Skip to content

Sound disappears after 5 minutes while screen is in sleep mode #8

@a-bytecode

Description

@a-bytecode

Sound disappears after 5 minutes while screen is in sleep mode

Hi everyone, if someone know how to fix this problem I would be really thankful for that.
Ive tried to solve this problem with wakelock & wifilock at the mediaPlayer but both are not working still the same problem.

powerManager = requireActivity().getSystemService(POWER_SERVICE) as PowerManager
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"radiosharp:wakelockv1")
wifiManager = requireActivity().getSystemService(Context.WIFI_SERVICE) as WifiManager
wifiLock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "radiosharp:wifilockv1")

binding.playImageDetail.setOnClickListener {
wifiLock.acquire()
Log.d("WIFILOCK","WIFILOCK ${wifiLock.isHeld}")
wakeLock.acquire(30601000L /30 minutes/)
Log.d("WAKELOCK","WAKELOCK: ${wakeLock.isHeld}")
mediaPlayer!!.start()
mediaPlayer!!.setScreenOnWhilePlaying(true)
binding.playImageDetail.visibility = View.GONE
binding.stopImageDetail.visibility = View.VISIBLE
}

this issue happens after a few minutes if mobile phone screen turns into sleep mode loosing the connection, I guess cause the WIFI goes into sleep mode aswell... I've tried to use wifilock to give him full & high preferences to work. But its not working im running out out ideas now.

I would preciate any help. Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions