是否可以让视频播放完后不关闭?因此,这将允许用户在视频结束时按“完成”,然后视频将关闭。
ViewController.h
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@interface player1: UIViewController {
}
-(IBAction) playMovie;
@end
ViewController.m
#import "ViewController.h"
@implementation player1
-(IBAction) playMovie {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"2.DragtoopenfileinaVM" ofType:@"mp4"]];
MPMoviePlayerViewController *windowsmac = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:windowsmac];
windowsmac.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[windowsmac.moviePlayer play];
windowsmac = nil;
}
这是我正在使用的编码,有人可以帮忙吗?
最佳答案
moviePlayer = [[MPMoviePlayerViewController alloc]initWithContentURL:[NSURL fileURLWithPath:path]];
[[NSNotificationCenter defaultCenter] removeObserver:moviePlayer
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer.moviePlayer];
[self presentViewController:moviePlayer animated:YES completion:nil];
关于ios - 视频播放后关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31385003/