summaryrefslogtreecommitdiff
path: root/src/de/podfetcher/activity/MediaplayerActivity.java
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2012-06-27 18:40:46 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2012-06-27 18:40:46 +0200
commit821dad45d20a30f5d84db7698ca18e925bd2f6dc (patch)
treeca68727c4f4897b76938a2c9097feea06828de49 /src/de/podfetcher/activity/MediaplayerActivity.java
parent0eded316b37cfd6328d528d1af2ea5e0aa716f35 (diff)
downloadAntennaPod-821dad45d20a30f5d84db7698ca18e925bd2f6dc.zip
Force portrait mode for audio
Diffstat (limited to 'src/de/podfetcher/activity/MediaplayerActivity.java')
-rw-r--r--src/de/podfetcher/activity/MediaplayerActivity.java29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/de/podfetcher/activity/MediaplayerActivity.java b/src/de/podfetcher/activity/MediaplayerActivity.java
index fd1dce669..103bab92a 100644
--- a/src/de/podfetcher/activity/MediaplayerActivity.java
+++ b/src/de/podfetcher/activity/MediaplayerActivity.java
@@ -7,6 +7,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
+import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.PixelFormat;
import android.media.MediaPlayer;
@@ -105,19 +106,16 @@ public class MediaplayerActivity extends SherlockActivity implements
super.onConfigurationChanged(newConfig);
Log.d(TAG, "Configuration changed");
orientation = newConfig.orientation;
- positionObserver.cancel(true);
+ if (positionObserver != null) {
+ positionObserver.cancel(true);
+ }
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
setContentView(R.layout.mediaplayer_activity);
} else {
setContentView(R.layout.mediaplayer_activity);
}
setupGUI();
- if (playbackService != null && playbackService.isPlayingVideo()) {
- playbackService.resetVideoSurface();
- if (!videoview.isShown()) {
- viewswitcher.showNext();
- }
- }
+
}
@Override
@@ -219,14 +217,7 @@ public class MediaplayerActivity extends SherlockActivity implements
break;
case AWAITING_VIDEO_SURFACE:
Log.d(TAG, "Preparing video playback");
- SurfaceHolder holder = videoview.getHolder();
- playbackService.setVideoSurface(holder);
- holder.addCallback(this);
- if (orientation == Configuration.ORIENTATION_PORTRAIT) {
- if (!videoview.isShown()) {
- viewswitcher.showNext();
- }
- }
+ this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
}
@@ -294,7 +285,6 @@ public class MediaplayerActivity extends SherlockActivity implements
private void setupGUI() {
viewswitcher = (ViewSwitcher) findViewById(R.id.viewswitcher);
sbPosition = (SeekBar) findViewById(R.id.sbPosition);
- videoview = (VideoView) findViewById(R.id.videoview);
txtvPosition = (TextView) findViewById(R.id.txtvPosition);
txtvLength = (TextView) findViewById(R.id.txtvLength);
@@ -358,6 +348,8 @@ public class MediaplayerActivity extends SherlockActivity implements
});
} else {
setTheme(R.style.Theme_Sherlock_Light_NoActionBar);
+ videoview = (VideoView) findViewById(R.id.videoview);
+ videoview.getHolder().addCallback(this);
videoview.setOnClickListener(playbuttonListener);
}
}
@@ -386,6 +378,11 @@ public class MediaplayerActivity extends SherlockActivity implements
media = playbackService.getMedia();
registerReceiver(statusUpdate, new IntentFilter(
PlaybackService.ACTION_PLAYER_STATUS_CHANGED));
+ if (playbackService.isPlayingVideo()) {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+ } else {
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+ }
handleStatus();
Log.d(TAG, "Connection to Service established");
}