本文整理汇总了Java中com.google.android.gms.cast.MediaTrack类的典型用法代码示例。如果您正苦于以下问题:Java MediaTrack类的具体用法?Java MediaTrack怎么用?Java MediaTrack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MediaTrack类属于com.google.android.gms.cast包,在下文中一共展示了MediaTrack类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onAudioMetadataUpdated
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
@Override
public void onAudioMetadataUpdated(VideoMetadata vMetadata, int currentAudio) {
if (PlayerService.sPlayerService.getVideoInfo() == null) {
// mNewSubtitleTrack = newSubtitleTrack;
// mAudioSubtitleNeedUpdate = true;
return;
}
int nbTrack = vMetadata.getAudioTrackNb();
ArchosVideoCastManager.getInstance().clearAudioTracks();
int noneTrack = nbTrack+1;
if (nbTrack != 0) {
for (int i = 0; i < nbTrack; ++i) {
VideoMetadata.AudioTrack audio = vMetadata.getAudioTrack(i);
CharSequence summary = VideoUtils.getLanguageString(this, audio.format);
ArchosVideoCastManager.getInstance().getMediaInfo().getMediaTracks().add(new MediaTrack.Builder(ArchosVideoCastManager.getInstance().getMediaInfo().getMediaTracks().size(), MediaTrack.TYPE_AUDIO).setContentId(""+i).setName((String) VideoUtils.getLanguageString(this, audio.name)+" ("+summary+")").build());
}
nbTrack++;
}
ArchosVideoCastManager.getInstance().onRemoteMediaPlayerMetadataUpdated();
}
开发者ID:archos-sa,项目名称:aos-Video,代码行数:26,代码来源:CastPlayerService.java
示例2: setActiveTracks
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
/**
* Sets the active tracks and their styles.
*/
public void setActiveTracks(List<MediaTrack> tracks) {
long[] tracksArray;
if (tracks.isEmpty()) {
tracksArray = new long[]{};
} else {
tracksArray = new long[tracks.size()];
for (int i = 0; i < tracks.size(); i++) {
tracksArray[i] = tracks.get(i).getId();
}
}
setActiveTrackIds(tracksArray);
if (tracks.size() > 0) {
setTextTrackStyle(getTracksPreferenceManager().getTextTrackStyle());
}
}
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:19,代码来源:VideoCastManager.java
示例3: buildTrack
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
private static MediaTrack buildTrack(long id, String type, String subType, String contentId,
String name, String language) {
int trackType = MediaTrack.TYPE_UNKNOWN;
if ("text".equals(type)) {
trackType = MediaTrack.TYPE_TEXT;
} else if ("video".equals(type)) {
trackType = MediaTrack.TYPE_VIDEO;
} else if ("audio".equals(type)) {
trackType = MediaTrack.TYPE_AUDIO;
}
int trackSubType = MediaTrack.SUBTYPE_NONE;
if (subType != null) {
if ("captions".equals(type)) {
trackSubType = MediaTrack.SUBTYPE_CAPTIONS;
} else if ("subtitle".equals(type)) {
trackSubType = MediaTrack.SUBTYPE_SUBTITLES;
}
}
return new MediaTrack.Builder(id, trackType)
.setName(name)
.setSubtype(trackSubType)
.setContentId(contentId)
.setLanguage(language).build();
}
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:27,代码来源:VideoProvider.java
示例4: buildTrack
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
private static MediaTrack buildTrack(long id, String type, String subType, String contentId,
String name, String language) {
int trackType = MediaTrack.TYPE_UNKNOWN;
if ("text".equals(type)) {
trackType = MediaTrack.TYPE_TEXT;
} else if ("video".equals(type)) {
trackType = MediaTrack.TYPE_VIDEO;
} else if ("audio".equals(type)) {
trackType = MediaTrack.TYPE_AUDIO;
}
int trackSubType = MediaTrack.SUBTYPE_NONE;
if (subType != null) {
if ("captions".equals(type)) {
trackSubType = MediaTrack.SUBTYPE_CAPTIONS;
} else if ("subtitle".equals(type)) {
trackSubType = MediaTrack.SUBTYPE_SUBTITLES;
}
}
return new MediaTrack.Builder(id, trackType)
.setName(name)
.setSubtype(trackSubType)
.setContentId(contentId)
.setLanguage(language).build();
}
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:27,代码来源:CastVideoProvider.java
示例5: testPlayMediaWithSubtitles
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
@Test
public void testPlayMediaWithSubtitles() throws CastService.CastClientException {
String mediaUrl = "http://media/";
String mediaType = "video/mp4";
String subtitleUrl = "http://subtitle";
MediaInfo mediaInfo = new MediaInfo.Builder(mediaUrl, mediaType)
.setSubtitleInfo(new SubtitleInfo.Builder(subtitleUrl).build())
.build();
com.google.android.gms.cast.MediaInfo media = verifyPlayMedia(mediaInfo);
MediaTrack track = media.getMediaTracks().get(0);
Assert.assertEquals(mediaUrl, media.getContentId());
Assert.assertEquals(mediaType, media.getContentType());
Assert.assertEquals(subtitleUrl, track.getContentId());
Assert.assertNull(track.getContentType());
}
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:19,代码来源:CastServiceTest.java
示例6: buildMediaInfo
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
private static MediaInfo buildMediaInfo(String title, String studio, String subTitle,
int duration, String url, String mimeType, String imgUrl, String bigImageUrl,
List<MediaTrack> tracks) {
MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);
movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, studio);
movieMetadata.putString(MediaMetadata.KEY_TITLE, title);
movieMetadata.addImage(new WebImage(Uri.parse(imgUrl)));
movieMetadata.addImage(new WebImage(Uri.parse(bigImageUrl)));
JSONObject jsonObj = null;
try {
jsonObj = new JSONObject();
jsonObj.put(KEY_DESCRIPTION, subTitle);
} catch (JSONException e) {
Log.e(TAG, "Failed to add description to the json object", e);
}
return new MediaInfo.Builder(url)
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setContentType(mimeType)
.setMetadata(movieMetadata)
.setMediaTracks(tracks)
.setStreamDuration(duration * 1000)
.setCustomData(jsonObj)
.build();
}
开发者ID:googlecast,项目名称:CastVideos-android,代码行数:27,代码来源:VideoProvider.java
示例7: buildTrack
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
private static MediaTrack buildTrack(long id, String type, String subType, String contentId,
String name, String language) {
int trackType = MediaTrack.TYPE_UNKNOWN;
if ("text".equals(type)) {
trackType = MediaTrack.TYPE_TEXT;
} else if ("video".equals(type)) {
trackType = MediaTrack.TYPE_VIDEO;
} else if ("audio".equals(type)) {
trackType = MediaTrack.TYPE_AUDIO;
}
int trackSubType = MediaTrack.SUBTYPE_NONE;
if (subType != null) {
if ("captions".equals(type)) {
trackSubType = MediaTrack.SUBTYPE_CAPTIONS;
} else if ("subtitle".equals(type)) {
trackSubType = MediaTrack.SUBTYPE_SUBTITLES;
}
}
return new MediaTrack.Builder(id, trackType)
.setName(name)
.setSubtype(trackSubType)
.setContentId(contentId)
.setLanguage(language).build();
}
开发者ID:googlecast,项目名称:CastVideos-android,代码行数:27,代码来源:VideoProvider.java
示例8: buildMediaInfo
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
private static MediaInfo buildMediaInfo(String title, String subTitle, String studio,
String url, String imgUrl, String bigImageUrl, List<MediaTrack> tracks) {
MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);
movieMetadata.putString(MediaMetadata.KEY_SUBTITLE, subTitle);
movieMetadata.putString(MediaMetadata.KEY_TITLE, title);
movieMetadata.putString(MediaMetadata.KEY_STUDIO, studio);
movieMetadata.addImage(new WebImage(Uri.parse(imgUrl)));
movieMetadata.addImage(new WebImage(Uri.parse(bigImageUrl)));
return new MediaInfo.Builder(url)
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setContentType(getMediaType())
.setMetadata(movieMetadata)
.setMediaTracks(tracks)
.build();
}
开发者ID:BruGTUG,项目名称:codelab-chromecast,代码行数:18,代码来源:VideoProvider.java
示例9: onTracksSelected
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
@Override
public void onTracksSelected(List<MediaTrack> tracks) {
long[] tracksArray;
if (tracks.size() == 0) {
tracksArray = new long[]{};
} else {
tracksArray = new long[tracks.size()];
for (int i = 0; i < tracks.size(); i++) {
tracksArray[i] = tracks.get(i).getId();
}
}
mCastManager.setActiveTrackIds(tracksArray);
if (tracks.size() > 0) {
mCastManager.setTextTrackStyle(mCastManager.getTracksPreferenceManager()
.getTextTrackStyle());
}
}
开发者ID:BruGTUG,项目名称:codelab-chromecast,代码行数:18,代码来源:VideoCastControllerFragment.java
示例10: onCreate
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
Bundle mediaWrapper = getArguments().getBundle(VideoCastManager.EXTRA_MEDIA);
mMediaInfo = Utils.bundleToMediaInfo(mediaWrapper);
mCastManager = VideoCastManager.getInstance();
mArchosCastManager = ArchosVideoCastManager.getInstance();
mActiveTracks = mArchosCastManager.getSelectedTracks();
List<MediaTrack> allTracks = mMediaInfo.getMediaTracks();
if (allTracks == null || allTracks.isEmpty()) {
Utils.showToast(getActivity(), R.string.ccl_caption_no_tracks_available);
dismiss();
}
}
开发者ID:archos-sa,项目名称:aos-Video,代码行数:16,代码来源:ArchosTracksChooserDialog.java
示例11: onTrackSelectionChanged
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
@Override
public void onTrackSelectionChanged() {
List<MediaTrack> selectedTracks = new ArrayList<>();
MediaTrack textTrack = mTextAdapter.getSelectedTrack();
if (textTrack.getId() != TEXT_TRACK_NONE_ID) {
selectedTracks.add(textTrack);
}
MediaTrack audioVideoTrack = mAudioVideoAdapter.getSelectedTrack();
if (audioVideoTrack != null) {
selectedTracks.add(audioVideoTrack);
}
mCastManager.notifyTracksSelectedListeners(selectedTracks);
}
开发者ID:archos-sa,项目名称:aos-Video,代码行数:14,代码来源:ArchosTracksChooserDialog.java
示例12: reloadSubs
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
public void reloadSubs(){
if(mStreamServer!=null) {
if(mReloadSubsTask!=null)
mReloadSubsTask.cancel(true);
mReloadSubsTask = new AsyncTask<Object,Void, List<MediaTrack> >() {
protected void onPostExecute(List<MediaTrack> tracks) {
if (tracks != null) {
try {
int initialSize = ArchosVideoCastManager.getInstance().getRemoteMediaInformation().getMediaTracks().size();
long resume = ArchosVideoCastManager.getInstance().getCurrentMediaPosition();
if(initialSize!=tracks.size()) {
ArchosVideoCastManager.getInstance().getRemoteMediaInformation().getMediaTracks().clear();
ArchosVideoCastManager.getInstance().getRemoteMediaInformation().getMediaTracks().addAll(tracks);
VideoCastManager.getInstance().loadMedia(ArchosVideoCastManager.getInstance().getRemoteMediaInformation(), true, (int)resume);
}
} catch (TransientNetworkDisconnectionException e) {
e.printStackTrace();
} catch (NoConnectionException e) {
e.printStackTrace();
}
}
}
@Override
protected List<MediaTrack> doInBackground(Object... objects) {
String ipAddress = SambaDiscovery.getLocalIpAddress();
if(ipAddress==null)
return null;
List<MediaTrack> tracks = prepareSubs(streamingUri, mStreamServer,ipAddress);
return tracks;
}
};
mReloadSubsTask.execute();
}
}
开发者ID:archos-sa,项目名称:aos-Video,代码行数:38,代码来源:CastService.java
示例13: clearSubtitleTracks
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
public void clearSubtitleTracks() {
List<MediaTrack> mediaTracks = new ArrayList<>(mMediaInfo.getMediaTracks());
for(MediaTrack mediaTrack : mediaTracks){
if(mediaTrack.getType()==MediaTrack.TYPE_TEXT){
mMediaInfo.getMediaTracks().remove(mediaTrack);
}
}
}
开发者ID:archos-sa,项目名称:aos-Video,代码行数:9,代码来源:ArchosVideoCastManager.java
示例14: clearAudioTracks
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
public void clearAudioTracks() {
List<MediaTrack> mediaTracks = new ArrayList<>(mMediaInfo.getMediaTracks());
for(MediaTrack mediaTrack : mediaTracks){
if(mediaTrack.getType()==MediaTrack.TYPE_AUDIO){
mMediaInfo.getMediaTracks().remove(mediaTrack);
}
}
}
开发者ID:archos-sa,项目名称:aos-Video,代码行数:9,代码来源:ArchosVideoCastManager.java
示例15: updateClosedCaptionState
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
private void updateClosedCaptionState() {
int state = VideoCastController.CC_HIDDEN;
if (mCastManager.isFeatureEnabled(CastConfiguration.FEATURE_CAPTIONS_PREFERENCE)
&& mSelectedMedia != null
/*<archos changes> && mCastManager.getTracksPreferenceManager().isCaptionEnabled()<!archos changes>*/) {
List<MediaTrack> tracks = mSelectedMedia.getMediaTracks();
state = Utils.hasAudioOrTextTrack(tracks) ? VideoCastController.CC_ENABLED
: VideoCastController.CC_DISABLED;
}
mCastController.setClosedCaptionState(state);
}
开发者ID:archos-sa,项目名称:aos-Video,代码行数:12,代码来源:VideoCastControllerFragment.java
示例16: notifyTracksSelectedListeners
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
/**
* Notifies all the
* {@link com.google.android.libraries.cast.companionlibrary.cast.tracks.OnTracksSelectedListener} // NOLINT
* that the set of active tracks has changed. If there are no listeners registered, then the
* cast manager sets that itself.
*
* @param tracks the set of active tracks. Must be {@code non-null} but can be an empty list.
*/
public void notifyTracksSelectedListeners(List<MediaTrack> tracks) {
if (tracks == null) {
throw new IllegalArgumentException("tracks must not be null");
}
if (mTracksSelectedListeners.isEmpty()) {
setActiveTracks(tracks);
} else {
for (OnTracksSelectedListener listener : mTracksSelectedListeners) {
listener.onTracksSelected(tracks);
}
}
}
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:21,代码来源:VideoCastManager.java
示例17: updateClosedCaptionState
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
private void updateClosedCaptionState() {
int state = VideoCastController.CC_HIDDEN;
if (mCastManager.isFeatureEnabled(CastConfiguration.FEATURE_CAPTIONS_PREFERENCE)
&& mSelectedMedia != null
&& mCastManager.getTracksPreferenceManager().isCaptionEnabled()) {
List<MediaTrack> tracks = mSelectedMedia.getMediaTracks();
state = Utils.hasAudioOrTextTrack(tracks) ? VideoCastController.CC_ENABLED
: VideoCastController.CC_DISABLED;
}
mCastController.setClosedCaptionState(state);
}
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:12,代码来源:VideoCastControllerFragment.java
示例18: onCreate
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
Bundle mediaWrapper = getArguments().getBundle(VideoCastManager.EXTRA_MEDIA);
mMediaInfo = Utils.bundleToMediaInfo(mediaWrapper);
mCastManager = VideoCastManager.getInstance();
mActiveTracks = mCastManager.getActiveTrackIds();
List<MediaTrack> allTracks = mMediaInfo.getMediaTracks();
if (allTracks == null || allTracks.isEmpty()) {
Utils.showToast(getActivity(), R.string.ccl_caption_no_tracks_available);
dismiss();
}
}
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:15,代码来源:TracksChooserDialog.java
示例19: TracksListAdapter
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
public TracksListAdapter(Context context, int resource, List<MediaTrack> tracks,
int activePosition) {
super(context, resource);
this.mContext = context;
mTracks = new ArrayList<>();
mTracks.addAll(tracks);
mSelectedPosition = activePosition;
}
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:9,代码来源:TracksListAdapter.java
示例20: hasAudioOrTextTrack
import com.google.android.gms.cast.MediaTrack; //导入依赖的package包/类
/**
* Returns {@code true} if and only if the {@code tracks} include at least one audio or text
* track.
*/
public static boolean hasAudioOrTextTrack(List<MediaTrack> tracks) {
if (tracks == null || tracks.isEmpty()) {
return false;
}
for (MediaTrack track : tracks) {
if (track.getType() == MediaTrack.TYPE_AUDIO
|| track.getType() == MediaTrack.TYPE_TEXT) {
return true;
}
}
return false;
}
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:17,代码来源:Utils.java
注:本文中的com.google.android.gms.cast.MediaTrack类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论