Java Code Examples for org.videolan.libvlc.IVLCVout#removeCallback()

The following examples show how to use org.videolan.libvlc.IVLCVout#removeCallback() . 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: FragmentVideoPlayer.java    From uPods-android with Apache License 2.0 6 votes vote down vote up
private void releasePlayer() {
    if (libvlc == null)
        return;
    mMediaPlayer.stop();
    final IVLCVout vout = mMediaPlayer.getVLCVout();
    vout.removeCallback(this);
    vout.detachViews();
    shVideoHolder = null;
    libvlc.release();
    libvlc = null;

    mVideoWidth = 0;
    mVideoHeight = 0;
    isVideoPlayerReady = false;

    if (rlVideoControls != null && btnPlay != null) {
        rlVideoControls.setVisibility(View.GONE);
        btnPlay.setVisibility(View.GONE);
    }
}
 
Example 2
Source File: VLCPlayerView.java    From react-native-vlc-player with MIT License 5 votes vote down vote up
private void releasePlayer() {
    if (libvlc == null) return;
    mMediaPlayer.stop();
    final IVLCVout vout = mMediaPlayer.getVLCVout();
    vout.removeCallback(this);
    vout.detachViews();
    holder = null;
    libvlc.release();
    libvlc = null;

    mVideoWidth = 0;
    mVideoHeight = 0;
}
 
Example 3
Source File: VideoPlayerActivity.java    From VCL-Android with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void stopPlayback() {
    if (!mPlaybackStarted)
        return;

    if (mMute)
        mute(false);

    LibVLC().setOnHardwareAccelerationError(null);

    mPlaybackStarted = false;

    mService.removeCallback(this);
    final IVLCVout vlcVout = mService.getVLCVout();
    vlcVout.removeCallback(this);
    if (mSurfacesAttached)
        vlcVout.detachViews();
    mSurfaceView.setKeepScreenOn(false);

    mHandler.removeCallbacksAndMessages(null);

    mDetector.setOnDoubleTapListener(null);

    /* Stop listening for changes to media routes. */
    if (mMediaRouter != null)
        mediaRouterAddCallback(false);

    if (AndroidUtil.isHoneycombOrLater() && mOnLayoutChangeListener != null)
        mSurfaceFrame.removeOnLayoutChangeListener(mOnLayoutChangeListener);

    if (AndroidUtil.isICSOrLater())
        getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(null);

    mActionBarView.setOnTouchListener(null);

    if(mSwitchingView && mService != null) {
        Log.d(TAG, "mLocation = \"" + mUri + "\"");
        mService.showWithoutParse(savedIndexPosition);
        return;
    }

    final boolean isPaused = !mService.isPlaying();
    long time = getTime();
    long length = mService.getLength();
    //remove saved position if in the last 5 seconds
    if (length - time < 5000)
        time = 0;
    else
        time -= 2000; // go back 2 seconds, to compensate loading time
    mService.stop();

    SharedPreferences.Editor editor = mSettings.edit();
    // Save position
    if (mService.isSeekable()) {
        if(MediaDatabase.getInstance().mediaItemExists(mUri)) {
            MediaDatabase.getInstance().updateMedia(
                    mUri,
                    MediaDatabase.INDEX_MEDIA_TIME,
                    time);
        } else {
            // Video file not in media library, store time just for onResume()
            editor.putLong(PreferencesActivity.VIDEO_RESUME_TIME, time);
        }
    }
    if(isPaused)
        Log.d(TAG, "Video paused - saving flag");
    editor.putBoolean(PreferencesActivity.VIDEO_PAUSED, isPaused);

    // Save selected subtitles
    String subtitleList_serialized = null;
    if(mSubtitleSelectedFiles.size() > 0) {
        Log.d(TAG, "Saving selected subtitle files");
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try {
            ObjectOutputStream oos = new ObjectOutputStream(bos);
            oos.writeObject(mSubtitleSelectedFiles);
            subtitleList_serialized = bos.toString();
        } catch(IOException e) {}
    }
    editor.putString(PreferencesActivity.VIDEO_SUBTITLE_FILES, subtitleList_serialized);

    if (mUri != null)
        editor.putString(PreferencesActivity.VIDEO_LAST, mUri.toString());

    // Save user playback speed and restore normal speed
    editor.putFloat(PreferencesActivity.VIDEO_SPEED, mService.getRate());
    mService.setRate(1.0f);

    Util.commitPreferences(editor);
}