ios - 视频播放后关闭

标签 ios objective-c video

是否可以让视频播放完后不关闭?因此,这将允许用户在视频结束时按“完成”,然后视频将关闭。

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/

相关文章:

caching - 什么情况下浏览器会缓存<video>文件?

ios - 使用 Avplayer 在后台播放视频

ios - Xcode 6 - 无法为 Ad-Hoc 分发选择签名证书/配置文件。一直默认

iphone - 在 uitableview 中删除行

ios - UITableView setEditing 不显示删除按钮

objective-c - 当值改变时 KVO 不触发

iOS -- "add"方法出现在 codeSense 中的自动合成属性

ios - Ben Gottlieb 的 Twitter+OAuth iOS SDK - 返回 nil 的用户名参数

iphone - AFJSONRequestOperation 和文件数据的 AFNetworking 永远不会完成

ios - AVI 视频不适用于 AVPlayerViewController