use of org.videolan.libvlc.IVLCVout in project vlc-android by GeoffreyMetais.
the class VideoPlayerActivity method handleVout.
private void handleVout(int voutCount) {
mHandler.removeCallbacks(mSwitchAudioRunnable);
final IVLCVout vlcVout = mService.getVLCVout();
if (vlcVout.areViewsAttached() && voutCount == 0) {
mHandler.postDelayed(mSwitchAudioRunnable, 4000);
}
}
use of org.videolan.libvlc.IVLCVout in project vlc-android by GeoffreyMetais.
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();
}
use of org.videolan.libvlc.IVLCVout in project vlc-android by GeoffreyMetais.
the class VideoPlayerActivity method changeSurfaceLayout.
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void changeSurfaceLayout() {
int sw;
int sh;
// get screen size
if (mDisplayManager.isPrimary()) {
sw = getWindow().getDecorView().getWidth();
sh = getWindow().getDecorView().getHeight();
} else if (mDisplayManager.getPresentation() != null) {
sw = mDisplayManager.getPresentation().getWindow().getDecorView().getWidth();
sh = mDisplayManager.getPresentation().getWindow().getDecorView().getHeight();
} else
return;
// sanity check
if (sw * sh == 0) {
Log.e(TAG, "Invalid surface size");
return;
}
if (mService != null) {
final IVLCVout vlcVout = mService.getVLCVout();
vlcVout.setWindowSize(sw, sh);
}
SurfaceView surface;
SurfaceView subtitlesSurface;
FrameLayout surfaceFrame;
if (mDisplayManager.isPrimary()) {
surface = mSurfaceView;
subtitlesSurface = mSubtitlesSurfaceView;
surfaceFrame = mSurfaceFrame;
} else if (mDisplayManager.getDisplayType() == DisplayManager.DisplayType.PRESENTATION) {
surface = mDisplayManager.getPresentation().getSurfaceView();
subtitlesSurface = mDisplayManager.getPresentation().getSubtitlesSurfaceView();
surfaceFrame = mDisplayManager.getPresentation().getSurfaceFrame();
} else
return;
LayoutParams lp = surface.getLayoutParams();
if (mVideoWidth * mVideoHeight == 0 || isInPictureInPictureMode()) {
/* Case of OpenGL vouts: handles the placement of the video using MediaPlayer API */
lp.width = LayoutParams.MATCH_PARENT;
lp.height = LayoutParams.MATCH_PARENT;
surface.setLayoutParams(lp);
lp = surfaceFrame.getLayoutParams();
lp.width = LayoutParams.MATCH_PARENT;
lp.height = LayoutParams.MATCH_PARENT;
surfaceFrame.setLayoutParams(lp);
if (mService != null && mVideoWidth * mVideoHeight == 0)
changeMediaPlayerLayout(sw, sh);
return;
}
if (mService != null && lp.width == lp.height && lp.width == LayoutParams.MATCH_PARENT) {
/* We handle the placement of the video using Android View LayoutParams */
mService.setVideoAspectRatio(null);
mService.setVideoScale(0);
}
double dw = sw, dh = sh;
boolean isPortrait;
// getWindow().getDecorView() doesn't always take orientation into account, we have to correct the values
isPortrait = mDisplayManager.isPrimary() && mCurrentScreenOrientation == Configuration.ORIENTATION_PORTRAIT;
if (sw > sh && isPortrait || sw < sh && !isPortrait) {
dw = sh;
dh = sw;
}
// compute the aspect ratio
double ar, vw;
if (mSarDen == mSarNum) {
/* No indication about the density, assuming 1:1 */
vw = mVideoVisibleWidth;
ar = (double) mVideoVisibleWidth / (double) mVideoVisibleHeight;
} else {
/* Use the specified aspect ratio */
vw = mVideoVisibleWidth * (double) mSarNum / mSarDen;
ar = vw / mVideoVisibleHeight;
}
// compute the display aspect ratio
double dar = dw / dh;
switch(mCurrentSize) {
case SURFACE_BEST_FIT:
if (dar < ar)
dh = dw / ar;
else
dw = dh * ar;
break;
case SURFACE_FIT_SCREEN:
if (dar >= ar)
dh = dw / ar;
else
/* horizontal */
dw = dh * ar;
/* vertical */
break;
case SURFACE_FILL:
break;
case SURFACE_16_9:
ar = 16.0 / 9.0;
if (dar < ar)
dh = dw / ar;
else
dw = dh * ar;
break;
case SURFACE_4_3:
ar = 4.0 / 3.0;
if (dar < ar)
dh = dw / ar;
else
dw = dh * ar;
break;
case SURFACE_ORIGINAL:
dh = mVideoVisibleHeight;
dw = vw;
break;
}
// set display size
lp.width = (int) Math.ceil(dw * mVideoWidth / mVideoVisibleWidth);
lp.height = (int) Math.ceil(dh * mVideoHeight / mVideoVisibleHeight);
surface.setLayoutParams(lp);
subtitlesSurface.setLayoutParams(lp);
// set frame size (crop if necessary)
lp = surfaceFrame.getLayoutParams();
lp.width = (int) Math.floor(dw);
lp.height = (int) Math.floor(dh);
surfaceFrame.setLayoutParams(lp);
surface.invalidate();
subtitlesSurface.invalidate();
}
use of org.videolan.libvlc.IVLCVout in project vlc-android by GeoffreyMetais.
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);
}
use of org.videolan.libvlc.IVLCVout in project vlc-android by GeoffreyMetais.
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;
}
Aggregations