We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
设备: 在iOS14.4.2下和iOS12.1.4下百分百复现,而在15.1上没有复现 复现步骤 1.创建player
(void)avPlayerDemo1 { NSString *url = DEMO_URL_HLS; NSURL *URL = [NSURL URLWithString:url]; NSURL *playbackUrl =[SJMediaCacheServer.shared playbackURLWithURL:URL]; self.avPlayer = [AVPlayer playerWithURL:playbackUrl]; self.avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer]; self.avPlayerLayer.frame = self.view.bounds; [self.view.layer addSublayer:self.avPlayerLayer]; [self addObservers:self.avPlayer.currentItem]; }
(void)addObservers:(AVPlayerItem*)item { [item addObserver:self forKeyPath:@"loadedTimeRanges" options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context:nil]; [item addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context:nil]; }
(void)observeValueForKeyPath:(NSString*)path ofObject:(id)object change:(NSDictionary*)change context:(void*)context {
if ([path isEqualToString:@"status"]) { AVPlayerItem* item = (AVPlayerItem*)object; switch (item.status) { case AVPlayerItemStatusFailed: // [UIView showToast:@"视频播放出错啦~"]; break; case AVPlayerItemStatusUnknown: // NSLog(@">>>>>>>>>>>>>>>>>>视频未知状态"); break; case AVPlayerItemStatusReadyToPlay: // NSLog(@">>>>>>>>>>>>>>视频已经准备好播放了duration:%lld",self.duration); [self.avPlayer play]; [self.avPlayer seekToTime:CMTimeMake(30000, self.avPlayer.currentItem.asset.duration.timescale)];
break; }
} }
当前代码运行起来,就会发现,在低版本中会出现ts片段下载失败的问题,导致界面假死现象。请问这个应该如何解决
The text was updated successfully, but these errors were encountered:
No branches or pull requests
设备: 在iOS14.4.2下和iOS12.1.4下百分百复现,而在15.1上没有复现
复现步骤
1.创建player
(void)avPlayerDemo1 {
NSString *url = DEMO_URL_HLS;
NSURL *URL = [NSURL URLWithString:url];
NSURL *playbackUrl =[SJMediaCacheServer.shared playbackURLWithURL:URL];
self.avPlayer = [AVPlayer playerWithURL:playbackUrl];
self.avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];
self.avPlayerLayer.frame = self.view.bounds;
[self.view.layer addSublayer:self.avPlayerLayer];
[self addObservers:self.avPlayer.currentItem];
}
(void)addObservers:(AVPlayerItem*)item {
[item addObserver:self
forKeyPath:@"loadedTimeRanges"
options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
context:nil];
[item addObserver:self
forKeyPath:@"status"
options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
context:nil];
}
(void)observeValueForKeyPath:(NSString*)path
ofObject:(id)object
change:(NSDictionary*)change
context:(void*)context {
if ([path isEqualToString:@"status"]) {
AVPlayerItem* item = (AVPlayerItem*)object;
switch (item.status) {
case AVPlayerItemStatusFailed:
// [UIView showToast:@"视频播放出错啦~"];
break;
case AVPlayerItemStatusUnknown:
// NSLog(@">>>>>>>>>>>>>>>>>>视频未知状态");
break;
case AVPlayerItemStatusReadyToPlay:
// NSLog(@">>>>>>>>>>>>>>视频已经准备好播放了duration:%lld",self.duration);
[self.avPlayer play];
[self.avPlayer seekToTime:CMTimeMake(30000, self.avPlayer.currentItem.asset.duration.timescale)];
}
}
当前代码运行起来,就会发现,在低版本中会出现ts片段下载失败的问题,导致界面假死现象。请问这个应该如何解决
The text was updated successfully, but these errors were encountered: