org.videolan.libvlc.IVLCVout Java Examples
The following examples show how to use
org.videolan.libvlc.IVLCVout.
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: VideoManager.java From jellyfin-androidtv with GNU General Public License v2.0 | 6 votes |
@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); } }); }
Example #2
Source File: FragmentVideoPlayer.java From uPods-android with Apache License 2.0 | 6 votes |
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 #3
Source File: VlcVideoLibrary.java From vlc-example-streamplayer with GNU General Public License v3.0 | 5 votes |
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 #4
Source File: VideoPlayerActivity.java From VCL-Android with Apache License 2.0 | 5 votes |
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); } }
Example #5
Source File: VideoPlayerActivity.java From VCL-Android with Apache License 2.0 | 5 votes |
@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(); }
Example #6
Source File: FragmentVideoPlayer.java From uPods-android with Apache License 2.0 | 5 votes |
@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(); } }
Example #7
Source File: FragmentVideoPlayer.java From uPods-android with Apache License 2.0 | 5 votes |
@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); }
Example #8
Source File: FragmentVideoPlayer.java From uPods-android with Apache License 2.0 | 5 votes |
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 #9
Source File: VLCPlayerView.java From react-native-vlc-player with MIT License | 5 votes |
@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); }
Example #10
Source File: VLCPlayerView.java From react-native-vlc-player with MIT License | 5 votes |
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 #11
Source File: VLCPlayerView.java From react-native-vlc-player with MIT License | 5 votes |
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(); } }
Example #12
Source File: MainActivity.java From libvlc-android-sdk with GNU Lesser General Public License v2.1 | 5 votes |
@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(); }
Example #13
Source File: MainActivity.java From libvlc-android-sdk with GNU Lesser General Public License v2.1 | 5 votes |
@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); }
Example #14
Source File: PlaybackService.java From VCL-Android with Apache License 2.0 | 4 votes |
@Override public void onNewLayout(IVLCVout vlcVout, int width, int height, int visibleWidth, int visibleHeight, int sarNum, int sarDen) { }
Example #15
Source File: PlaybackService.java From VCL-Android with Apache License 2.0 | 4 votes |
public IVLCVout getVLCVout() { return mMediaPlayer.getVLCVout(); }
Example #16
Source File: PlaybackService.java From VCL-Android with Apache License 2.0 | 4 votes |
@Override public void onSurfacesDestroyed(IVLCVout vlcVout) { handleVout(); }
Example #17
Source File: PlaybackService.java From VCL-Android with Apache License 2.0 | 4 votes |
@Override public void onSurfacesCreated(IVLCVout vlcVout) { handleVout(); }
Example #18
Source File: VideoPlayerActivity.java From VCL-Android with Apache License 2.0 | 4 votes |
@Override public void onSurfacesDestroyed(IVLCVout vlcVout) { mSurfacesAttached = false; }
Example #19
Source File: VideoPlayerActivity.java From VCL-Android with Apache License 2.0 | 4 votes |
@Override public void onSurfacesCreated(IVLCVout vlcVout) { }
Example #20
Source File: VideoPlayerActivity.java From VCL-Android with Apache License 2.0 | 4 votes |
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); }
Example #21
Source File: VideoPlayerActivity.java From VCL-Android with Apache License 2.0 | 4 votes |
@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); }
Example #22
Source File: VideoPlayerActivity.java From VCL-Android with Apache License 2.0 | 4 votes |
@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)); }
Example #23
Source File: VLCPlayerView.java From react-native-vlc-player with MIT License | 4 votes |
@Override public void onHardwareAccelerationError(IVLCVout vout) { // Handle errors with hardware acceleration this.releasePlayer(); Toast.makeText(getContext(), "Error with hardware acceleration", Toast.LENGTH_LONG).show(); }
Example #24
Source File: VLCPlayerView.java From react-native-vlc-player with MIT License | 4 votes |
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(); }
Example #25
Source File: FragmentVideoPlayer.java From uPods-android with Apache License 2.0 | 2 votes |
@Override public void onSurfacesDestroyed(IVLCVout vlcVout) { }
Example #26
Source File: FragmentVideoPlayer.java From uPods-android with Apache License 2.0 | 2 votes |
@Override public void onSurfacesCreated(IVLCVout vlcVout) { }
Example #27
Source File: VLCPlayerView.java From react-native-vlc-player with MIT License | 2 votes |
@Override public void onSurfacesDestroyed(IVLCVout vout) { }
Example #28
Source File: VLCPlayerView.java From react-native-vlc-player with MIT License | 2 votes |
@Override public void onSurfacesCreated(IVLCVout vout) { }