#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
IOS Video Player Singleton class