YHNativeMedia.m
979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// YHNativeMedia.m
// YohoExplorerDemo
//
// Created by gaoqiang xu on 4/13/15.
// Copyright (c) 2015 gaoqiang xu. All rights reserved.
//
#import "YHNativeMedia.h"
@import MediaPlayer;
NSString * const YHNative_Media = @"Native_Media";
@implementation YHNativeMedia
- (NSString *)actionName
{
return YHNative_Media;
}
- (void)playMedia
{
if (!self.options || !self.options[@"url"]) {
self.failureCallBack(@"No media url detected!");
return;
}
NSString *url = self.options[@"url"];
MPMoviePlayerViewController *vc = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:url]];
if (!vc) {
self.failureCallBack(@"Unsupported url!");
return;
}
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:vc animated:YES completion:nil];
self.successCallBack(nil, NO);
}
- (NSArray *)availableFunctions
{
return @[ @"playMedia" ];
}
@end