强制打开息屏Bug
chenjc0317 opened this issue · 3 comments
chenjc0317 commented
最新SDK版本,在AppDelegate中设置了强制亮屏,但是去播放视频的时候会强制打开息屏,望尽快修复!!!
Vanson commented
这个问题官方解决了吗?
xx-li commented
hook可以发现是这行代码的问题
frame #5: 0x00000001025ba9a0 Aspects`__ASPECTS_ARE_BEING_CALLED__(self=0x000000013dd09b10, selector="forwardInvocation:", invocation=0x0000000282558ff0) at Aspects.m:480:5
frame #6: 0x0000000187fe5654 CoreFoundation`___forwarding___ + 736
frame #7: 0x0000000187fe7c10 CoreFoundation`_CF_forwarding_prep_0 + 96
frame #8: 0x000000010104395c DTVideo_Example`-[TXIJKMediaModule updateIdleTimerOnMainThread:] + 80
frame #9: 0x00000001893b8468 Foundation`__NSThreadPerformPerform + 188
frame #10: 0x0000000187f5d07c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
frame #11: 0x0000000187f5cf78 CoreFoundation`__CFRunLoopDoSource0 + 208
解决方案:
- 加个定时器,在播放器页面不停的设置
[UIApplication sharedApplication].idleTimerDisabled = true;
。 - hook这个方法,在播放器页面设置
idleTimerDisabled
为false
后将手动把它改为true
。 - 等腾讯修复或者降级到没这个问题的版本。
chenjc0317 commented
这个问题官方解决了吗?
最新的sdk没有解决,但是官方给了解决方法。在SuperPlayerView.m里操作
第一步:新增两个方法
- -(void)keepIdleTimerDisabled {
[[UIApplication sharedApplication] setIdleTimerDisabled: YES];
[[UIApplication sharedApplication] addObserver:self forKeyPath:@"idleTimerDisabled" options:NSKeyValueObservingOptionNew context:nil];
} - -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
if (![UIApplication sharedApplication].idleTimerDisabled) {
[UIApplication sharedApplication].idleTimerDisabled = YES;
}
}
第二步:在initializeThePlayer添加代码
// 解决息屏Bug
[self keepIdleTimerDisabled];
第三步:在dealloc方法中移除监听
[[UIApplication sharedApplication] removeObserver:self forKeyPath:@"idleTimerDisabled"];