Play audio from a Music Video using Youtube API in android, when my app is minimized

徘徊边缘 提交于 2019-12-21 17:27:45

问题


I am working on an app that uses the Youtube API. Since I'm concentrating mainly on MUSIC *VIDEOS* from Youtube, I need to play the audio of the video in the background when I navigate away from the app. But every time I navigate to another app, the video pauses. What can I do to get this issue fixed? Please help me. Thanks in advance


回答1:


From my understanding, the activity will pause when it goes to the background. Please refer to android activity life cycle.
When the activity goes to pause state, the video and audio linked with it will pause.
You will need a service to stream the audio in the background. And that's where it gets complicated.
Streaming audio inside a Service is a very easy task. The tough part is how to extract the audio from the video, and from this forum Youtube API is not keen on it.
The application PVStar+ does what you are looking for. But I have to figure out how they did it.



来源:https://stackoverflow.com/questions/20063630/play-audio-from-a-music-video-using-youtube-api-in-android-when-my-app-is-minim

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!