的铃声的发挥如何设定时间 [英] How set duration of the ringtone's play

查看:224
本文介绍了的铃声的发挥如何设定时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序播放铃声。我的code:

  RingtoneManager.getRingtone(背景下,RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))播放();

铃声很好的发挥。但是,如果铃声是多久,我需要从中切头n毫秒。


  1. 如何得到这个铃声的充分时间?

  2. 如何设置最长持续时间在这个铃声毫秒?


解决方案

只要把媒体播放器的手机铃声
对于如

 媒体播放器MP =新的MediaPlayer();
URI = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
mp.setDataSoure(getApplicationContext(),URI);
MP prepare()。
mp.getDuration()

使用的mp.getDuration,做任何ü希望。
享受

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

这篇关于的铃声的发挥如何设定时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆