How set duration of the ringtone's play

半城伤御伤魂 提交于 2019-12-12 04:37:21

问题


My app play ringtone. My code:

RingtoneManager.getRingtone( context, RingtoneManager.getDefaultUri( RingtoneManager.TYPE_NOTIFICATION)).play();

Ringtone play very well. But if ringtone is long I need cut the first N milliseconds from it.

  1. How get full duration of this ringtone?
  2. How set maximum duration in milliseconds of this ringtone?

回答1:


Just put the RingTone in mediaPlayer for eg

Mediaplayer mp =new MediaPlayer();
uri = RingtoneManager.getDefaultUri( RingtoneManager.TYPE_NOTIFICATION))
mp.setDataSoure(getApplicationContext(), uri);
mp.prepare();
mp.getDuration()

Use the mp.getDuration and do whatever u want. Enjoy



来源:https://stackoverflow.com/questions/25460283/how-set-duration-of-the-ringtones-play

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