Enable playing local files in iOs.

This commit is contained in:
andreivolgin 2020-01-20 09:54:00 -05:00
parent f01bb0c1a5
commit 0715f84b1a
1 changed files with 10 additions and 1 deletions

View File

@ -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