2

Is there any way to know when the Youtube player/plugin on iPad goes fullscreen?

I have a UIWebview being displayed inside a Modal view controller that contains a Youtube video. If the user choose to view the Youtube video in fullscreen mode, it's displayed in fullscreen (naturally), but behind the UIWebview's modal view.

I'd like to know if some Notification or Delegate message is sent when the video starts to play in fullscreen mode, so that I would be able dismiss my modal view controller (or bring the Youtube fullscreen video to front in some way).

Thanks in advance.

Eduardo Coelho
  • 1,953
  • 8
  • 34
  • 60

3 Answers3

2

I think the best way is to :
1°) Know it by JS (because it's inside the UIWebView), like adding a click() event on the youtube object.
2°) Do an JS action and caught it with the UIWebViewDelegate

Maybe there is a better solution.

Good Luck !

Vinzius
  • 2,890
  • 2
  • 26
  • 27
  • Thanks for the answer Vinzius. I'll try your approach. I really don't know a thing about Javascript specifics. Could you indicate me some starting point guide to achieve what you proposed? Thanks – Eduardo Coelho Oct 04 '10 at 14:05
  • 2
    You should take a look at http://www.jqtouch.com/ && http://jquery.com/ which are a good help :-) You just need to add a click(); event on the youtube object. Then to send a signal to the webview Delegate by trying to access a page (with - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType) – Vinzius Oct 04 '10 at 14:12
1

For anyone interested, I found an alternative workaround for this.

I created a custom UIView inherited class for the view containing the webview. Responding to the (BOOL)pointInside event, if the touch event took place within coordinates of YouTube's 'fullscreen' button on the bottom right, I passed a notification to trigger a dismissal of the modalviewcontroller.

A little ugly, but it works for me!

3advance
  • 295
  • 2
  • 10
0

As per @prabhu-natarajan

in ViewDidLoad add the following code

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(VideoExitFullScreen:) name:@"UIMoviePlayerControllerDidExitFullscreenNotification" object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(VideoEnterFullScreen:) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];

The following methods are for showing the message/functions for respective process of entering/exiting to/from full screen

- (void)VideoExitFullScreen:(id)sender{
 // Your respective content/function for Exit from full screen
}

- (void)VideoEnterFullScreen:(id)sender{
// Your respective content/function for Enter to full screen
}

From : This link

Community
  • 1
  • 1
g212gs
  • 863
  • 10
  • 26