我正在为我的应用程序制作视频播放器模块。
这是我的 .h 文件:
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@interface SpanishViewController : UIViewController
- (IBAction)Video1Button:(id)sender;
@property (nonatomic, strong) MPMoviePlayerController *moviePlayer;
@end
这是 .m 文件中按钮执行的事件代码:
- (IBAction)Video1Button:(id)sender {
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"01" ofType:@"mp4"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayerController];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.fullscreen = YES;
[moviePlayerController play];
}
根据标准以 mp4 编码并在 iOS 上运行的视频。结果是 -这里
视频无法启动,“完成”按钮不起作用..我不明白出了什么问题。请帮我。