Merge pull request #2525 from dirkmueller/video_aspect
Set video aspect on initial creation
This commit is contained in:
commit
b1c212c2fc
|
@ -152,16 +152,9 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onAwaitingVideoSurface() {
|
protected void onAwaitingVideoSurface() {
|
||||||
|
setupVideoAspectRatio();
|
||||||
if (videoSurfaceCreated && controller != null) {
|
if (videoSurfaceCreated && controller != null) {
|
||||||
Log.d(TAG, "Videosurface already created, setting videosurface now");
|
Log.d(TAG, "Videosurface already created, setting videosurface now");
|
||||||
|
|
||||||
Pair<Integer, Integer> videoSize = controller.getVideoSize();
|
|
||||||
if (videoSize != null && videoSize.first > 0 && videoSize.second > 0) {
|
|
||||||
Log.d(TAG, "Width,height of video: " + videoSize.first + ", " + videoSize.second);
|
|
||||||
videoview.setVideoSize(videoSize.first, videoSize.second);
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "Could not determine video size");
|
|
||||||
}
|
|
||||||
controller.setVideoSurface(videoview.getHolder());
|
controller.setVideoSurface(videoview.getHolder());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,6 +192,18 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
||||||
videoControlsHider.start();
|
videoControlsHider.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupVideoAspectRatio() {
|
||||||
|
if (videoSurfaceCreated && controller != null) {
|
||||||
|
Pair<Integer, Integer> videoSize = controller.getVideoSize();
|
||||||
|
if (videoSize != null && videoSize.first > 0 && videoSize.second > 0) {
|
||||||
|
Log.d(TAG, "Width,height of video: " + videoSize.first + ", " + videoSize.second);
|
||||||
|
videoview.setVideoSize(videoSize.first, videoSize.second);
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "Could not determine video size");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void toggleVideoControlsVisibility() {
|
private void toggleVideoControlsVisibility() {
|
||||||
if (videoControlsShowing) {
|
if (videoControlsShowing) {
|
||||||
getSupportActionBar().hide();
|
getSupportActionBar().hide();
|
||||||
|
@ -247,7 +252,7 @@ public class VideoplayerActivity extends MediaplayerActivity {
|
||||||
Log.e(TAG, "Couldn't attach surface to mediaplayer - reference to service was null");
|
Log.e(TAG, "Couldn't attach surface to mediaplayer - reference to service was null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setupVideoAspectRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue