private boolean hasTrack(int trackType) { try { TrackInfo trackInfo[] = getLocalPlayer().getTrackInfo(); // HLS media does not have the track info, so we treat them conservatively. if (trackInfo.length == 0) return true; for (TrackInfo info : trackInfo) { // TODO(zqzhang): may be we can have a histogram recording // media track types in the future. // See http://crbug.com/571411 if (trackType == info.getTrackType()) return true; if (TrackInfo.MEDIA_TRACK_TYPE_UNKNOWN == info.getTrackType()) return true; } } catch (RuntimeException e) { // Exceptions may come from getTrackInfo (IllegalStateException/RuntimeException), or // from some customized OS returning null TrackInfos (NullPointerException). return true; } return false; }
@CalledByNative protected boolean hasVideo() { return hasTrack(TrackInfo.MEDIA_TRACK_TYPE_VIDEO); }
@CalledByNative protected boolean hasAudio() { return hasTrack(TrackInfo.MEDIA_TRACK_TYPE_AUDIO); }
/** * Method to get information about the current file * @return a TrackInfo array with the information */ public TrackInfo[] getTrackInfo() { return mediaPlayer.getTrackInfo(); }