找回密码
 立即注册
MediaPlayertheresourceTextView | android开发 2022-11-07 43 0star收藏 版权: . 保留作者信息 . 禁止商业使用 . 禁止修改作品
一个挺简单的Androidaudio多媒体编程实例,在源代码中:声明一个ImageButton,TextView,MediaPlayer变量,声明一个Flag作为承认音乐是否暂停的变量并默认为false,通过findViewById结构器创建TextView与ImageView对象,onCreate时创建MediaPlayer对象,将音乐以Import的方法存储在res/raw/always.mp3,在Android系统运行播放音乐的按钮,覆盖OnClick事情,在MediaPlayer获得播放资源与stop()之后,要预备Playback的状况前一定要使用MediaPlayer.prepare(),解除资源与MediaPlayer的赋值联系让资源可认为其它程序使用,再主程序暂停时解除资源与MediaPlayer的赋值联系。

(A very simple Android studio multimedia programming example, in the source code: declare an ImageButton, TextView, MediaPlayer variable, declare a Flag as a variable to acknowledge whether the music is paused and the default value is false, create TextView and ImageView objects through the findViewById constructor, create MediaPlayer objects when onCreate, store the music in res/raw/always.mp3 in the Import method, and run the button to play music in the Android system, Overwrite the OnClick event. After MediaPlayer obtains the playback resource and stop(), you must use MediaPlayer. prepare() before preparing the Playback status. Release the assignment contact between the resource and MediaPlayer so that the resource can be used by other programs. Release the assignment contact between the resource and MediaPlayer when the main program is paused.)

[下载]11505416542.rar




上一篇:animation Android动画效果实例
下一篇:Android Gsnake贪吃蛇代码