org.videolan.libvlc.MediaPlayer Java Examples

The following examples show how to use org.videolan.libvlc.MediaPlayer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlaybackService.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
protected void publishState(int state) {
    if (mMediaSession == null)
        return;
    PlaybackStateCompat.Builder bob = new PlaybackStateCompat.Builder();
    bob.setActions(PLAYBACK_ACTIONS);
    switch (state) {
        case MediaPlayer.Event.Playing:
            bob.setState(PlaybackStateCompat.STATE_PLAYING, -1, 1);
            break;
        case MediaPlayer.Event.Stopped:
            bob.setState(PlaybackStateCompat.STATE_STOPPED, -1, 0);
            break;
        default:
        bob.setState(PlaybackStateCompat.STATE_PAUSED, -1, 0);
    }
    PlaybackStateCompat pbState = bob.build();
    mMediaSession.setPlaybackState(pbState);
    mMediaSession.setActive(state != PlaybackStateCompat.STATE_STOPPED);
}
 
Example #2
Source File: PlaybackService.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
/**
 * A function to control the Remote Control Client. It is needed for
 * compatibility with devices below Ice Cream Sandwich (4.0).
 *
 * @param state Playback state
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void setRemoteControlClientPlaybackState(int state) {
    if (!AndroidUtil.isICSOrLater() || mRemoteControlClient == null)
        return;

    switch (state) {
        case MediaPlayer.Event.Playing:
            mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
            break;
        case MediaPlayer.Event.Paused:
            mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
            break;
        case MediaPlayer.Event.Stopped:
            mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
            break;
    }
}
 
Example #3
Source File: VideoPlayerActivity.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
private boolean navigateDvdMenu(int keyCode) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_UP:
            mService.navigate(MediaPlayer.Navigate.Up);
            return true;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            mService.navigate(MediaPlayer.Navigate.Down);
            return true;
        case KeyEvent.KEYCODE_DPAD_LEFT:
            mService.navigate(MediaPlayer.Navigate.Left);
            return true;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            mService.navigate(MediaPlayer.Navigate.Right);
            return true;
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_ENTER:
        case KeyEvent.KEYCODE_BUTTON_X:
        case KeyEvent.KEYCODE_BUTTON_A:
            mService.navigate(MediaPlayer.Navigate.Activate);
            return true;
        default:
            return false;
    }
}
 
Example #4
Source File: VlcVideoLibrary.java    From vlc-example-streamplayer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onEvent(MediaPlayer.Event event) {
  switch (event.type) {
    case MediaPlayer.Event.Playing:
      vlcListener.onComplete();
      break;
    case MediaPlayer.Event.EncounteredError:
      vlcListener.onError();
      break;
    case MediaPlayer.Event.Buffering:
      vlcListener.onBuffering(event);
      break;
    default:
      break;
  }
}
 
Example #5
Source File: AudioPlayer.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
@Override
public void onMediaPlayerEvent(MediaPlayer.Event event) {
    switch (event.type) {
        case MediaPlayer.Event.Opening:
            mSwitchedToVideo = false;
            break;
        case MediaPlayer.Event.ESAdded:
            final boolean forceAudio = (mService.getCurrentMediaWrapper().getFlags() & MediaWrapper.MEDIA_FORCE_AUDIO) != 0;
            if (!forceAudio && !mSwitchedToVideo && event.getEsChangedType() == Media.Track.Type.Video) {
                mService.switchToVideo();
                mSwitchedToVideo = true;
            }
            break;
        case MediaPlayer.Event.Stopped:
            hide();
            break;
    }
}
 
Example #6
Source File: FragmentVideoPlayer.java    From uPods-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onEvent(MediaPlayer.Event event) {
    switch (event.type) {
        case MediaPlayer.Event.EndReached:
            releasePlayer();
            getActivity().onBackPressed();
            break;
        case MediaPlayer.Event.Playing: {
            if (!isVideoPlayerReady) {
                isVideoPlayerReady = true;
                pbLoading.setVisibility(View.GONE);
                MediaItem mediaItem = UniversalPlayer.getInstance().getPlayingMediaItem();
                if (mediaItem instanceof Podcast) {
                    int position = ProfileManager.getInstance().getTrackPosition(((Podcast) mediaItem).getSelectedTrack());
                    if (position > 0) {
                        mMediaPlayer.setTime(position);
                    }
                }
            }
        }
        case MediaPlayer.Event.Paused:
        case MediaPlayer.Event.Stopped:
        default:
            break;
    }
}
 
Example #7
Source File: VLCOptions.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
public static void setEqualizer(Context context, MediaPlayer.Equalizer eq, int preset) {
    final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = pref.edit();
    if (eq != null) {
        editor.putBoolean("equalizer_enabled", true);
        final int bandCount = MediaPlayer.Equalizer.getBandCount();
        final float[] bands = new float[bandCount + 1];
        bands[0] = eq.getPreAmp();
        for (int i = 0; i < bandCount; ++i) {
            bands[i + 1] = eq.getAmp(i);
        }
        Preferences.putFloatArray(editor, "equalizer_values", bands);
        editor.putInt("equalizer_preset", preset);
    } else {
        editor.putBoolean("equalizer_enabled", false);
    }
    Util.commitPreferences(editor);
}
 
Example #8
Source File: VLCOptions.java    From VCL-Android with Apache License 2.0 6 votes vote down vote up
@MainThread
public static MediaPlayer.Equalizer getEqualizer(Context context) {
    final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
    if (pref.getBoolean("equalizer_enabled", false)) {
        final float[] bands = Preferences.getFloatArray(pref, "equalizer_values");
        final int bandCount = MediaPlayer.Equalizer.getBandCount();
        if (bands.length != bandCount + 1)
            return null;

        final MediaPlayer.Equalizer eq = MediaPlayer.Equalizer.create();
        eq.setPreAmp(bands[0]);
        for (int i = 0; i < bandCount; ++i)
            eq.setAmp(i, bands[i + 1]);
        return eq;
    } else
        return null;
}
 
Example #9
Source File: VLCPlayerView.java    From react-native-vlc-player with MIT License 5 votes vote down vote up
@Override
    public void onEvent(MediaPlayer.Event event) {
        WritableMap eventMap = Arguments.createMap();
        switch (event.type) {
            case MediaPlayer.Event.EndReached:
                pausedState = false;
                eventMap.putBoolean(EVENT_PROP_END, true);
                mEventEmitter.receiveEvent(getId(), Events.EVENT_ENDED.toString(), eventMap);
                break;
            case MediaPlayer.Event.Stopped:
                mEventEmitter.receiveEvent(getId(), Events.EVENT_STOPPED.toString(), null);
                break;
            case MediaPlayer.Event.Playing:
                eventMap.putDouble(EVENT_PROP_DURATION, mMediaPlayer.getLength());
                mEventEmitter.receiveEvent(getId(), Events.EVENT_PLAYING.toString(), eventMap);
                break;
//            case MediaPlayer.Event.Buffering:
//                mEventEmitter.receiveEvent(getId(), Events.EVENT_PLAYING.toString(), null);
//                break;
            case MediaPlayer.Event.Paused:
                mEventEmitter.receiveEvent(getId(), Events.EVENT_PAUSED.toString(), null);
                break;
            case MediaPlayer.Event.EncounteredError:
                mEventEmitter.receiveEvent(getId(), Events.EVENT_ERROR.toString(), null);
                break;
            case MediaPlayer.Event.TimeChanged:
                eventMap.putDouble(EVENT_PROP_CURRENT_TIME, mMediaPlayer.getTime());
                eventMap.putDouble(EVENT_PROP_DURATION, mMediaPlayer.getLength());
                eventMap.putDouble(EVENT_PROP_POSITION, mMediaPlayer.getPosition());
                mEventEmitter.receiveEvent(getId(), Events.EVENT_PROGRESS.toString(), eventMap);
                break;
        }
    }
 
Example #10
Source File: PlaybackService.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Play a media from the media list (playlist)
 *
 * @param index The index of the media
 * @param flags LibVLC.MEDIA_* flags
 */
public void playIndex(int index, int flags) {
    if (mMediaList.size() == 0) {
        Log.w(TAG, "Warning: empty media list, nothing to play !");
        return;
    }
    if (index >= 0 && index < mMediaList.size()) {
        mCurrentIndex = index;
    } else {
        Log.w(TAG, "Warning: index " + index + " out of bounds");
        mCurrentIndex = 0;
    }

    String mrl = mMediaList.getMRL(index);
    if (mrl == null)
        return;
    final MediaWrapper mw = mMediaList.getMedia(index);
    if (mw == null)
        return;

    /* Pausable and seekable are true by default */
    mPausable = mSeekable = true;
    final Media media = new Media(VLCInstance.get(), mw.getUri());
    VLCOptions.setMediaOptions(media, this, flags | mw.getFlags());
    media.setEventListener(mMediaListener);
    mMediaPlayer.setMedia(media);
    media.release();
    mMediaPlayer.setEqualizer(VLCOptions.getEqualizer(this));
    mMediaPlayer.setVideoTitleDisplay(MediaPlayer.Position.Disable, 0);
    changeAudioFocus(true);
    mMediaPlayer.setEventListener(mMediaPlayerListener);
    mMediaPlayer.play();

    notifyTrackChanged();
    determinePrevAndNextIndices();
}
 
Example #11
Source File: PlaybackService.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
@MainThread
public void stop() {
    if (mMediaSession != null) {
        mMediaSession.setActive(false);
        mMediaSession.release();
        mMediaSession = null;
    }
    if (mMediaPlayer == null)
        return;
    savePosition();
    final Media media = mMediaPlayer.getMedia();
    if (media != null) {
        media.setEventListener(null);
        mMediaPlayer.setEventListener(null);
        mMediaPlayer.stop();
        mMediaPlayer.setMedia(null);
        media.release();
    }
    mMediaList.removeEventListener(mListEventListener);
    setRemoteControlClientPlaybackState(MediaPlayer.Event.Stopped);
    mCurrentIndex = -1;
    mPrevious.clear();
    mHandler.removeMessages(SHOW_PROGRESS);
    hideNotification();
    broadcastMetadata();
    executeUpdate();
    executeUpdateProgress();
    changeAudioFocus(false);
}
 
Example #12
Source File: PlaybackService.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
private MediaPlayer newMediaPlayer() {
    final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    final MediaPlayer mp = new MediaPlayer(LibVLC());
    final String aout = VLCOptions.getAout(pref);
    if (mp.setAudioOutput(aout) && aout.equals("android_audiotrack")) {
        mIsAudioTrack = true;
        if (mHasHdmiAudio)
            mp.setAudioOutputDevice("hdmi");
    } else
        mIsAudioTrack = false;
    mp.getVLCVout().addCallback(this);

    return mp;
}
 
Example #13
Source File: VideoPlayerActivity.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
private void updateNavStatus() {
    mIsNavMenu = false;
    mMenuIdx = -1;

    final MediaPlayer.Title[] titles = mService.getTitles();
    if (titles != null) {
        final int currentIdx = mService.getTitleIdx();
        for (int i = 0; i < titles.length; ++i) {
            final MediaPlayer.Title title = titles[i];
            if (title.menu) {
                mMenuIdx = i;
                break;
            }
        }
        mIsNavMenu = mMenuIdx == currentIdx;
    }

    if (mIsNavMenu) {
        /*
         * Keep the overlay hidden in order to have touch events directly
         * transmitted to navigation handling.
         */
        hideOverlay(false);
    }
    else if (mMenuIdx != -1)
        setESTracks();
    supportInvalidateOptionsMenu();
}
 
Example #14
Source File: EqualizerFragment.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
private static String[] getEqualizerPresets() {
    final int count = MediaPlayer.Equalizer.getPresetCount();
    if (count <= 0)
        return null;
    final String [] presets = new String[count];
    for (int i = 0; i < count; ++i) {
        presets[i] = MediaPlayer.Equalizer.getPresetName(i);
    }
    return presets;
}
 
Example #15
Source File: EqualizerFragment.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
    if (mService == null)
        return;

    mEqualizer = MediaPlayer.Equalizer.createFromPreset(pos);

    preamp.setProgress((int) mEqualizer.getPreAmp() + 20);
    for (int i = 0; i < BAND_COUNT; ++i) {
        EqualizerBar bar = (EqualizerBar) bands_layout.getChildAt(i);
        bar.setValue(mEqualizer.getAmp(i));
    }
}
 
Example #16
Source File: MediaWrapper.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
public void updateMeta(MediaPlayer mediaPlayer) {
    final Media media = mediaPlayer.getMedia();
    if (media == null)
        return;
    updateMeta(media);
    media.release();
}
 
Example #17
Source File: Dumper.java    From libvlc-sdk-android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a Dumper that will download an Uri into a local filesystem path
 *
 * @param uri      the Uri to dump
 * @param filepath local filesystem path where to dump the Uri
 * @param listener listener in order to be notified when the dump is finished
 */
@MainThread
public Dumper(Uri uri, String filepath, Listener listener) {
    if (uri == null || filepath == null || listener == null)
        throw new IllegalArgumentException("arguments shouldn't be null");
    mListener = listener;

    ArrayList<String> options = new ArrayList<>(8);
    options.add("--demux");
    options.add("dump2,none");
    options.add("--demuxdump-file");
    options.add(filepath);
    options.add("--no-video");
    options.add("--no-audio");
    options.add("--no-spu");
    options.add("-vv");
    mLibVLC = new LibVLC(null, options);

    final Media media = new Media(mLibVLC, uri);
    mMediaPlayer = new MediaPlayer(media);
    mMediaPlayer.setEventListener(new MediaPlayer.EventListener() {
        @Override
        public void onEvent(MediaPlayer.Event event) {
            switch (event.type) {
                case MediaPlayer.Event.Buffering:
                    mListener.onProgress(event.getBuffering());
                    break;
                case MediaPlayer.Event.EncounteredError:
                case MediaPlayer.Event.EndReached:
                    mListener.onFinish(event.type == MediaPlayer.Event.EndReached);
                    cancel();
                    break;
            }

        }
    });
    media.release();
}
 
Example #18
Source File: FragmentVideoPlayer.java    From uPods-android with Apache License 2.0 5 votes vote down vote up
private void createPlayer() {
    releasePlayer();
    String videoLink = UniversalPlayer.getInstance().getPlayingMediaItem().getAudeoLink();
    try {
        Logger.printInfo(TAG, "Trying to play video: " + videoLink);

        ArrayList<String> options = new ArrayList<String>();
        options.add("--aout=opensles");
        options.add("--audio-time-stretch"); // time stretching
        options.add("-vvv"); // verbosity
        libvlc = new LibVLC(options);
        shVideoHolder.setKeepScreenOn(true);

        // Create media player
        mMediaPlayer = new MediaPlayer(libvlc);
        mMediaPlayer.setEventListener(this);

        // Set up video output
        final IVLCVout vout = mMediaPlayer.getVLCVout();
        vout.setVideoView(sfVideo);
        vout.addCallback(this);
        vout.attachViews();

        Media m = URLUtil.isValidUrl(videoLink) ? new Media(libvlc, Uri.parse(videoLink)) : new Media(libvlc, videoLink);
        mMediaPlayer.setMedia(m);
        mMediaPlayer.play();
    } catch (Exception e) {
        Logger.printInfo(TAG, "Error creating video player: ");
        e.printStackTrace();
        if (onPlayingFailedCallback != null) {
            onPlayingFailedCallback.operationFinished();
        }
    }
}
 
Example #19
Source File: VlcVideoLibrary.java    From vlc-example-streamplayer with GNU General Public License v3.0 5 votes vote down vote up
private void setMedia(Media media) {
  //delay = network buffer + file buffer
  //media.addOption(":network-caching=" + Constants.BUFFER);
  //media.addOption(":file-caching=" + Constants.BUFFER);
  if (options != null) {
    for (String s : options) {
      media.addOption(s);
    }
  }
  media.setHWDecoderEnabled(true, false);
  player = new MediaPlayer(vlcInstance);
  player.setMedia(media);
  player.setEventListener(this);

  IVLCVout vlcOut = player.getVLCVout();
  //set correct class for render depend of constructor called
  if (surfaceView != null) {
    vlcOut.setVideoView(surfaceView);
    width = surfaceView.getWidth();
    height = surfaceView.getHeight();
  } else if (textureView != null) {
    vlcOut.setVideoView(textureView);
    width = textureView.getWidth();
    height = textureView.getHeight();
  } else if (surfaceTexture != null) {
    vlcOut.setVideoSurface(surfaceTexture);
  } else if (surface != null) {
    vlcOut.setVideoSurface(surface, surfaceHolder);
  } else {
    throw new RuntimeException("You cant set a null render object");
  }
  if (width != 0 && height != 0) vlcOut.setWindowSize(width, height);
  vlcOut.attachViews();
  player.setVideoTrackEnabled(true);
  player.play();
}
 
Example #20
Source File: Dumper.java    From libvlc-android-sdk with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Create a Dumper that will download an Uri into a local filesystem path
 * @param uri the Uri to dump
 * @param filepath local filesystem path where to dump the Uri
 * @param listener listener in order to be notified when the dump is finished
 */
@MainThread
public Dumper(Uri uri, String filepath, Listener listener) {
    if (uri == null || filepath == null || listener == null)
        throw new IllegalArgumentException("arguments shouldn't be null");
    mListener = listener;

    ArrayList<String> options = new ArrayList<>(8);
    options.add("--demux");
    options.add("dump2,none");
    options.add("--demuxdump-file");
    options.add(filepath);
    options.add("--no-video");
    options.add("--no-audio");
    options.add("--no-spu");
    options.add("-vv");
    mLibVLC = new LibVLC(null, options);

    final Media media = new Media(mLibVLC, uri);
    mMediaPlayer = new MediaPlayer(media);
    mMediaPlayer.setEventListener(new MediaPlayer.EventListener() {
        @Override
        public void onEvent(MediaPlayer.Event event) {
            switch (event.type) {
                case MediaPlayer.Event.Buffering:
                    mListener.onProgress(event.getBuffering());
                    break;
                case MediaPlayer.Event.EncounteredError:
                case MediaPlayer.Event.EndReached:
                    mListener.onFinish(event.type == MediaPlayer.Event.EndReached);
                    cancel();
                    break;
            }

        }
    });
    media.release();
}
 
Example #21
Source File: Dumper.java    From OTTLivePlayer_vlc with MIT License 5 votes vote down vote up
/**
 * Create a Dumper that will download an Uri into a local filesystem path
 * @param uri the Uri to dump
 * @param filepath local filesystem path where to dump the Uri
 * @param listener listener in order to be notified when the dump is finished
 */
@MainThread
public Dumper(Uri uri, String filepath, Listener listener) {
    if (uri == null || filepath == null || listener == null)
        throw new IllegalArgumentException("arguments shouldn't be null");
    mListener = listener;

    ArrayList<String> options = new ArrayList<>(8);
    options.add("--demux");
    options.add("dump2,none");
    options.add("--demuxdump-file");
    options.add(filepath);
    options.add("--no-video");
    options.add("--no-audio");
    options.add("--no-spu");
    options.add("-vv");
    mLibVLC = new LibVLC(null, options);

    final Media media = new Media(mLibVLC, uri);
    mMediaPlayer = new MediaPlayer(media);
    mMediaPlayer.setEventListener(new MediaPlayer.EventListener() {
        @Override
        public void onEvent(MediaPlayer.Event event) {
            switch (event.type) {
                case MediaPlayer.Event.Buffering:
                    mListener.onProgress(event.getBuffering());
                    break;
                case MediaPlayer.Event.EncounteredError:
                case MediaPlayer.Event.EndReached:
                    mListener.onFinish(event.type == MediaPlayer.Event.EndReached);
                    cancel();
                    break;
            }

        }
    });
    media.release();
}
 
Example #22
Source File: MediaWrapper.java    From OTTLivePlayer_vlc with MIT License 5 votes vote down vote up
public void updateMeta(MediaPlayer mediaPlayer) {
    if (!TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mDisplayTitle))
        mDisplayTitle = mTitle;
    final Media media = mediaPlayer.getMedia();
    if (media == null)
        return;
    updateMeta(media);
    media.release();
}
 
Example #23
Source File: Dumper.java    From OTTLivePlayer_vlc with MIT License 5 votes vote down vote up
/**
 * Create a Dumper that will download an Uri into a local filesystem path
 * @param uri the Uri to dump
 * @param filepath local filesystem path where to dump the Uri
 * @param listener listener in order to be notified when the dump is finished
 */
@MainThread
public Dumper(Uri uri, String filepath, Listener listener) {
    if (uri == null || filepath == null || listener == null)
        throw new IllegalArgumentException("arguments shouldn't be null");
    mListener = listener;

    ArrayList<String> options = new ArrayList<>(8);
    options.add("--demux");
    options.add("dump2,none");
    options.add("--demuxdump-file");
    options.add(filepath);
    options.add("--no-video");
    options.add("--no-audio");
    options.add("--no-spu");
    options.add("-vv");
    mLibVLC = new LibVLC(null, options);

    final Media media = new Media(mLibVLC, uri);
    mMediaPlayer = new MediaPlayer(media);
    mMediaPlayer.setEventListener(new MediaPlayer.EventListener() {
        @Override
        public void onEvent(MediaPlayer.Event event) {
            switch (event.type) {
                case MediaPlayer.Event.Buffering:
                    mListener.onProgress(event.getBuffering());
                    break;
                case MediaPlayer.Event.EncounteredError:
                case MediaPlayer.Event.EndReached:
                    mListener.onFinish(event.type == MediaPlayer.Event.EndReached);
                    cancel();
                    break;
            }

        }
    });
    media.release();
}
 
Example #24
Source File: MediaWrapper.java    From OTTLivePlayer_vlc with MIT License 5 votes vote down vote up
public void updateMeta(MediaPlayer mediaPlayer) {
    if (!TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mDisplayTitle))
        mDisplayTitle = mTitle;
    final Media media = mediaPlayer.getMedia();
    if (media == null)
        return;
    updateMeta(media);
    media.release();
}
 
Example #25
Source File: PlaybackService.java    From VCL-Android with Apache License 2.0 4 votes vote down vote up
@MainThread
public void setEqualizer(MediaPlayer.Equalizer equalizer) {
    mMediaPlayer.setEqualizer(equalizer);
}
 
Example #26
Source File: PlaybackService.java    From VCL-Android with Apache License 2.0 4 votes vote down vote up
@MainThread
public MediaPlayer.TrackDescription[] getSpuTracks() {
    return mMediaPlayer.getSpuTracks();
}
 
Example #27
Source File: PlaybackService.java    From VCL-Android with Apache License 2.0 4 votes vote down vote up
@MainThread
public MediaPlayer.TrackDescription[] getAudioTracks() {
    return mMediaPlayer.getAudioTracks();
}
 
Example #28
Source File: PlaybackService.java    From VCL-Android with Apache License 2.0 4 votes vote down vote up
@MainThread
public MediaPlayer.Title[] getTitles() {
    return mMediaPlayer.getTitles();
}
 
Example #29
Source File: PlaybackService.java    From VCL-Android with Apache License 2.0 4 votes vote down vote up
@MainThread
public MediaPlayer.Chapter[] getChapters(int title) {
    return mMediaPlayer.getChapters(title);
}
 
Example #30
Source File: Dumper.java    From vlc-example-streamplayer with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Create a Dumper that will download an Uri into a local filesystem path
 * @param uri the Uri to dump
 * @param filepath local filesystem path where to dump the Uri
 * @param listener listener in order to be notified when the dump is finished
 */
@MainThread
public Dumper(Uri uri, String filepath, Listener listener) {
    if (uri == null || filepath == null || listener == null)
        throw new IllegalArgumentException("arguments shouldn't be null");
    mListener = listener;

    ArrayList<String> options = new ArrayList<>(8);
    options.add("--demux");
    options.add("dump2,none");
    options.add("--demuxdump-file");
    options.add(filepath);
    options.add("--no-video");
    options.add("--no-audio");
    options.add("--no-spu");
    options.add("-vv");
    mLibVLC = new LibVLC(null, options);

    final Media media = new Media(mLibVLC, uri);
    mMediaPlayer = new MediaPlayer(media);
    mMediaPlayer.setEventListener(new MediaPlayer.EventListener() {
        @Override
        public void onEvent(MediaPlayer.Event event) {
            switch (event.type) {
                case MediaPlayer.Event.Buffering:
                    mListener.onProgress(event.getBuffering());
                    break;
                case MediaPlayer.Event.EncounteredError:
                case MediaPlayer.Event.EndReached:
                    mListener.onFinish(event.type == MediaPlayer.Event.EndReached);
                    cancel();
                    break;
            }

        }
    });
    media.release();
}