本文整理匯總了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();
}
}