tags:

views:

245

answers:

4

Hello,

I am trying to play a video like this

self.webView = [[UIWebView alloc] initWithFrame: CGRectMake(0.0, 0.0, 1.0, 1.0)];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL: urlToMovie];
[self.webView loadRequest: request];
[request release];

could anyone tell me how can i get moviePlayerWindow (UIWindow ) handler if i am playing with the help of safari.

Is there any way to get movie notifications? like did finish loading, finish playing etc.

thank you for your responses :)

A: 
NSArray *windows = [[UIApplication sharedApplication] windows]; 

if ([windows count] > 1) {  // Locate the movie player window  
   UIWindow * moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];    
 // ... and now you can add views and play around with the window directly
} 

There is only one notification you can get at.

http://www.iphonedevsdk.com/forum/iphone-sdk-development/26322-all-mpmovieplayercontroller-notifications.html

David Sowsy
A: 

You will not get player window handler like this (if you are using safari to play video)

A: 

Then could you tell me how we will get player window handler?

iPhoneMan
A: 

Skip the UIWebView and use MPMoviePlayerController directly, which provides the following notifications:

MPMoviePlayerContentPreloadDidFinishNotification Notifies observers that the movie is now in memory and ready to play. The affected movie player is stored in the object parameter of the notification. If an error occurred during loading, the userInfo dictionary of this notification contains a key with the name “error” whose value is the NSError object describing the problem.

MPMoviePlayerPlaybackDidFinishNotification Notifies observers that the movie finished playing. The affected movie player is stored in the object parameter of the notification.

MPMoviePlayerScalingModeDidChangeNotification Notifies observers that the scaling mode property of the player changed. The affected movie player is stored in the object parameter of the notification. User actions may also cause the media player to send this notification.