LiteAVSDK / Player_iOS

Super player for iOS...
https://trtc.io/
1.11k stars 226 forks source link

强制打开息屏Bug #278

Closed chenjc0317 closed 2 years ago

chenjc0317 commented 2 years ago

最新SDK版本,在AppDelegate中设置了强制亮屏,但是去播放视频的时候会强制打开息屏,望尽快修复!!!

Vanson commented 2 years ago

这个问题官方解决了吗?

xx-li commented 2 years ago

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

解决方案:

  1. 加个定时器,在播放器页面不停的设置[UIApplication sharedApplication].idleTimerDisabled = true;
  2. hook这个方法,在播放器页面设置idleTimerDisabledfalse后将手动把它改为true
  3. 等腾讯修复或者降级到没这个问题的版本。
chenjc0317 commented 2 years ago

这个问题官方解决了吗? 最新的sdk没有解决,但是官方给了解决方法。在SuperPlayerView.m里操作

第一步:新增两个方法

第二步:在initializeThePlayer添加代码 // 解决息屏Bug [self keepIdleTimerDisabled];

第三步:在dealloc方法中移除监听 [[UIApplication sharedApplication] removeObserver:self forKeyPath:@"idleTimerDisabled"];