どちらもviewDidLoad()にあります。 このobjective-cソースファイルの何が問題なのですか? スウィフト版は魅力のように機能します... Xcode ver。 8.2 iOSの10このObjective-CコードがAVPlayerViewControllerビデオを再生しないのはなぜですか?
スウィフト(OK):
let path : String = Bundle.main.path(forResource: "charlie", ofType: "mp4")!
let movieurl : URL = URL(fileURLWithPath: path)
let movie : AVPlayerViewController = AVPlayerViewController()
movie.view.frame = self.view.bounds
let player : AVPlayer = AVPlayer(url: movieurl)
movie.player = player
self.view.addSubview(movie.view)
player.play()
は、Objective-Cの(ビデオを再生/表示されません):
AVPlayerViewController* movie;
AVPlayer* player;
NSString *path = [[NSBundle mainBundle]
pathForResource:@"charlie" ofType:@"mp4"];
NSURL *url = [NSURL URLWithString:path] ;
movie = [[AVPlayerViewController alloc] init];
movie.view.frame = self.view.bounds;
player = [[AVPlayer alloc] initWithURL:url];
[movie setPlayer:player];
[self.view addSubview:movie.view];
[player play];
コードはおそらくビデオを見つけられませんでした。このhttp://stackoverflow.com/questions/1949992/working-with-paths-from-nsbundle-mainbundle-resourcepathを使用してバンドルパスを修正しようとしましたか? –