Skip to content
New issue

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

Update index.js #144

Closed
wants to merge 1 commit into from
Closed

Update index.js #144

wants to merge 1 commit into from

Conversation

yuzhen1024
Copy link

@yuzhen1024
Copy link
Author

@rocka
Copy link
Member

rocka commented Aug 12, 2022

这样能解决唤醒屏幕的问题吗? prevent-display-sleep 的优先级是高于 prevent-app-suspension 的,如果什么地方的网络请求会触发 prevent-display-sleep ,屏幕还是会被唤醒。

如果主动设置 prevent-app-suspension 就能阻止 powerSaveBlocker 的其它行为,那么在应用启动的时候直接设置也是不合理的,因为有时候确实需要 prevent-display-sleep 的能力,比如播放 MV 视频的时候。

@yuzhen1024
Copy link
Author

这样能解决唤醒屏幕的问题吗? prevent-display-sleep 的优先级是高于 prevent-app-suspension 的,如果什么地方的网络请求会触发 prevent-display-sleep ,屏幕还是会被唤醒。

已测试,可行。只要不主动 powerSaveBlocker.start('prevent-display-sleep')
(虽然在编译的时候遇到了点麻烦导致起初没能测试成功。并不是 npm build 即可,而需要 npm dist && node script/packager.js clean && npm build。)

如果主动设置 prevent-app-suspension 就能阻止 powerSaveBlocker 的其它行为,那么在应用启动的时候直接设置也是不合理的,因为有时候确实需要 prevent-display-sleep 的能力,比如播放 MV 视频的时候。

后续只需要确保在播放完视频 powerSaveBlocker.stop(id) 即可。

例如, 一个 API 调用A的类型是 prevent-app-suspension, 另一个调用B的类型是 prevent-display-sleep。 prevent-display-sleep 一直生效,直到 B 停止请求, 之后,prevent-app-suspension才生效。

@yuzhen1024
Copy link
Author

一段时间的观察。
prevent-app-suspension 确实需要被关闭,因为它虽然不阻止屏幕自动关闭,但屏蔽了系统的自动锁屏。目前它解决了我的短时之需。

@yuzhen1024 yuzhen1024 closed this Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants