简体   繁体   中英

How set duration of the ringtone's play

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM