Android starts a new thread to play background music

In this example, start a new thread to play background music. After the music file is played, pause for 5 seconds and start playing again.

Specific implementation:

Interface (only one start button) RES / layout / main.xml:

Create a raw directory in the RES / folder, and place the background music file to be played in the raw / folder (the flower.mp3 file is placed here)

MainActivity:

Operation result: click the start button, the button will become unavailable and start playing background music. The interface is shown in the figure

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>