playing video in ios 6

馋奶兔 提交于 2019-12-11 03:46:50

问题


I wanted to play a video in ios 6. I am using Xcode 4.5. I write code below but getting error

 Test Demo[736:14003] [MPAVController] Autoplay: Disabling autoplay for pause
 Test Demo[736:14003] [MPAVController] Autoplay: Disabling autoplay
 Test Demo[736:14003] [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 1, on player: 0)

and my code

NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"TestVideo" ofType:@"m4v"];
NSURL *streamURL = [NSURL fileURLWithPath:videoPath];

MPMoviePlayerController *player =
[[MPMoviePlayerController alloc] initWithContentURL: streamURL];
[player prepareToPlay];
[player.view setFrame: self.view.bounds];  // player's frame must match parent's
[self.view addSubview: player.view];
// ...
[player play];`

回答1:


There could be many issues for your error.

1) Set a property for your MPMoviePlayerController and synthesize it. This may occur, if your MPMoviePlayerController releases before it plays.

2) add this code player.moviePlayer.movieSourceType = MPMovieSourceTypeFile;

3) As per documentation, .m4v extension is not mentioned to play.

4) Below screenshot will help you about supported formats.




回答2:


NSString *url   =   [[NSBundle mainBundle] pathForResource:@"santaMessage" ofType:@"mp4"];

moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];

[self.view addSubview:moviePlayer.view];

moviePlayer.fullscreen = YES;

moviePlayer.allowsAirPlay = YES;

[moviePlayer play];

///this worked like a charm



来源:https://stackoverflow.com/questions/13133023/playing-video-in-ios-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!