android.view.View.OnSystemUiVisibilityChangeListener#org.videolan.libvlc.IVLCVout源码实例Demo

下面列出了android.view.View.OnSystemUiVisibilityChangeListener#org.videolan.libvlc.IVLCVout 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jellyfin-androidtv   文件: VideoManager.java
@Override
public void onNewVideoLayout(IVLCVout vout, int width, int height, int visibleWidth, int visibleHeight, int sarNum, int sarDen) {
    if (width * height == 0 || isContracted)
        return;

    // store video size
    mVideoHeight = height;
    mVideoWidth = width;
    mVideoVisibleHeight = visibleHeight;
    mVideoVisibleWidth  = visibleWidth;
    mSarNum = sarNum;
    mSarDen = sarDen;

    mActivity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            changeSurfaceLayout(mVideoWidth, mVideoHeight, mVideoVisibleWidth, mVideoVisibleHeight, mSarNum, mSarDen);
        }
    });
}
 
源代码2 项目: uPods-android   文件: FragmentVideoPlayer.java
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);
    }
}
 
源代码3 项目: libvlc-android-sdk   文件: MainActivity.java
@Override
protected void onStart() {
    super.onStart();

    final IVLCVout vlcVout = mMediaPlayer.getVLCVout();
    if (mVideoSurface != null) {
        vlcVout.setVideoView(mVideoSurface);
        if (mSubtitlesSurface != null)
            vlcVout.setSubtitlesView(mSubtitlesSurface);
    } else
        vlcVout.setVideoView(mVideoTexture);
    vlcVout.attachViews(this);

    Media media = new Media(mLibVLC, Uri.parse(SAMPLE_URL));
    mMediaPlayer.setMedia(media);
    media.release();
    mMediaPlayer.play();

    if (mOnLayoutChangeListener == null) {
        mOnLayoutChangeListener = new View.OnLayoutChangeListener() {
            private final Runnable mRunnable = new Runnable() {
                @Override
                public void run() {
                    updateVideoSurfaces();
                }
            };

            @Override
            public void onLayoutChange(View v, int left, int top, int right,
                                       int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                if (left != oldLeft || top != oldTop || right != oldRight || bottom != oldBottom) {
                    mHandler.removeCallbacks(mRunnable);
                    mHandler.post(mRunnable);
                }
            }
        };
    }
    mVideoSurfaceFrame.addOnLayoutChangeListener(mOnLayoutChangeListener);
}
 
源代码4 项目: libvlc-android-sdk   文件: MainActivity.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
public void onNewVideoLayout(IVLCVout vlcVout, int width, int height, int visibleWidth, int visibleHeight, int sarNum, int sarDen) {
    mVideoWidth = width;
    mVideoHeight = height;
    mVideoVisibleWidth = visibleWidth;
    mVideoVisibleHeight = visibleHeight;
    mVideoSarNum = sarNum;
    mVideoSarDen = sarDen;
    updateVideoSurfaces();
}
 
源代码5 项目: react-native-vlc-player   文件: VLCPlayerView.java
private void setMedia(String filePath) {
    // Set up video output
    final IVLCVout vout = mMediaPlayer.getVLCVout();
    if (!vout.areViewsAttached()) {
        vout.setVideoView(mSurface);
        vout.addCallback(this);
        vout.attachViews();
    }
    Uri uri = Uri.parse(filePath);
    media = new Media(libvlc, uri);
    mMediaPlayer.setMedia(media);
    if (autoPlay) {
        mMediaPlayer.play();
    }
}
 
源代码6 项目: react-native-vlc-player   文件: VLCPlayerView.java
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;
}
 
源代码7 项目: react-native-vlc-player   文件: VLCPlayerView.java
@Override
public void onNewLayout(IVLCVout vout, int width, int height, int visibleWidth, int visibleHeight, int sarNum, int sarDen) {
    if (width * height == 0) return;

    // store video size
    mSarNum = sarNum;
    mSarDen = sarDen;
    changeSurfaceLayout(width, height);
}
 
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();
}
 
源代码9 项目: uPods-android   文件: FragmentVideoPlayer.java
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();
        }
    }
}
 
源代码10 项目: uPods-android   文件: FragmentVideoPlayer.java
@Override
public void onNewLayout(IVLCVout vlcVout, int width, int height, int visibleWidth, int visibleHeight, int sarNum, int sarDen) {
    if (width * height == 0)
        return;

    // store video size
    mVideoWidth = width;
    mVideoHeight = height;
    setSize(mVideoWidth, mVideoHeight);
}
 
源代码11 项目: uPods-android   文件: FragmentVideoPlayer.java
@Override
public void onHardwareAccelerationError(IVLCVout vlcVout) {
    // Handle errors with hardware acceleration
    Logger.printError(TAG, "Error with hardware acceleration");
    this.releasePlayer();
    if (onPlayingFailedCallback != null) {
        onPlayingFailedCallback.operationFinished();
    }
}
 
源代码12 项目: VCL-Android   文件: VideoPlayerActivity.java
private void handleVout(int voutCount) {
    final IVLCVout vlcVout = mService.getVLCVout();
    if (vlcVout.areViewsAttached() && voutCount == 0 && !mEndReached) {
        /* Video track lost, open in audio mode */
        Log.i(TAG, "Video track lost, switching to audio");
        mSwitchingView = true;
        exit(RESULT_VIDEO_TRACK_LOST);
    }
}
 
源代码13 项目: VCL-Android   文件: VideoPlayerActivity.java
@Override
public void onNewLayout(IVLCVout vlcVout, int width, int height, int visibleWidth, int visibleHeight, int sarNum, int sarDen) {
    if (width * height == 0)
        return;

    // store video size
    mVideoWidth = width;
    mVideoHeight = height;
    mVideoVisibleWidth  = visibleWidth;
    mVideoVisibleHeight = visibleHeight;
    mSarNum = sarNum;
    mSarDen = sarDen;
    changeSurfaceLayout();
}
 
源代码14 项目: react-native-vlc-player   文件: VLCPlayerView.java
private void changeSurfaceSize(int width, int height) {
    int screenWidth = width;
    int screenHeight = height;
    mVideoWidth = width;
    mVideoHeight = height;
    mVideoVisibleWidth = width;
    mVideoVisibleHeight = height;

    if (mMediaPlayer != null) {
        final IVLCVout vlcVout = mMediaPlayer.getVLCVout();
        vlcVout.setWindowSize(screenWidth, screenHeight);
    }

    double displayWidth = screenWidth, displayHeight = screenHeight;

    if (screenWidth < screenHeight) {
        displayWidth = screenHeight;
        displayHeight = screenWidth;
    }

    // sanity check
    if (displayWidth * displayHeight <= 1 || mVideoWidth * mVideoHeight <= 1) {
        return;
    }

    // compute the aspect ratio
    double aspectRatio, visibleWidth;
    if (mSarDen == mSarNum) {
        /* No indication about the density, assuming 1:1 */
        visibleWidth = mVideoVisibleWidth;
        aspectRatio = (double) mVideoVisibleWidth / (double) mVideoVisibleHeight;
    } else {
        /* Use the specified aspect ratio */
        visibleWidth = mVideoVisibleWidth * (double) mSarNum / mSarDen;
        aspectRatio = visibleWidth / mVideoVisibleHeight;
    }

    // compute the display aspect ratio
    double displayAspectRatio = displayWidth / displayHeight;

    counter++;

    switch (mCurrentSize) {
        case SURFACE_BEST_FIT:
            if (counter > 2) if (displayAspectRatio < aspectRatio) displayHeight = displayWidth / aspectRatio;
            else displayWidth = displayHeight * aspectRatio;
            break;
        case SURFACE_FIT_HORIZONTAL:
            displayHeight = displayWidth / aspectRatio;
            break;
        case SURFACE_FIT_VERTICAL:
            displayWidth = displayHeight * aspectRatio;
            break;
        case SURFACE_FILL:
            break;
        case SURFACE_16_9:
            aspectRatio = 16.0 / 9.0;
            if (displayAspectRatio < aspectRatio) displayHeight = displayWidth / aspectRatio;
            else displayWidth = displayHeight * aspectRatio;
            break;
        case SURFACE_4_3:
            aspectRatio = 4.0 / 3.0;
            if (displayAspectRatio < aspectRatio) displayHeight = displayWidth / aspectRatio;
            else displayWidth = displayHeight * aspectRatio;
            break;
        case SURFACE_ORIGINAL:
            displayHeight = mVideoVisibleHeight;
            displayWidth = visibleWidth;
            break;
    }

    // set display size
    int finalWidth = (int) Math.ceil(displayWidth * mVideoWidth / mVideoVisibleWidth);
    int finalHeight = (int) Math.ceil(displayHeight * mVideoHeight / mVideoVisibleHeight);

    SurfaceHolder holder = mSurface.getHolder();
    holder.setFixedSize(finalWidth, finalHeight);

    ViewGroup.LayoutParams lp = mSurface.getLayoutParams();
    lp.width = finalWidth;
    lp.height = finalHeight;
    mSurface.setLayoutParams(lp);
    mSurface.invalidate();
}
 
源代码15 项目: react-native-vlc-player   文件: VLCPlayerView.java
@Override
public void onHardwareAccelerationError(IVLCVout vout) {
    // Handle errors with hardware acceleration
    this.releasePlayer();
    Toast.makeText(getContext(), "Error with hardware acceleration", Toast.LENGTH_LONG).show();
}
 
源代码16 项目: VCL-Android   文件: VideoPlayerActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void startPlayback() {
    /* start playback only when audio service and both surfaces are ready */
    if (mPlaybackStarted || mService == null)
        return;

    mPlaybackStarted = true;

    /* Dispatch ActionBar touch events to the Activity */
    mActionBarView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            onTouchEvent(event);
            return true;
        }
    });

    if (AndroidUtil.isICSOrLater())
        getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(
                new OnSystemUiVisibilityChangeListener() {
                    @Override
                    public void onSystemUiVisibilityChange(int visibility) {
                        if (visibility == mUiVisibility)
                            return;
                        if (visibility == View.SYSTEM_UI_FLAG_VISIBLE && !mShowing && !isFinishing()) {
                            showOverlay();
                        }
                        mUiVisibility = visibility;
                    }
                }
        );

    if (AndroidUtil.isHoneycombOrLater()) {
        if (mOnLayoutChangeListener == null) {
            mOnLayoutChangeListener = new View.OnLayoutChangeListener() {
                private final Runnable mRunnable = new Runnable() {
                    @Override
                    public void run() {
                        changeSurfaceLayout();
                    }
                };
                @Override
                public void onLayoutChange(View v, int left, int top, int right,
                                           int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                    if (left != oldLeft || top != oldTop || right != oldRight || bottom != oldBottom) {
                        /* changeSurfaceLayout need to be called after the layout changed */
                        mHandler.removeCallbacks(mRunnable);
                        mHandler.post(mRunnable);
                    }
                }
            };
        }
        mSurfaceFrame.addOnLayoutChangeListener(mOnLayoutChangeListener);
    }
    changeSurfaceLayout();

    /* Listen for changes to media routes. */
    if (mMediaRouter != null)
        mediaRouterAddCallback(true);

    LibVLC().setOnHardwareAccelerationError(this);
    final IVLCVout vlcVout = mService.getVLCVout();
    vlcVout.detachViews();
    if (mPresentation == null) {
        vlcVout.setVideoView(mSurfaceView);
        if (mSubtitlesSurfaceView.getVisibility() != View.GONE)
            vlcVout.setSubtitlesView(mSubtitlesSurfaceView);
    } else {
        vlcVout.setVideoView(mPresentation.mSurfaceView);
        if (mSubtitlesSurfaceView.getVisibility() != View.GONE)
            vlcVout.setSubtitlesView(mPresentation.mSubtitlesSurfaceView);
    }
    mSurfacesAttached = true;
    vlcVout.addCallback(this);
    vlcVout.attachViews();
    mSurfaceView.setKeepScreenOn(true);

    loadMedia();

    // Add any selected subtitle file from the file picker
    if(mSubtitleSelectedFiles.size() > 0) {
        for(String file : mSubtitleSelectedFiles) {
            Log.i(TAG, "Adding user-selected subtitle " + file);
            mService.addSubtitleTrack(file);
        }
    }

    // Set user playback speed
    mService.setRate(mSettings.getFloat(PreferencesActivity.VIDEO_SPEED, 1));
}
 
源代码17 项目: VCL-Android   文件: VideoPlayerActivity.java
@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);
}
 
源代码18 项目: VCL-Android   文件: VideoPlayerActivity.java
private void sendMouseEvent(int action, int button, int x, int y) {
    if (mService == null)
        return;
    final IVLCVout vlcVout = mService.getVLCVout();
    vlcVout.sendMouseEvent(action, button, x, y);
}
 
源代码19 项目: VCL-Android   文件: VideoPlayerActivity.java
@Override
public void onSurfacesCreated(IVLCVout vlcVout) {
}
 
源代码20 项目: VCL-Android   文件: VideoPlayerActivity.java
@Override
public void onSurfacesDestroyed(IVLCVout vlcVout) {
    mSurfacesAttached = false;
}
 
源代码21 项目: VCL-Android   文件: PlaybackService.java
public IVLCVout getVLCVout()  {
    return mMediaPlayer.getVLCVout();
}
 
源代码22 项目: VCL-Android   文件: PlaybackService.java
@Override
public void onNewLayout(IVLCVout vlcVout, int width, int height, int visibleWidth, int visibleHeight, int sarNum, int sarDen) {
}
 
源代码23 项目: VCL-Android   文件: PlaybackService.java
@Override
public void onSurfacesCreated(IVLCVout vlcVout) {
    handleVout();
}
 
源代码24 项目: VCL-Android   文件: PlaybackService.java
@Override
public void onSurfacesDestroyed(IVLCVout vlcVout) {
    handleVout();
}
 
源代码25 项目: react-native-vlc-player   文件: VLCPlayerView.java
@Override
public void onSurfacesCreated(IVLCVout vout) {

}
 
源代码26 项目: react-native-vlc-player   文件: VLCPlayerView.java
@Override
public void onSurfacesDestroyed(IVLCVout vout) {

}
 
源代码27 项目: uPods-android   文件: FragmentVideoPlayer.java
@Override
public void onSurfacesCreated(IVLCVout vlcVout) {

}
 
源代码28 项目: uPods-android   文件: FragmentVideoPlayer.java
@Override
public void onSurfacesDestroyed(IVLCVout vlcVout) {

}