Merge pull request #26 from volgin/master
Enable playing local files in iOS.
This commit is contained in:
commit
ad88e986f3
|
@ -155,7 +155,16 @@
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:_endObserver];
|
[[NSNotificationCenter defaultCenter] removeObserver:_endObserver];
|
||||||
_endObserver = 0;
|
_endObserver = 0;
|
||||||
}
|
}
|
||||||
AVPlayerItem* playerItem = [[AVPlayerItem alloc] initWithURL:[NSURL URLWithString:url]];
|
|
||||||
|
AVPlayerItem *playerItem;
|
||||||
|
|
||||||
|
//Allow iOs playing both external links and local files.
|
||||||
|
if ([url hasPrefix:@"file://"]) {
|
||||||
|
playerItem = [[AVPlayerItem alloc] initWithURL:[NSURL fileURLWithPath:[url substringFromIndex:7]]];
|
||||||
|
} else {
|
||||||
|
playerItem = [[AVPlayerItem alloc] initWithURL:[NSURL URLWithString:url]];
|
||||||
|
}
|
||||||
|
|
||||||
[playerItem addObserver:self
|
[playerItem addObserver:self
|
||||||
forKeyPath:@"status"
|
forKeyPath:@"status"
|
||||||
options:NSKeyValueObservingOptionNew
|
options:NSKeyValueObservingOptionNew
|
||||||
|
|
Loading…
Reference in New Issue