本文整理汇总了Java中org.videolan.libvlc.Media.Track方法的典型用法代码示例。如果您正苦于以下问题:Java Media.Track方法的具体用法?Java Media.Track怎么用?Java Media.Track使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.videolan.libvlc.Media
的用法示例。
在下文中一共展示了Media.Track方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateText
import org.videolan.libvlc.Media; //导入方法依赖的package包/类
private void updateText() {
boolean hasSubs = false;
if (mMedia == null)
return;
final int trackCount = mMedia.getTrackCount();
for (int i = 0; i < trackCount; ++i) {
final Media.Track track = mMedia.getTrack(i);
if (track.type == Media.Track.Type.Text)
hasSubs = true;
mAdapter.add(track);
}
if (mAdapter.isEmpty()) {
getActivity().finish();
return;
}
if (hasSubs)
mHandler.obtainMessage(SHOW_SUBTITLES).sendToTarget();
}
示例2: getAvailableTracks
import org.videolan.libvlc.Media; //导入方法依赖的package包/类
/**
*
* @param media
* @return
*/
static org.videolan.libvlc.Media.Track[] getAvailableTracks(org.videolan.libvlc.Media media) {
ArrayList<Media.Track> l = new ArrayList<Media.Track>();
int c = media.getTrackCount();
while (--c >= 0) {
Media.Track t = media.getTrack(c);
System.out.println("ExoVlcUtil.getAvailableTracks() ?? type : " + t.type + " search "
+ Arrays.binarySearch(MEDIA_TYPES, t.type));
if (Arrays.binarySearch(MEDIA_TYPES, t.type) >= 0)
l.add(t);
}
return l.toArray(new org.videolan.libvlc.Media.Track[l.size()]);
}
示例3: init
import org.videolan.libvlc.Media; //导入方法依赖的package包/类
private void init(Media media) {
mType = TYPE_ALL;
if (media != null) {
if (media.isParsed()) {
mLength = media.getDuration();
for (int i = 0; i < media.getTrackCount(); ++i) {
final Media.Track track = media.getTrack(i);
if (track == null)
continue;
if (track.type == Media.Track.Type.Video) {
final Media.VideoTrack videoTrack = (VideoTrack) track;
mType = TYPE_VIDEO;
mWidth = videoTrack.width;
mHeight = videoTrack.height;
} else if (mType == TYPE_ALL && track.type == Media.Track.Type.Audio){
mType = TYPE_AUDIO;
}
}
}
updateMeta(media);
if (mType == TYPE_ALL && media.getType() == Media.Type.Directory)
mType = TYPE_DIR;
}
if (mType == TYPE_ALL) {
final String location = mUri.toString();
int dotIndex = location.lastIndexOf(".");
if (dotIndex != -1) {
String fileExt = location.substring(dotIndex).toLowerCase(Locale.ENGLISH);
if( Extensions.VIDEO.contains(fileExt) ) {
mType = TYPE_VIDEO;
} else if (Extensions.AUDIO.contains(fileExt)) {
mType = TYPE_AUDIO;
} else if (Extensions.SUBTITLES.contains(fileExt)) {
mType = TYPE_SUBTITLE;
} else if (Extensions.PLAYLIST.contains(fileExt)) {
mType = TYPE_PLAYLIST;
}
}
}
}
示例4: getView
import org.videolan.libvlc.Media; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
View v = convertView;
if (v == null) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.list_item, parent, false);
holder = new ViewHolder();
holder.title = (TextView) v.findViewById(R.id.title);
holder.text = (TextView) v.findViewById(R.id.artist);
v.setTag(holder);
} else
holder = (ViewHolder) v.getTag();
Media.Track track = getItem(position);
String title;
StringBuilder textBuilder = new StringBuilder(1024);
Resources res = getContext().getResources();
switch (track.type)
{
case Media.Track.Type.Audio:
title = res.getString(R.string.track_audio);
appendCommon(textBuilder, res, track);
appendAudio(textBuilder, res, (Media.AudioTrack)track);
break;
case Media.Track.Type.Video:
title = res.getString(R.string.track_video);
appendCommon(textBuilder, res, track);
appendVideo(textBuilder, res, (Media.VideoTrack) track);
break;
case Media.Track.Type.Text:
title = res.getString(R.string.track_text);
appendCommon(textBuilder, res, track);
break;
default:
title = res.getString(R.string.track_unknown);
}
holder.title.setText(title);
holder.text.setText(textBuilder.toString());
return v;
}
示例5: appendCommon
import org.videolan.libvlc.Media; //导入方法依赖的package包/类
private void appendCommon(StringBuilder textBuilder, Resources res, Media.Track track) {
textBuilder.append(res.getString(R.string.track_codec_info, track.codec));
if (track.language != null && !track.language.equalsIgnoreCase("und"))
textBuilder.append(res.getString(R.string.track_language_info, track.language));
}
示例6: init
import org.videolan.libvlc.Media; //导入方法依赖的package包/类
private void init(Media media) {
mType = TYPE_ALL;
if (media != null) {
if (media.isParsed()) {
mLength = media.getDuration();
for (int i = 0; i < media.getTrackCount(); ++i) {
final Media.Track track = media.getTrack(i);
if (track == null)
continue;
if (track.type == Media.Track.Type.Video) {
final Media.VideoTrack videoTrack = (VideoTrack) track;
mType = TYPE_VIDEO;
mWidth = videoTrack.width;
mHeight = videoTrack.height;
} else if (mType == TYPE_ALL && track.type == Media.Track.Type.Audio){
mType = TYPE_AUDIO;
}
}
}
updateMeta(media);
if (mType == TYPE_ALL && media.getType() == Media.Type.Directory)
mType = TYPE_DIR;
}
if (mType == TYPE_ALL) {
final int index = mUri.toString().indexOf('?');
String location;
if (index == -1)
location = mUri.toString();
else
location = mUri.toString().substring(0, index);
int dotIndex = location.lastIndexOf(".");
if (dotIndex != -1) {
String fileExt = location.substring(dotIndex).toLowerCase(Locale.ENGLISH);
if( Extensions.VIDEO.contains(fileExt) ) {
mType = TYPE_VIDEO;
} else if (Extensions.AUDIO.contains(fileExt)) {
mType = TYPE_AUDIO;
} else if (Extensions.SUBTITLES.contains(fileExt)) {
mType = TYPE_SUBTITLE;
} else if (Extensions.PLAYLIST.contains(fileExt)) {
mType = TYPE_PLAYLIST;
}
}
}
}
示例7: track2mediaFormat
import org.videolan.libvlc.Media; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
static android.media.MediaFormat track2mediaFormat(Media.Track track) {
android.media.MediaFormat mf;
// TODO fix track
switch (track.type) {
case Media.Track.Type.Video: {
VideoTrack vt = (VideoTrack) track;
mf = android.media.MediaFormat.createVideoFormat(track.codec, vt.width, vt.height);
mf.setInteger(android.media.MediaFormat.KEY_WIDTH, vt.width);
mf.setInteger(android.media.MediaFormat.KEY_HEIGHT, vt.height);
mf.setFloat(android.media.MediaFormat.KEY_FRAME_RATE, vt.frameRateNum);
}
break;
case Media.Track.Type.Audio: {
AudioTrack at = (AudioTrack) track;
mf = android.media.MediaFormat.createAudioFormat(track.codec, at.rate, at.channels);
}
break;
case Media.Track.Type.Text: {
SubtitleTrack st = (SubtitleTrack) track;
mf = android.media.MediaFormat.createSubtitleFormat(track.codec, track.language);
mf.setString(VLCTrackKeys.VLC_SUBTITLE_TRACK_ECODING, st.encoding);
}
break;
default:
throw new IllegalArgumentException("Unknown track type.");
}
mf.setInteger(android.media.MediaFormat.KEY_BIT_RATE, track.bitrate);
mf.setString(android.media.MediaFormat.KEY_LANGUAGE, track.language);// VLC_TRACK_ORIGINAL_CODEC
mf.setString(VLCTrackKeys.VLC_TRACK_DESCRIPTION, track.description);
mf.setString(VLCTrackKeys.VLC_TRACK_ORIGINAL_CODEC, track.originalCodec);
// TODO
/*
* Missing maxInputSize = getOptionalIntegerV16(format,
* android.media.MediaFormat.KEY_MAX_INPUT_SIZE); pixelWidthHeightRatio
* = getOptionalFloatV16(format, KEY_PIXEL_WIDTH_HEIGHT_RATIO);
*/
return mf;
}