using android mediaPlayer object for multiple dataSources, use of release();

谁都会走 提交于 2019-12-11 02:26:40

问题


I have several raw sound files that I want to play using the MediaPlayer class in the android API, before I change the data source to a different file do I have to call release(); The documentation says that the release(); method will end the MediaPlayer object, I am using the same MediaPlayer object to switch between the different raw files so will that interfere, or do I just call release after the program ends


回答1:


Call reset() first. It resets the MediaPlayer to its uninitialized state. Then you will have to initialize it again by setting the data source and calling prepare(). Call release() once you are done with the MediaPlayer instance.



来源:https://stackoverflow.com/questions/20536036/using-android-mediaplayer-object-for-multiple-datasources-use-of-release

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