本文整理汇总了Java中android.media.Ringtone.isPlaying方法的典型用法代码示例。如果您正苦于以下问题:Java Ringtone.isPlaying方法的具体用法?Java Ringtone.isPlaying怎么用?Java Ringtone.isPlaying使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.Ringtone
的用法示例。
在下文中一共展示了Ringtone.isPlaying方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beep
import android.media.Ringtone; //导入方法依赖的package包/类
/**
* Beep plays the default notification ringtone.
*
* @param count Number of times to play notification
*/
public void beep(long count) {
Uri ringtone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone notification = RingtoneManager.getRingtone(this.cordova.getActivity().getBaseContext(), ringtone);
// If phone is not set to silent mode
if (notification != null) {
for (long i = 0; i < count; ++i) {
notification.play();
long timeout = 5000;
while (notification.isPlaying() && (timeout > 0)) {
timeout = timeout - 100;
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
}
}
}
示例2: beep
import android.media.Ringtone; //导入方法依赖的package包/类
public void beep(long paramLong)
{
Uri localUri = RingtoneManager.getDefaultUri(2);
Ringtone localRingtone = RingtoneManager.getRingtone(this.cordova.getActivity().getBaseContext(), localUri);
if (localRingtone != null)
{
long l1 = 0L;
while (l1 < paramLong)
{
localRingtone.play();
long l2 = 5000L;
while ((localRingtone.isPlaying()) && (l2 > 0L))
{
l2 -= 100L;
try
{
Thread.sleep(100L);
}
catch (InterruptedException localInterruptedException)
{
}
}
l1 += 1L;
}
}
}
示例3: playNotificationSound
import android.media.Ringtone; //导入方法依赖的package包/类
private static void playNotificationSound( Context context ) {
if( !isSoundEnabled( context ) ) {
return;
}
Uri uri = getRingtone( context );
if( uri == null ) {
uri = RingtoneManager.getDefaultUri( RingtoneManager.TYPE_NOTIFICATION );
}
Ringtone ringtone = RingtoneManager.getRingtone( context.getApplicationContext(), uri );
if( ringtone != null && !ringtone.isPlaying() ) {
ringtone.play();
}
}
示例4: beep
import android.media.Ringtone; //导入方法依赖的package包/类
/**
* 设备播放默认蜂鸣声.
*
* @param count
* 播放 notification 的次数
*/
public void beep(final long count) {
Uri ringtoneUri = RingtoneManager
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone ringtone = RingtoneManager.getRingtone(mCordova.getActivity(), ringtoneUri);
// 如果设备设置成静音状态,则返回
if (ringtone == null) {
return;
}
for (long i = 0; i < count; ++i) {
ringtone.play();
// timeout是一个经验值,有可能beep的声音超时5s,则需要调用stop来停止播放
long timeout = 5000;
while (ringtone.isPlaying() && (timeout > 0)) {
timeout -= 100;
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
/**
* 在Android2.1上调用ringtone.play后会一直循环播放,所以在超时过后需要stop
* 同时,在Android2.2及其以上版本,有可能notification beep的播放时间超过5s,
* 也需要调用stop接口来结束播放
*/
ringtone.stop();
}
}
示例5: beep
import android.media.Ringtone; //导入方法依赖的package包/类
/**
* 设备播放默认蜂鸣声.
*
* @param count
* 播放 notification 的次数
*/
public void beep(final long count) {
Uri ringtoneUri = RingtoneManager
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone ringtone = RingtoneManager.getRingtone(mSystemContext.getContext(), ringtoneUri);
// 如果设备设置成静音状态,则返回
if (ringtone == null) {
return;
}
for (long i = 0; i < count; ++i) {
ringtone.play();
// timeout是一个经验值,有可能beep的声音超时5s,则需要调用stop来停止播放
long timeout = 5000;
while (ringtone.isPlaying() && (timeout > 0)) {
timeout -= 100;
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
/**
* 在Android2.1上调用ringtone.play后会一直循环播放,所以在超时过后需要stop
* 同时,在Android2.2及其以上版本,有可能notification beep的播放时间超过5s,
* 也需要调用stop接口来结束播放
*/
ringtone.stop();
}
}