Search in sources :

Example 6 with IVLCVout

use of org.videolan.libvlc.IVLCVout in project vlc-android by videolan.

the class VideoPlayerActivity method stopPlayback.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void stopPlayback() {
    if (!mPlaybackStarted)
        return;
    if (mDisplayManager.isOnRenderer() && !isFinishing()) {
        mPlaybackStarted = false;
        return;
    }
    mWasPaused = !mService.isPlaying();
    if (!isFinishing()) {
        mCurrentAudioTrack = mService.getAudioTrack();
        mCurrentSpuTrack = mService.getSpuTrack();
    }
    if (mMute)
        mute(false);
    mPlaybackStarted = false;
    mService.setVideoTrackEnabled(false);
    mService.removeCallback(this);
    mHandler.removeCallbacksAndMessages(null);
    final IVLCVout vlcVout = mService.getVLCVout();
    vlcVout.removeCallback(this);
    vlcVout.detachViews();
    if (mService.hasMedia() && mSwitchingView) {
        if (BuildConfig.DEBUG)
            Log.d(TAG, "mLocation = \"" + mUri + "\"");
        if (mSwitchToPopup)
            mService.switchToPopup(mService.getCurrentMediaPosition());
        else {
            mService.getCurrentMediaWrapper().addFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
            mService.showWithoutParse(mService.getCurrentMediaPosition());
        }
        return;
    }
    if (mService.isSeekable()) {
        mSavedTime = getTime();
        long length = mService.getLength();
        // remove saved position if in the last 5 seconds
        if (length - mSavedTime < 5000)
            mSavedTime = 0;
        else
            // go back 2 seconds, to compensate loading time
            mSavedTime -= 2000;
    }
    mSavedRate = mService.getRate();
    mRateHasChanged = mSavedRate != 1.0f;
    mService.setRate(1.0f, false);
    mService.stop();
}
Also used : IVLCVout(org.videolan.libvlc.IVLCVout) TargetApi(android.annotation.TargetApi)

Example 7 with IVLCVout

use of org.videolan.libvlc.IVLCVout in project vlc-android by videolan.

the class VideoPlayerActivity method startPlayback.

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void startPlayback() {
    /* start playback only when audio service and both surfaces are ready */
    if (mPlaybackStarted || mService == null)
        return;
    mSavedRate = 1.0f;
    mSavedTime = -1;
    mPlaybackStarted = true;
    IVLCVout vlcVout = mService.getVLCVout();
    if (vlcVout.areViewsAttached()) {
        if (mService.isPlayingPopup()) {
            mService.stop();
            vlcVout = mService.getVLCVout();
        } else
            vlcVout.detachViews();
    }
    final DisplayManager.SecondaryDisplay sd = mDisplayManager.getPresentation();
    vlcVout.setVideoView(sd != null ? sd.getSurfaceView() : mSurfaceView);
    vlcVout.setSubtitlesView(sd != null ? sd.getSubtitlesSurfaceView() : mSubtitlesSurfaceView);
    vlcVout.addCallback(this);
    vlcVout.attachViews(this);
    mService.setVideoTrackEnabled(true);
    initUI();
    loadMedia();
}
Also used : IVLCVout(org.videolan.libvlc.IVLCVout) TargetApi(android.annotation.TargetApi)

Example 8 with IVLCVout

use of org.videolan.libvlc.IVLCVout in project vlc-android by videolan.

the class PopupManager method showPopup.

public void showPopup() {
    mService.addCallback(this);
    LayoutInflater li = (LayoutInflater) VLCApplication.getAppContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mRootView = (PopupLayout) li.inflate(R.layout.video_popup, null);
    if (mAlwaysOn)
        mRootView.setKeepScreenOn(true);
    mPlayPauseButton = mRootView.findViewById(R.id.video_play_pause);
    mCloseButton = mRootView.findViewById(R.id.popup_close);
    mExpandButton = mRootView.findViewById(R.id.popup_expand);
    mPlayPauseButton.setOnClickListener(this);
    mCloseButton.setOnClickListener(this);
    mExpandButton.setOnClickListener(this);
    GestureDetectorCompat gestureDetector = new GestureDetectorCompat(mService, this);
    gestureDetector.setOnDoubleTapListener(this);
    mRootView.setGestureDetector(gestureDetector);
    final IVLCVout vlcVout = mService.getVLCVout();
    vlcVout.setVideoView((SurfaceView) mRootView.findViewById(R.id.player_surface));
    vlcVout.addCallback(this);
    vlcVout.attachViews(this);
    mRootView.setVLCVOut(vlcVout);
}
Also used : LayoutInflater(android.view.LayoutInflater) IVLCVout(org.videolan.libvlc.IVLCVout) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat)

Example 9 with IVLCVout

use of org.videolan.libvlc.IVLCVout in project vlc-android by videolan.

the class PopupManager method removePopup.

public void removePopup() {
    hideNotification();
    if (mRootView == null)
        return;
    mService.removeCallback(this);
    final IVLCVout vlcVout = mService.getVLCVout();
    vlcVout.detachViews();
    mRootView.close();
    mRootView = null;
}
Also used : IVLCVout(org.videolan.libvlc.IVLCVout)

Example 10 with IVLCVout

use of org.videolan.libvlc.IVLCVout in project butter-android by butterproject.

the class VlcPlayer method detachFromSurface.

public void detachFromSurface() {
    final IVLCVout vlcVout = mediaPlayer.getVLCVout();
    vlcVout.removeCallback(this);
    vlcVout.detachViews();
}
Also used : IVLCVout(org.videolan.libvlc.IVLCVout)

Aggregations

IVLCVout (org.videolan.libvlc.IVLCVout)16 TargetApi (android.annotation.TargetApi)6 SuppressLint (android.annotation.SuppressLint)2 GestureDetectorCompat (android.support.v4.view.GestureDetectorCompat)2 LayoutInflater (android.view.LayoutInflater)2 SurfaceView (android.view.SurfaceView)2 LayoutParams (android.view.ViewGroup.LayoutParams)2 FrameLayout (android.widget.FrameLayout)2