use-wake-lock | React hook for the Screen Wake Lock API | Frontend Framework library
kandi X-RAY | use-wake-lock Summary
kandi X-RAY | use-wake-lock Summary
:bulb: A React hook for the Screen Wake Lock API. Can be used to prevent a device's screen from turning off.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of use-wake-lock
use-wake-lock Key Features
use-wake-lock Examples and Code Snippets
Community Discussions
Trending Discussions on use-wake-lock
QUESTION
I'm making a music player, and there was a problem when switching to the next song. When the phone is in working condition (the screen is on) the tracks switch smoothly, when the screen is off there is a long pause, the song starts only after a long time (very long!!!) or when the screen is turned on. Also, everything works well with a headset (Bluetooth), songs switch smoothly even when the screen is turned off. I use MediaPlayer.prepare
to prepare the track (music files are taken from the SD card, so I don't see any point in using MediaPlayer.prepareAsync()
). Songs are played using Service. Since the player works fine when the screen is turned on and poorly when it is turned off, then this is the problem. I tried everything, searched all the articles about media player in Russian and English, reviewed YouTube. Help is also accepted on Kotlin.
(here is the same question. but there is no answer. How to use wake lock for android mediaplayer?)
Below is the code:
ANSWER
Answered 2021-Nov-02 at 07:18I found a problem. It was necessary to call MediaPlayer.setwakemode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install use-wake-lock
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page