MediaPlayer.reset()有什么用啊?什么时候用?

ameyume
博客专家认证
2010-07-26 12:09:22
如题,我做了一个小播放器来播放音频,在play之前执行reset()后再执行start(),播放不了。
但是先执行stop(),再执行start()就可以播放。

还有一个问题,按照上面的先执行stop(),再执行start()播放完一遍后,再次点击播放,则不能再播放。这是为什么呢?
...全文
1487 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 smallhero007 的回复:]
源码中这样告诉我们:
Resets the MediaPlayer to its uninitialized state. After calling this method, you will have to initialize it again by setting the data source and calling prepare().
也就是说当你调用reset以后你的media……
[/Quote]
应该是正解!
SmallHero007 2010-07-27
  • 打赏
  • 举报
回复
源码中这样告诉我们:
Resets the MediaPlayer to its uninitialized state. After calling this method, you will have to initialize it again by setting the data source and calling prepare().
也就是说当你调用reset以后你的mediaplayer这个类就得重新实例化一次。
代码片段如下

mediaPlayer = MediaPlayer.create(MediaPlayerTest.this,
R.raw.abc);
try {
mediaPlayer.prepare();
} catch (IllegalStateException e) {
e.printStackTrace();

} catch (IOException e) {
e.printStackTrace();

}

ameyume 2010-07-27
  • 打赏
  • 举报
回复
多谢各位!要看SDK才行!
vclongking 2010-07-27
  • 打赏
  • 举报
回复
就风行天下说的那几个状态 , LZ好好看一下SDK里面对应的DOC , 都说的很详细哈。
ghfseawindy 2010-07-26
  • 打赏
  • 举报
回复
http://cnmsdn.com/html/201005/1275060545ID5305.html 看下这个吧 讲的挺详细的
ameyume 2010-07-26
  • 打赏
  • 举报
回复
自己up
yihua0001 2010-07-26
  • 打赏
  • 举报
回复
主要是几个状态切换要正确,学习一下。
karlzheng 2010-07-26
  • 打赏
  • 举报
回复
http://zhg-grj.spaces.live.com/blog/cns!ADA1FB08E190EBF4!374.entry

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧