Author Topic: UIScreen and external display programming in iOS  (Read 8980 times)

Slacer

  • Newbie
  • *
  • Posts: 14
    • View Profile
UIScreen and external display programming in iOS
« on: August 12, 2013, 01:02:48 PM »
I have the issue to display in the second screen ( through the hdmi adaptor ) two views,where are displayed two AVPlayers, one above the other. It's possibile to display a view, two views or a portion of the main screen in the secondary screen? http://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/WindowAndScreenGuide/UsingExternalDisplay/UsingExternalDisplay.html#//apple_ref/doc/uid/TP40012555-CH3-SW1

In the Apple doc. I found only the basic implementation... If I must display only a viewcontroller, I must re-convert all my application to work with another viewcontroller?

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
Re: UIScreen and external display programming in iOS
« Reply #1 on: August 12, 2013, 02:06:23 PM »
You can either completely mirror the main interface on an external display or you can present a completely different UI. If you are showing different content, you can create a second window for the external display and use a separate view controller. Here is a good blog post on using AVIPlayer and/or MPMoviewPlayerController. AVIPlayer is a better choice if you need to play multiple videos simultaneously.

All the best!
Kevin

Slacer

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: UIScreen and external display programming in iOS
« Reply #2 on: August 13, 2013, 02:35:42 PM »
Thank for the reply, but I can't see the blog post :/
I use 2 AVplayer one above the other and I want to display only those in the external screen...
« Last Edit: August 13, 2013, 03:45:51 PM by Slacer »

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
Re: UIScreen and external display programming in iOS
« Reply #3 on: August 15, 2013, 12:36:11 PM »
You may need to be logged into the iOS Dev Center to see the link I posted. It's Apple Documentation under the topic "Multiple Display Programming Guide for iOS".

Kevin

Slacer

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: UIScreen and external display programming in iOS
« Reply #4 on: August 17, 2013, 04:16:37 PM »
Ah ok, I found that guide!
Now I have set up the external screen, but I have another big problem. It's hard to explain without see the code, but i'm trying to do it:
there is the main controller called "ViewController" where inside I can choose two video to play.
there is a class called avPlayer which simply sets the video player:
Code: [Select]
+ (Class)layerClass
{
    return [AVPlayerLayer class];
}

- (AVPlayer*)player
{
    return [(AVPlayerLayer*)[self layer]player];
}

- (void)setMovieToPlayer:(AVPlayer *)player
{

    [(AVPlayerLayer*)[self layer]setPlayer:player];
   
}

and another viewcontroller called "videoController" that control the container view ( and the HDMI output ).

I get the url of the video in the "ViewController", I pass it to "videoController" and I call the "setMovieToPlayer" method. But that method will be never called. No error, the sound of the video is playing, but the program never call the "setMovieToPlayer" method in videoController.

I have try to develop a player outside the container view and it works! I see the video and I can implement sound control and time control.

What I can do? How I can check why the method isn't called?

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
Re: UIScreen and external display programming in iOS
« Reply #5 on: August 17, 2013, 05:27:05 PM »
It's hard to tell what's going on from here. If you zip up the project and send it to me, I can take a look at it. You can put it in this DropBox folder:

https://www.dropbox.com/sh/qvtgpff1wg04a4e/-mR5fLOk4b

If you would rather not post it publicly, you can send me a link where I can download it. Just send an email to kevinm@oakleafsd.com.

P.S. When you zip up the project make sure you compress the parent folder that contains the .xcodeproj file.

Kevin


Slacer

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: UIScreen and external display programming in iOS
« Reply #6 on: August 18, 2013, 05:28:07 AM »
Thank you very much for your help, I just sent you an email ...

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
Re: UIScreen and external display programming in iOS
« Reply #7 on: August 20, 2013, 08:49:30 PM »
For you lurkers out there, the problem was caused by the avPlayer objects being null. When you declare a property, you must subsequently create an instance of an object to store in that property.

Objective-C allows you to send messages to null objects, so if you forget to create instances of objects you are referencing in your view controller, you won't get an error at run time--your app simply won't function! Typically you can create objects in your view controller's viewDidLoad method.

All the best!
Kevin