當前位置: 首頁>>代碼示例>>Java>>正文


Java RemoteControlClient.PLAYSTATE_PLAYING屬性代碼示例

本文整理匯總了Java中android.media.RemoteControlClient.PLAYSTATE_PLAYING屬性的典型用法代碼示例。如果您正苦於以下問題:Java RemoteControlClient.PLAYSTATE_PLAYING屬性的具體用法?Java RemoteControlClient.PLAYSTATE_PLAYING怎麽用?Java RemoteControlClient.PLAYSTATE_PLAYING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.media.RemoteControlClient的用法示例。


在下文中一共展示了RemoteControlClient.PLAYSTATE_PLAYING屬性的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: playbackStateUpdate

private void playbackStateUpdate(int state) {
    boolean active;
    switch (state) {
        case RemoteControlClient.PLAYSTATE_PLAYING:
            active = true;
            break;
        case RemoteControlClient.PLAYSTATE_ERROR:
        case RemoteControlClient.PLAYSTATE_PAUSED:
        default:
            active = false;
            break;
    }
    if (active != mActive) {
        mActive = active;
        refreshState();
        if (DEBUG) log(getKey() + ": playbackStateUpdate("+state+")");
    }
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:18,代碼來源:MusicTile.java

示例2: getStateFromPlayState

static int getStateFromPlayState(PlayState playState) {
    switch (playState) {
        case BUFFERING:
            return RemoteControlClient.PLAYSTATE_BUFFERING;
        case ERROR:
            return RemoteControlClient.PLAYSTATE_ERROR;
        case FAST_FORWARDING:
            return RemoteControlClient.PLAYSTATE_FAST_FORWARDING;
        case PAUSED:
            return RemoteControlClient.PLAYSTATE_PAUSED;
        case PLAYING:
            return RemoteControlClient.PLAYSTATE_PLAYING;
        case REWINDING:
            return RemoteControlClient.PLAYSTATE_REWINDING;
        case SKIPPING_BACKWARDS:
            return RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS;
        case SKIPPING_FORWARDS:
            return RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS;
        case STOPPED:
            return RemoteControlClient.PLAYSTATE_STOPPED;
        default:
            return RemoteControlClient.PLAYSTATE_ERROR;
    }
}
 
開發者ID:Tombarr,項目名稱:Noyze,代碼行數:24,代碼來源:MediaProviderDelegate.java

示例3: wasPlayingRecently

public boolean wasPlayingRecently() {
    switch (mState) {
        case RemoteControlClient.PLAYSTATE_PLAYING:
        case RemoteControlClient.PLAYSTATE_FAST_FORWARDING:
        case RemoteControlClient.PLAYSTATE_REWINDING:
        case RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS:
        case RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS:
        case RemoteControlClient.PLAYSTATE_BUFFERING:
            // actively playing or about to play
            return true;
        case RemoteControlClient.PLAYSTATE_STOPPED:
        case RemoteControlClient.PLAYSTATE_PAUSED:
        case RemoteControlClient.PLAYSTATE_ERROR:
            return ((SystemClock.elapsedRealtime() - mStateChangeTimeMs) < DISPLAY_TIMEOUT_MS);
        default:
            LOGE("PlaybackInfo", "Unknown playback state " + mState + " in wasPlayingRecently()");
            return false;
    }
}
 
開發者ID:Tombarr,項目名稱:Noyze,代碼行數:19,代碼來源:PlaybackInfo.java

示例4: updateRemoteControlClient

@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void updateRemoteControlClient(final String what) {
    //Legacy for ICS
    if (mRemoteControlClient != null) {
        int playState = mIsSupposedToBePlaying
                ? RemoteControlClient.PLAYSTATE_PLAYING
                : RemoteControlClient.PLAYSTATE_PAUSED;
        if (what.equals(META_CHANGED) || what.equals(QUEUE_CHANGED)) {
            Bitmap albumArt = null;
            if (mShowAlbumArtOnLockscreen) {
                albumArt = ImageLoader.getInstance().loadImageSync(TimberUtils.getAlbumArtUri(getAlbumId()).toString());
                if (albumArt != null) {

                    Bitmap.Config config = albumArt.getConfig();
                    if (config == null) {
                        config = Bitmap.Config.ARGB_8888;
                    }
                    albumArt = albumArt.copy(config, false);
                }
            }

            RemoteControlClient.MetadataEditor editor = mRemoteControlClient.editMetadata(true);
            editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, getAlbumName());
            editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, getArtistName());
            editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, getTrackName());
            editor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, duration());
            editor.putBitmap(MediaMetadataEditor.BITMAP_KEY_ARTWORK, albumArt);
            editor.apply();

        }
        mRemoteControlClient.setPlaybackState(playState);
    }
}
 
開發者ID:Vinetos,項目名稱:Hello-Music-droid,代碼行數:34,代碼來源:MusicService.java

示例5: isRemoteControlPlaying

public static boolean isRemoteControlPlaying(final int state) {
    switch (state) {
        case RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS:
        case RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS:
        case RemoteControlClient.PLAYSTATE_BUFFERING:
        case RemoteControlClient.PLAYSTATE_FAST_FORWARDING:
        case RemoteControlClient.PLAYSTATE_PLAYING:
        case RemoteControlClient.PLAYSTATE_REWINDING:
            return true;
    }

    return false;
}
 
開發者ID:Tombarr,項目名稱:Noyze,代碼行數:13,代碼來源:Constants.java

示例6: gainFocus

void gainFocus() {
    if (!mFocused) {
        mFocused = true;
        mAudioManager.registerMediaButtonEventReceiver(mPendingIntent);
        mAudioManager.registerRemoteControlClient(mRemoteControl);
        if (mPlayState == RemoteControlClient.PLAYSTATE_PLAYING) {
            takeAudioFocus();
        }
    }
}
 
開發者ID:bestarandyan,項目名稱:ShoppingMall,代碼行數:10,代碼來源:TransportMediatorJellybeanMR2.java

示例7: startPlaying

public void startPlaying() {
    if (mPlayState != RemoteControlClient.PLAYSTATE_PLAYING) {
        mPlayState = RemoteControlClient.PLAYSTATE_PLAYING;
        mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
    }
    if (mFocused) {
        takeAudioFocus();
    }
}
 
開發者ID:bestarandyan,項目名稱:ShoppingMall,代碼行數:9,代碼來源:TransportMediatorJellybeanMR2.java

示例8: pausePlaying

public void pausePlaying() {
    if (mPlayState == RemoteControlClient.PLAYSTATE_PLAYING) {
        mPlayState = RemoteControlClient.PLAYSTATE_PAUSED;
        mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
    }
    dropAudioFocus();
}
 
開發者ID:bestarandyan,項目名稱:ShoppingMall,代碼行數:7,代碼來源:TransportMediatorJellybeanMR2.java

示例9: setPlaybackState

@Override
public void setPlaybackState(final int state, int index, int queueSize) {
	if(mRemoteControl == null) {
		return;
	}

	long position = -1;
	if(state == RemoteControlClient.PLAYSTATE_PLAYING || state == RemoteControlClient.PLAYSTATE_PAUSED) {
		position = downloadService.getPlayerPosition();
	}
	mRemoteControl.setPlaybackState(state, position, 1.0f);
}
 
開發者ID:popeen,項目名稱:Popeens-DSub,代碼行數:12,代碼來源:RemoteControlClientJB.java

示例10: setPlaybackState

@Override
public void setPlaybackState(final int state) {
	long position = -1;
	if(state == RemoteControlClient.PLAYSTATE_PLAYING || state == RemoteControlClient.PLAYSTATE_PAUSED) {
		position = downloadService.getPlayerPosition();
	}
	mRemoteControl.setPlaybackState(state, position, 1.0f);
}
 
開發者ID:MadMarty,項目名稱:madsonic-5.5,代碼行數:8,代碼來源:RemoteControlClientJB.java

示例11: updateMeta

@Override
void updateMeta(String what) {
    int playState = mService.isPlaying()
            ? RemoteControlClient.PLAYSTATE_PLAYING
            : RemoteControlClient.PLAYSTATE_PAUSED;

    if (what.equals(PLAYSTATE_CHANGED) || what.equals(POSITION_CHANGED)) {
        setPlaybackState(playState);
    } else if (what.equals(META_CHANGED)) {
        Bitmap albumArt;
        if (VersionUtils.hasKitkat()) {
            //Kitkat has fullscreen artwork
            albumArt = mService.getAlbumArt();
        } else {
            albumArt = mService.getAlbumArtThumbnail();
        }
        if (albumArt != null) {
            // RemoteControlClient wants to recycle the bitmaps thrown at it, so we need
            // to make sure not to hand out our cache copy
            Bitmap.Config config = albumArt.getConfig();
            if (config == null) {
                config = Bitmap.Config.ARGB_8888;
            }
            albumArt = albumArt.copy(config, false);
        }

        mRemoteControlClient
                .editMetadata(true)
                .putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, mService.getArtistName())
                .putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST,
                        !TextUtils.isEmpty(mService.getAlbumArtistName()) ? mService.getAlbumArtistName() : mService.getArtistName())
                .putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, mService.getAlbumName())
                .putString(MediaMetadataRetriever.METADATA_KEY_TITLE, mService.getTrackName())
                .putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, mService.duration())
                .putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, albumArt)
                .apply();

        setPlaybackState(playState);
    }
}
 
開發者ID:OpenSilk,項目名稱:Orpheus,代碼行數:40,代碼來源:MediaSessionHelper.java

示例12: setPlaybackState

@Override
public void setPlaybackState(int state, int index, int queueSize) {
	PlaybackState.Builder builder = new PlaybackState.Builder();

	int newState = PlaybackState.STATE_NONE;
	switch(state) {
		case RemoteControlClient.PLAYSTATE_PLAYING:
			newState = PlaybackState.STATE_PLAYING;
			break;
		case RemoteControlClient.PLAYSTATE_STOPPED:
			newState = PlaybackState.STATE_STOPPED;
			break;
		case RemoteControlClient.PLAYSTATE_PAUSED:
			newState = PlaybackState.STATE_PAUSED;
			break;
		case RemoteControlClient.PLAYSTATE_BUFFERING:
			newState = PlaybackState.STATE_BUFFERING;
			break;
	}

	long position = -1;
	if(state == RemoteControlClient.PLAYSTATE_PLAYING || state == RemoteControlClient.PLAYSTATE_PAUSED) {
		position = downloadService.getPlayerPosition();
	}
	builder.setState(newState, position, 1.0f);
	DownloadFile downloadFile = downloadService.getCurrentPlaying();
	Entry entry = null;
	boolean isSong = true;
	if(downloadFile != null) {
		entry = downloadFile.getSong();
		isSong = entry.isSong();
	}

	builder.setActions(getPlaybackActions(isSong, index, queueSize));

	if(entry != null) {
		addCustomActions(entry, builder);
		builder.setActiveQueueItemId(entry.getId().hashCode());
	}

	PlaybackState playbackState = builder.build();
	mediaSession.setPlaybackState(playbackState);
	previousState = state;
}
 
開發者ID:popeen,項目名稱:Popeens-DSub,代碼行數:44,代碼來源:RemoteControlClientLP.java

示例13: onClientPlaybackStateUpdate

@Override
public void onClientPlaybackStateUpdate(int state, long stateChangeTimeMs, long currentPosMs, float speed) {
    this.isRemoteControllerPlaying = state == RemoteControlClient.PLAYSTATE_PLAYING;
    mHasBug = false;
    if (currentPosMs > 3600000)
        currentPosMs = -1L;
    SharedPreferences current = getSharedPreferences("current_music", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = current.edit();
    editor.putLong("position", currentPosMs);

    if (isRemoteControllerPlaying) {
        long currentTime = System.currentTimeMillis();
        editor.putLong("startTime", currentTime);
    } else {
        NotificationManager notificationManager =
                ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE));
        notificationManager.cancel(NOTIFICATION_ID);
        notificationManager.cancel(8);
    }
    editor.putBoolean("playing", isRemoteControllerPlaying);
    editor.apply();

    if (App.isMainActivityVisible() && isRemoteControllerPlaying) {
        Intent internalIntent = new Intent(LyricsViewFragment.UPDATE_LYRICS_ACTION);
        internalIntent
                .putExtra("artist", current.getString("artist", ""))
                .putExtra("track", current.getString("track", ""));
        LyricsViewFragment.sendIntent(NotificationListenerService.this, internalIntent);
    }
    Log.d("geecko", "PlaybackStateUpdate - position stored: " + currentPosMs);

    long position = getRemotePlayerPosition();

    if (durationObject instanceof Double) {
        if (artist != null && !artist.isEmpty())
            mediaControllerCallback.broadcast(this, artist, track, isRemoteControllerPlaying, (Double) durationObject, position, null);
    } else if (durationObject instanceof Integer) {
        if (artist != null && !artist.isEmpty())
            mediaControllerCallback.broadcast(this, artist, track, isRemoteControllerPlaying, (Integer) durationObject, position, null);
    } else if (durationObject instanceof Long)
        if (artist != null && !artist.isEmpty())
            mediaControllerCallback.broadcast(this, artist, track, isRemoteControllerPlaying, (Long) durationObject, position, null);
}
 
開發者ID:QuickLyric,項目名稱:QuickLyric,代碼行數:43,代碼來源:NotificationListenerService.java


注:本文中的android.media.RemoteControlClient.PLAYSTATE_PLAYING屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。