当前位置: 首页>>代码示例>>Java>>正文


Java MediaMetadata.getString方法代码示例

本文整理汇总了Java中android.media.MediaMetadata.getString方法的典型用法代码示例。如果您正苦于以下问题:Java MediaMetadata.getString方法的具体用法?Java MediaMetadata.getString怎么用?Java MediaMetadata.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.media.MediaMetadata的用法示例。


在下文中一共展示了MediaMetadata.getString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCustomAction

import android.media.MediaMetadata; //导入方法依赖的package包/类
@Override
public void onCustomAction(@NonNull String action, Bundle extras) {
    if (CUSTOM_ACTION_THUMBS_UP.equals(action)) {
        LogHelper.i(TAG, "onCustomAction: favorite for current track");
        MediaMetadata track = getCurrentPlayingMusic();
        if (track != null) {
            String musicId = track.getString(MediaMetadata.METADATA_KEY_MEDIA_ID);
            mMusicProvider.setFavorite(musicId, !mMusicProvider.isFavorite(musicId));
        }
        // playback state needs to be updated because the "Favorite" icon on the
        // custom action will change to reflect the new favorite state.
        updatePlaybackState(null);
    } else {
        LogHelper.e(TAG, "Unsupported action: ", action);
    }
}
 
开发者ID:mrinalgit-dev,项目名称:MrinalMusicPlayer,代码行数:17,代码来源:MusicService.java

示例2: setCustomAction

import android.media.MediaMetadata; //导入方法依赖的package包/类
private void setCustomAction(PlaybackState.Builder stateBuilder) {
    MediaMetadata currentMusic = getCurrentPlayingMusic();
    if (currentMusic != null) {
        // Set appropriate "Favorite" icon on Custom action:
        String musicId = currentMusic.getString(MediaMetadata.METADATA_KEY_MEDIA_ID);
        int favoriteIcon = R.drawable.ic_star_off;
        if (mMusicProvider.isFavorite(musicId)) {
            favoriteIcon = R.drawable.ic_star_on;
        }
        LogHelper.d(TAG, "updatePlaybackState, setting Favorite custom action of music ",
                musicId, " current favorite=", mMusicProvider.isFavorite(musicId));
        Bundle customActionExtras = new Bundle();
        WearHelper.setShowCustomActionOnWear(customActionExtras, true);
        stateBuilder.addCustomAction(new PlaybackState.CustomAction.Builder(
                CUSTOM_ACTION_THUMBS_UP, getString(R.string.favorite), favoriteIcon)
                .setExtras(customActionExtras)
                .build());
    }
}
 
开发者ID:mrinalgit-dev,项目名称:MrinalMusicPlayer,代码行数:20,代码来源:MusicService.java

示例3: updateMusic

import android.media.MediaMetadata; //导入方法依赖的package包/类
public synchronized void updateMusic(String musicId, MediaMetadata metadata) {
    MutableMediaMetadata track = mMusicListById.get(musicId);
    if (track == null) {
        return;
    }

    String oldGenre = track.metadata.getString(MediaMetadata.METADATA_KEY_GENRE);
    String newGenre = metadata.getString(MediaMetadata.METADATA_KEY_GENRE);

    track.metadata = metadata;

    // if genre has changed, we need to rebuild the list by genre
    if (!oldGenre.equals(newGenre)) {
        buildListsByGenre();
    }
}
 
开发者ID:mrinalgit-dev,项目名称:MrinalMusicPlayer,代码行数:17,代码来源:MusicProvider.java

示例4: onCustomAction

import android.media.MediaMetadata; //导入方法依赖的package包/类
@Override
public void onCustomAction(String action, Bundle extras) {
    if (CUSTOM_ACTION_THUMBS_UP.equals(action)) {
        LogHelper.i(TAG, "onCustomAction: favorite for current track");
        MediaMetadata track = getCurrentPlayingMusic();
        if (track != null) {
            String musicId = track.getString(MediaMetadata.METADATA_KEY_MEDIA_ID);
            mMusicProvider.setFavorite(musicId, !mMusicProvider.isFavorite(musicId));
        }
        // playback state needs to be updated because the "Favorite" icon on the
        // custom action will change to reflect the new favorite state.
        updatePlaybackState(null);
    } else {
        LogHelper.e(TAG, "Unsupported action: ", action);
    }

}
 
开发者ID:ErNaveen,项目名称:UniversalMusicPlayer,代码行数:18,代码来源:MusicService.java

示例5: onCustomAction

import android.media.MediaMetadata; //导入方法依赖的package包/类
@Override
public void onCustomAction(String action, Bundle extras) {
    if (CUSTOM_ACTION_THUMBS_UP.equals(action)) {
        LogHelper.i(TAG, "onCustomAction: favorite for current track");
        MediaMetadata track = getCurrentPlayingMusic();
        if (track != null) {
            String musicId = track.getString(MediaMetadata.METADATA_KEY_MEDIA_ID);
            mMusicProvider.setFavorite(musicId, !mMusicProvider.isFavorite(musicId));
        }
        // playback state needs to be updated because the "Favorite" icon on the
        // custom action will change to reflect the new favorite state.
        updatePlaybackState(null);
    } else {
        LogHelper.e(TAG, "Unsupported action: ", action);
    }
}
 
开发者ID:SferaDev,项目名称:MusicFromChina,代码行数:17,代码来源:MusicService.java

示例6: updateMusic

import android.media.MediaMetadata; //导入方法依赖的package包/类
public synchronized void updateMusic(String musicId, MediaMetadata metadata) {
    MutableMediaMetadata track = mMusicListById.get(musicId);
    if (track == null) {
        return;
    }

    String oldGenre = track.metadata.getString(MediaMetadata.METADATA_KEY_GENRE);
    String newGenre = metadata.getString(MediaMetadata.METADATA_KEY_GENRE);

    track.metadata = metadata;

    // if genre has changed, we need to rebuild the list by genre
    if (!oldGenre.equals(newGenre)) {
        buildListsByGenre();
    }

}
 
开发者ID:SferaDev,项目名称:MusicFromChina,代码行数:18,代码来源:MusicProvider.java

示例7: retrieveMedia

import android.media.MediaMetadata; //导入方法依赖的package包/类
private synchronized void retrieveMedia() {
    try {
        if (mCurrentState == State.NON_INITIALIZED) {
            mCurrentState = State.INITIALIZING;

            int slashPos = CATALOG_URL.lastIndexOf('/');
            String path = CATALOG_URL.substring(0, slashPos + 1);
            JSONObject jsonObj = fetchJSONFromUrl(CATALOG_URL);
            if (jsonObj == null) {
                return;
            }
            JSONArray tracks = jsonObj.getJSONArray(JSON_MUSIC);
            if (tracks != null) {
                for (int j = 0; j < tracks.length(); j++) {
                    MediaMetadata item = buildFromJSON(tracks.getJSONObject(j), path);
                    String musicId = item.getString(MediaMetadata.METADATA_KEY_MEDIA_ID);
                    mMusicListById.put(musicId, new MutableMediaMetadata(musicId, item));
                }
                buildListsByGenre();
            }
            mCurrentState = State.INITIALIZED;
        }
    } catch (JSONException e) {
        LogHelper.e(TAG, e, "Could not retrieve music list");
    } finally {
        if (mCurrentState != State.INITIALIZED) {
            // Something bad happened, so we reset state to NON_INITIALIZED to allow
            // retries (eg if the network connection is temporary unavailable)
            mCurrentState = State.NON_INITIALIZED;
        }
    }
}
 
开发者ID:mrinalgit-dev,项目名称:MrinalMusicPlayer,代码行数:33,代码来源:MusicProvider.java

示例8: setCustomAction

import android.media.MediaMetadata; //导入方法依赖的package包/类
private void setCustomAction(PlaybackState.Builder stateBuilder) {
    MediaMetadata currentMusic = getCurrentPlayingMusic();
    if (currentMusic != null) {
        // Set appropriate "Favorite" icon on Custom action:
        String musicId = currentMusic.getString(MediaMetadata.METADATA_KEY_MEDIA_ID);
        int favoriteIcon = R.drawable.ic_star_off;
        if (mMusicProvider.isFavorite(musicId)) {
            favoriteIcon = R.drawable.ic_star_on;
        }
        LogHelper.d(TAG, "updatePlaybackState, setting Favorite custom action of music ",
                musicId, " current favorite=", mMusicProvider.isFavorite(musicId));
        stateBuilder.addCustomAction(CUSTOM_ACTION_THUMBS_UP, getString(R.string.favorite),
                favoriteIcon);
    }
}
 
开发者ID:ErNaveen,项目名称:UniversalMusicPlayer,代码行数:16,代码来源:MusicService.java

示例9: retrieveMedia

import android.media.MediaMetadata; //导入方法依赖的package包/类
private synchronized void retrieveMedia() {
    try {
        if (mCurrentState == State.NON_INITIALIZED) {
            mCurrentState = State.INITIALIZING;

            JSONObject jsonObj = MusicAPI.getPlaylistDetails("60198");
            if (jsonObj == null) {
                return;
            }
            JSONArray tracks = jsonObj.getJSONArray(JSON_TRACKS);
            if (tracks != null) {
                for (int j = 0; j < 20; j++) {
                    MediaMetadata item = buildFromJSON(tracks.getJSONObject(j));
                    String musicId = item.getString(MediaMetadata.METADATA_KEY_MEDIA_ID);
                    mMusicListById.put(musicId, new MutableMediaMetadata(musicId, item));
                }
                buildListsByGenre();
            }
            mCurrentState = State.INITIALIZED;
        }
    } catch (JSONException e) {
        e.printStackTrace();
    } finally {
        if (mCurrentState != State.INITIALIZED) {
            // Something bad happened, so we reset state to NON_INITIALIZED to allow
            // retries (eg if the network connection is temporary unavailable)
            mCurrentState = State.NON_INITIALIZED;
        }
    }
}
 
开发者ID:SferaDev,项目名称:MusicFromChina,代码行数:31,代码来源:MusicProvider.java

示例10: getMediaTitle

import android.media.MediaMetadata; //导入方法依赖的package包/类
@Override
public CharSequence getMediaTitle() {
    MediaMetadata mediaMetadata = mMediaController.getMetadata();
    return mediaMetadata == null ? ""
            : mediaMetadata.getString(MediaMetadata.METADATA_KEY_TITLE);
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:7,代码来源:DvrPlaybackControlHelper.java

示例11: getMediaSubtitle

import android.media.MediaMetadata; //导入方法依赖的package包/类
@Override
public CharSequence getMediaSubtitle() {
    MediaMetadata mediaMetadata = mMediaController.getMetadata();
    return mediaMetadata == null ? ""
            : mediaMetadata.getString(MediaMetadata.METADATA_KEY_DISPLAY_SUBTITLE);
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:7,代码来源:DvrPlaybackControlHelper.java

示例12: fromMediaMetadata

import android.media.MediaMetadata; //导入方法依赖的package包/类
public static Track fromMediaMetadata(MediaMetadata metadata) {
  String title = metadata.getString(MediaMetadata.METADATA_KEY_TITLE);
  String artist = metadata.getString(MediaMetadata.METADATA_KEY_ARTIST);
  String album = metadata.getString(MediaMetadata.METADATA_KEY_ALBUM);
  String albumArtist = metadata.getString(MediaMetadata.METADATA_KEY_ALBUM_ARTIST);
  Bitmap art = metadata.getBitmap(MediaMetadata.METADATA_KEY_ART);
  long duration = metadata.getLong(MediaMetadata.METADATA_KEY_DURATION);

  if (title == null) {
    title = metadata.getString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE);

    if (title == null) {
      title = "";
    }
  }

  if (art == null) {
    art = metadata.getBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART);
  }

  Track.Builder builder = Track.builder().track(title);

  if (duration < 1000) {
    // Apple Music incorrectly reports durations in seconds instead of ms (when it reports
    // duration at all).
    duration *= 1000;
  }

  if (duration > 0) {
    builder.duration(duration);
  }
  if (album != null && !album.isEmpty()) {
    builder.album(album);
  }
  if (albumArtist != null && !albumArtist.isEmpty()) {
    builder.albumArtist(albumArtist);
  }
  if (art != null) {
    builder.art(art);
  }
  if (artist != null) {
    builder.artist(artist);
  } else if (albumArtist != null) {
    // Some apps (Telegram) set ALBUM_ARTIST but not ARTIST.
    builder.artist(albumArtist);
  } else {
    return new TitleExtractor().transform(builder.artist("").build());
  }
  return builder.build();
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:51,代码来源:Track.java

示例13: play

import android.media.MediaMetadata; //导入方法依赖的package包/类
@Override
public void play(QueueItem item) {
    mPlayOnFocusGain = true;
    tryToGetAudioFocus();
    registerAudioNoisyReceiver();
    String mediaId = item.getDescription().getMediaId();
    boolean mediaHasChanged = !TextUtils.equals(mediaId, mCurrentMediaId);
    if (mediaHasChanged) {
        mCurrentPosition = 0;
        mCurrentMediaId = mediaId;
    }

    if (mState == PlaybackState.STATE_PAUSED && !mediaHasChanged && mMediaPlayer != null) {
        configMediaPlayerState();
    } else {
        mState = PlaybackState.STATE_STOPPED;
        relaxResources(false); // release everything except MediaPlayer
        MediaMetadata track = mMusicProvider.getMusic(
                MediaIDHelper.extractMusicIDFromMediaID(item.getDescription().getMediaId()));

        String source = track.getString(MusicProvider.CUSTOM_METADATA_TRACK_SOURCE);

        try {
            createMediaPlayerIfNeeded();

            mState = PlaybackState.STATE_BUFFERING;

            mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
            mMediaPlayer.setDataSource(source);

            // Starts preparing the media player in the background. When
            // it's done, it will call our OnPreparedListener (that is,
            // the onPrepared() method on this class, since we set the
            // listener to 'this'). Until the media player is prepared,
            // we *cannot* call start() on it!
            mMediaPlayer.prepareAsync();

            // If we are streaming from the internet, we want to hold a
            // Wifi lock, which prevents the Wifi radio from going to
            // sleep while the song is playing.
            mWifiLock.acquire();

            if (mCallback != null) {
                mCallback.onPlaybackStatusChanged(mState);
            }

        } catch (IOException ex) {
            LogHelper.e(TAG, ex, "Exception playing song");
            if (mCallback != null) {
                mCallback.onError(ex.getMessage());
            }
        }
    }
}
 
开发者ID:mrinalgit-dev,项目名称:MrinalMusicPlayer,代码行数:55,代码来源:LocalPlayback.java


注:本文中的android.media.MediaMetadata.getString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。