标签:
#import <Foundation/Foundation.h>
#import <MediaPlayer/MediaPlayer.h>
@interface XHMoviePlayer : MPMoviePlayerController
-(void)playWithUrl:(NSString *)url;
-(instancetype)init;
+(instancetype)defaultMoviePlayer;
-(void)playWithFilePath:(NSString *)path;
@end
#import "XHMoviePlayer.h"
@implementation XHMoviePlayer
-(instancetype)init
{
if (self == [super init]) {
}
return self;
}
+(instancetype)defaultMoviePlayer
{
static XHMoviePlayer *moviePlayer = nil;
static dispatch_once_t onceTaken;
dispatch_once(&onceTaken, ^{
moviePlayer = [[XHMoviePlayer alloc] init];
});
return moviePlayer;
}
-(void)playWithUrl:(NSString *)url
{
NSURL *Url = [NSURL URLWithString:url];
self.contentURL = Url;
[self play];
}
-(void)playWithFilePath:(NSString *)path
{
NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
self.contentURL = url;
[self play];
}
@end
标签:
原文地址:http://www.cnblogs.com/echo-imax/p/4262810.html