Tag: mpmovieplayer

AVPlayer不显示video

我想在游戏开始时播放电影。 我正在使用AVPlayer来做到这一点。 我的问题是,当我注册一个KVO来检查我的AVPlayer的状态时,我的游戏照常进行,没有等待video加载和完成。 因此,我只能听到我的.mov文件中的audio,并且看不到任何video(因为我的游戏已经开始)。 我希望video加载和完成之前进行游戏。 代码如下: @interface RMVideoView : NSView { NSURL* _videoURL; AVPlayer* _player; AVPlayerLayer* _playerLayer; } @property (nonatomic, readonly, strong) AVPlayer* player; @property (nonatomic, readonly, strong) AVPlayerLayer* playerLayer; @property (nonatomic, retain) NSURL* videoURL; – (void) play; @end static void *RMVideoViewPlayerLayerReadyForDisplay = &RMVideoViewPlayerLayerReadyForDisplay; static void *RMVideoViewPlayerItemStatusContext = &RMVideoViewPlayerItemStatusContext; @interface RMVideoView() – (void)onError:(NSError*)error; – (void)onReadyToPlay; […]

iOS – uitabbarcontroller之前的login视图

我想在login成功时显示接口UITabBar 。 我在AppDelegate声明了接口UITabBar ,但是在login成功之后,我不知道如何调用接口。 这是我的代码: appdelegate.m -(void)loadInterface { [self configureiPhoneTabBar]; } -(void)configureiPhoneTabBar { UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController; UIViewController *controller1 = [[tabBarController viewControllers] objectAtIndex:0]; [self configureTabBarItemWithImageName:@"home_ON.png" : @"home.png" andText:@"Trang chủ" forViewController:controller1]; UIViewController *controller2 = [[tabBarController viewControllers] objectAtIndex:1]; [self configureTabBarItemWithImageName:@"channel_ON.png" : @"tvChannel.png" andText:@"Kênh" forViewController:controller2]; } 和loginviewcontroller.m – (IBAction)btnLogin:(id)sender { [self performSegueWithIdentifier:@"idenLogin" sender:self]; AppDelegate *delegate = (AppDelegate […]

MPMoviePlayerController – 检测和不同上一页/下一页button

我已经通过下面的代码实现了检测prev / nextbutton的点击,但是还没有find区分两次点击的方法。 在@implementation MyMovieController:MPMoviePlayerController [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieChangeCallBack:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil]; 并定义– (void)movieChangeCallBack:(NSNotification *)aNotification – (void)movieChangeCallBack:(NSNotification*) aNotification { if (self.playbackState == MPMoviePlaybackStateStopped) { //Touched 'Previous' or 'Next' button. } } 有没有办法判断“上一个”或“下一个”button是否被点击? 谢谢 :)

MPMoviePlayerViewController不会播放电影,立即启动和closures

我试图用MPMoviePlayerViewController播放video,我介绍了MPMoviePlayerViewController,但1秒后,他正在解散。 这是我的代码: 。H: #import <MediaPlayer/MediaPlayer.h> @property (strong, nonatomic) MPMoviePlayerViewController *moviePlayerViewController; .M: – (void)playmovie { NSString *databaseName = @"NO.mp4"; NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentDir = [documentPaths objectAtIndex:0]; NSString *databasePath = [documentDir stringByAppendingPathComponent:databaseName]; NSURL *movieURL = [NSURL fileURLWithPath:databasePath]; UIGraphicsBeginImageContext(CGSizeMake(1,1)); self.moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL]; [self presentMoviePlayerViewControllerAnimated:self.moviePlayerViewController]; UIGraphicsEndImageContext(); [self.moviePlayerViewController.moviePlayer prepareToPlay]; [self.moviePlayerViewController.moviePlayer play]; } 请告诉我我做错了什么。 提前致谢!

在没有UIWebView的情况下从YouTube链接播放video

我想通过YouTube链接在我的应用中播放video,例如: http://www.youtube.com/watch?v=Uner-3tTY1I : http://www.youtube.com/watch?v=Uner-3tTY1I Uner-3tTY1I。 但我不想将用户redirect到应用程序中的任何Web视图。 只想在我的应用程序的当前视图中播放video播放器中的video。 是否有可能不redirect到UIWebView播放video? 如果可能的话,我该怎么做? 我在这里先向您的帮助表示感谢。

在iOS 7中显示带有声音的黑屏的MPMoviePlayerController,在iOS 6中运行良好

// introVideoViewController #import <AVFoundation/AVAudioSession.h> #import <AudioToolbox/AudioServices.h> #import <AVFoundation/AVAudioPlayer.h> #import <MediaPlayer/MediaPlayer.h> @property(nonatomic,strong) MPMoviePlayerController *playercontroller; 嗨,大家好, 有人知道在iOS 7中我可以听到我的video声音,但不是video,它在iOS 6中工作正常。 任何意见,不胜感激。 // introVideoViewController //prepare & init video -(void)prepareIntroVideo { NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"intro_movie" ofType:@"mp4"]]; //NSURL *url = [NSURL URLWithString:@"http://km.support.apple.com/library/APPLE/APPLECARE_ALLGEOS/HT1211/sample_iTunes.mov"]; self.playercontroller = [[MPMoviePlayerController alloc] initWithContentURL:url]; [self.playercontroller.view setFrame:CGRectMake(0, 0, 320,480)]; self.playercontroller.movieSourceType = MPMovieSourceTypeFile; self.playercontroller.scalingMode = MPMovieScalingModeAspectFill; self.playercontroller.fullscreen = […]

iOS – video不能仅在iOS7上通过iPhone旋转?

我做了什么? 我正在MPMoviePlayerViewController的扩展类中播放video,并已经实现了如下的方向function – (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){ return FALSE; } else{ return TRUE; } } – (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { [self setControlsPositions:toInterfaceOrientation]; } -(BOOL)shouldAutorotate { return YES; } 我面临什么问题? 应用程序工作正常,直到iPhone6上的iOS6 Almong与iPad(与iOS7),但video不会旋转通过安装iOS7的iPhone。 这个问题的原因是什么?如何解决? 更新 我发现,如果setMovieSourceType设置为MPMovieSourceTypeUnknown ,则video会旋转,但设置为“MPMovieSourceTypeStreaming”时不会旋转

如何在iOS中使用MpMoviePlayerController在UISlider上显示缓冲数据?

我正在使用MPMoviePlayerController来播放audio,我想显示像这样的滑块缓冲数据… 我想在滑块中显示像红色部分的缓冲区数据。 我试图谷歌它。 但我没有得到任何解决scheme。 以及如何使滑块自定义? 提前致谢…

在下载iOS时stream式传输video

我正在使用iOS 7,我有一个.mp4video,需要在我的应用程序中下载。 video很大(〜1 GB),这就是为什么它不包括在应用程序的一部分。 我希望用户能够在开始下载时立即开始观看video。 我也希望video能够被caching在iOS设备上,以便用户不需要稍后再下载。 播放video的普通方法(渐进式下载和实时stream式传输)似乎不能让您cachingvideo,因此我已经制作了自己的Web服务,将video文件分块并将字节stream式传输到客户端。 我使用NSURLConnection开始HTTPstream式传输: self.request = [[NSMutableURLRequest alloc] initWithURL:self.url]; [self.request setTimeoutInterval:10]; // Expect data at least every 10 seconds [self.request setHTTPMethod:@"GET"]; self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:YES]; 当我收到一个数据块时,我将它追加到本地副本的末尾: – (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { NSFileHandle *handle = [NSFileHandle fileHandleForWritingAtPath:[self videoFilePath]]; [handle truncateFileAtOffset:[handle seekToEndOfFile]]; [handle writeData:data]; } 如果我让设备运行,文件下载成功,我可以使用MPMoviePlayerViewController播放它: NSURL *url=[NSURL fileURLWithPath:self.videoFilePath]; […]

MPMoviePlayer在iOS 9中

我已经做了iOS 8的function在后台播放电影,现在当我想在iOS 9中使用它,它给了我一个警告,并说,最好不要使用MPMoviePlayer,而是使用AVPlayer。 但是我对AVPlayer一无所知。 我怎样才能将其转换为适当的function没有使用AVPlayer而不是MPMoviePlayer的警告? inheritance人的function: func playVideo() ->Bool { let path = NSBundle.mainBundle().pathForResource("video", ofType:"mov") //take path of video let url = NSURL.fileURLWithPath(path!) moviePlayer = MPMoviePlayerController(contentURL: url) //asigning video to moviePlayer if let player = moviePlayer { player.view.frame = self.view.bounds //setting the video size to the view size player.controlStyle = MPMovieControlStyle.None //Hiding the Player controls […]