Mdemovie didexitfulscreen message not working in ios

I am uploading youtube video to webview. Since my app is an online radio app, the radio plays in the background. When I click on webview it redirects the video full screen to mpmovieplayer. I want when someone clicks on webview or when mpmovieplayer starts playing video, the radio should pause. But how can I keep track of when mpmoviepayer starts playing and exits the game. I have also set MPMoviePlayerDidExitFullscreenNotification notification in my method viewdidload

. But he was never called.

self.videoTitleLabel.text = videoInfo.videoTitle;

//NSString *vidUrl = [videoInfo.videoURL stringByReplacingOccurrencesOfString:@" " withString:@"%20"];

CGSize scrSize = [[UIScreen mainScreen] bounds].size;//appDel.window.frame.size;

float imgSclToX = scrSize.width/16.0;

int imgWidth = (int) (scrSize.width -18);
int imgHeight = (int) ((float)(9.0)*imgSclToX);

// DebugLog(@"Yo-----> Window: %@ Width: %i Height: %i", NSStringFromCGSize(scrSize), imgWidth, imgHeight);

NSString *htmlStr = @"";
// htmlStr = [htmlStr stringByAppendingFormat:@"<iframe width=\"%i\" height=\"%i\" src=\"%@\" frameborder=\"0\" allowfullscreen></iframe>", imgWidth, imgHeight, vidUrl];

NSString *tStr = videoInfo.videoURL;
// NSString *tStr = @"https://www.youtube.com/watch?v=yz_j7nVCJJ0";
tStr = [tStr substringFromIndex:([tStr rangeOfString:@"v="].location+2)];

htmlStr = [NSString stringWithFormat:@"<iframe  type=\"application/x-shockwave-flash\" width=\"%i\" height=\"%i\" src=\"https://www.youtube.com/embed/%@\" frameborder=\"0\" allowfullscreen></iframe>", imgWidth, imgHeight, tStr];

NSString *embedHTML = [NSString stringWithFormat:@"<html><head></head><body>%@<p><b>Artist:</b> %@<br><b>Composer:</b>%@<p>%@</p></body></html>", htmlStr, videoInfo.videoArtist, videoInfo.videoCompositor, videoInfo.videoDescription];
[self.myWebview loadHTMLString: embedHTML baseURL: nil];

if([appDelegate.lastState isEqualToString:@"play"])
{
    [appDelegate pausePlayer];
    manuallyPause = YES;
}

      

+3


source to share


1 answer


See answers at fooobar.com/questions/239294 / ... ( user1717750 ) and fooobar.com/questions/239294 / ... ( Selvin ).

Use AVPlayerItemBecameCurrentNotification in conjunction with UIWindowDidBecomeVisibleNotification and UIWindowDidBecomeHiddenNotification for iOS 8 instead of UIMoviePlayerControllerDidExitFullscreenNotification.



It works for me! )

0


source







All Articles