Tag: mpmovieplayercontroller

iPad MPMoviePlayerController – 禁用全屏

有没有办法来禁用MPMoviePlayerController的全屏button?

xcode – MPNowPlayingInfoCenter信息不显示在iOS 8上

我正在开发一个音乐应用程序,它应该在后台播放音乐。 我使用MPMoviePlayerController播放音乐。 我的代码来启动MPMoviePlayerController : NSString* resourcePath = [[NSBundle mainBundle] resourcePath]; resourcePath = [resourcePath stringByAppendingString:@"/music.m4a"]; NSError* err; self.player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:resourcePath]]; if (err) { NSLog(@"ERROR: %@", err.localizedDescription); } AVAudioSession *session = [AVAudioSession sharedInstance]; [session setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil]; [session setActive:YES error:nil]; [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; [self.player setShouldAutoplay:NO]; [self.player setControlStyle: MPMovieControlStyleEmbedded]; self.player.view.hidden = YES; [self.player prepareToPlay]; 当我执行[self.player […]

强制整个屏幕上的横向方向MPMoviePlayerController在退出全屏时阻止正确的旋转

我有一个支持所有接口方向的iPhone应用程序(iOS6 +)。 但是,当MPMoviePlayerController正在全屏播放video时,只应支持横向。 我发现堆栈溢出下面的解决scheme,它的工作原理。 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerWillEnterFullscreenNotification:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerWillExitFullscreenNotification:) name:MPMoviePlayerWillExitFullscreenNotification object:nil]; … -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if (self.landscapeOnlyOrientation) { return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; } return UIInterfaceOrientationMaskAll; } – (void)moviePlayerWillEnterFullscreenNotification:(NSNotification*)notification { self.landscapeOnlyOrientation = YES; } – (void)moviePlayerWillExitFullscreenNotification:(NSNotification*)notification { self.landscapeOnlyOrientation = NO; } 然而,一个恼人的问题仍然存在,即如果video以纵向方式退出全屏(在强制横向播放之后),则底层视图不会旋转回来。 我必须手动将设备旋转到横向,然后回到纵向触发更新方向。 有什么办法可以触发这种更新程序? 下面的一组截图应该说明我的意思: 注意:由于各种原因,使用MPMoviePlayerViewController是不可能的。

如何使用MPMoviePlayerController播放video时将audio静音/取消静音?

我创build了我自己的自定义控件,用于MPMoviePlayerController 。 到目前为止,除了静音button控制之外,所有的工作都正常。 在创buildMPMoviePlayerController实例之前,我使用以下代码configuration了MPMoviePlayerController 。 NSError *modeError = nil; [self.audioSession setMode:AVAudioSessionModeMoviePlayback error:&modeError]; if (modeError != nil) { NSLog(@"Error setting mode for AVAudioSession: %@", modeError); } NSError *categoryError = nil; [self.audioSession setCategory:AVAudioSessionCategoryPlayback error:&categoryError]; if (categoryError != nil) { NSLog(@"Error setting category for AVAudioSession: %@", categoryError); } 然后在我的静音buttoncallback方法我有以下代码: NSError *activeError = nil; [self.audioSession setActive:NO error:&activeError]; if (activeError […]

完成button事件MPMoviePlayerController

在我的iPhone上,我以全屏模式播放video/audio文件。 当video/audio文件到达结尾时,将触发以下方法: – (void) movieFinishedCallback:(NSNotification*) aNotification { MPMoviePlayerController *player = [aNotification object]; [player stop]; [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player]; [player autorelease]; [moviePlayer.view removeFromSuperview]; NSLog(@"stopped?"); } 这工作正常! 但问题是,当我按下“完成”button时,video/audio文件仍在播放。 那么这个方法不会被触发 任何人都知道如何按下“完成”button时捕捉事件? 因为现在媒体播放器停留在视图中。 它不消失。

我如何知道用户点击iPhone中播放控件的快进和快退button

我想实施以下的事情, 应用程序在后台运行音乐或video(使用MPMoviePlayerController )。 用户双击主页button,进入显示播放控制的第一个屏幕(快退,播放或暂停,快进button) 用户点击快退或快进button。 然后,应用播放上一个或下一个音乐或video。 第三步,我应该知道哪个button被点击。 (正如我自然知道,当前正在播放的项目已暂停,停止..使用MPMoviePlayerPlaybackStateDidChangeNotification通知)。 我应该注册哪个通知? 或者还有其他的方法吗?

如何在iOS中使用MPMoviePlayerController播放videostream

我试图通过按下button从iPhone上的互联网播放videostream。 我用了很多代码示例,但没有任何工作。 有了这个代码,它将打开一个没有任何videostream或控件的黑色视图。 (stream本身起作用) NSURL *url = [NSURL URLWithString:@"http://MyStreamURL.com"]; MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer]; moviePlayer.controlStyle = MPMovieControlStyleDefault; moviePlayer.shouldAutoplay = YES; [self.view addSubview:moviePlayer.view]; [moviePlayer setFullscreen:YES animated:YES];

MPMoviePlayer完成button问题

我正在使用MPMoviePlayer来显示video。 我进入全屏,当完成button被点击时,我希望它从我的视图中删除整个电影播放器​​。 目前它只能走出全屏模式。 你如何跟踪被单击的doneButton,或者我该如何解决这个问题?

在iPhone应用程序中播放YouTubevideo而不使用UIWebView?

我想从我的iPhone应用程序播放YouTubevideo。 我必须尝试使用​​以下代码在iPhone应用程序中播放YouTubevideo, [self playVideo:@"http://www.youtube.com/watch?v=WL2l_Q1AR_Q" frame:CGRectMake(20, 70, 280, 250)]; – (void)playVideo:(NSString *)urlString frame:(CGRect)frame { NSString *embedHTML = @"\ <html><head>\ <style type=\"text/css\">\ body {\ background-color: transparent;\ color: white;\ }\ </style>\ </head><body style=\"margin:0\">\ <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \ width=\"%0.0f\" height=\"%0.0f\"></embed>\ </body></html>"; NSString *html = [NSString stringWithFormat:embedHTML, urlString, frame.size.width, frame.size.height]; UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame]; [videoView loadHTMLString:html baseURL:nil]; […]

iOS 6中的自动旋转具有奇怪的行为

我有UITabBarController应用程序播放video,并显示其他UITabBar选项卡中的其他信息。 在iOS 6 UIView旋转方法已被弃用,现在我需要使用shouldAutoRotate和supportedInterfaceOrientations方法。 对于video播放我使用MPMoviePlayerViewController 。 如何只旋转这个播放器视图? 我只能旋转整个应用程序,但不想这样做。 我介绍MPMoviePlayerViewController但它不像iOS 5和更早版本那样旋转。 在plist设置中,我只设置了1个人像界面方向。 如果我设置其他 – 整个应用程序将被旋转。