Improved media info loading behaviour of mediaplayeractivity
This commit is contained in:
parent
704e974940
commit
3c2f083378
|
@ -64,6 +64,8 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements
|
||||||
|
|
||||||
/** True if video controls are currently visible. */
|
/** True if video controls are currently visible. */
|
||||||
private boolean videoControlsShowing = true;
|
private boolean videoControlsShowing = true;
|
||||||
|
/** True if media information was loaded. */
|
||||||
|
private boolean mediaInfoLoaded = false;
|
||||||
|
|
||||||
private PlaybackService playbackService;
|
private PlaybackService playbackService;
|
||||||
private MediaPositionObserver positionObserver;
|
private MediaPositionObserver positionObserver;
|
||||||
|
@ -157,7 +159,7 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
Log.d(TAG, "Creating Activity");
|
Log.d(TAG, "Creating Activity");
|
||||||
|
|
||||||
orientation = getResources().getConfiguration().orientation;
|
orientation = getResources().getConfiguration().orientation;
|
||||||
manager = FeedManager.getInstance();
|
manager = FeedManager.getInstance();
|
||||||
getWindow().setFormat(PixelFormat.TRANSPARENT);
|
getWindow().setFormat(PixelFormat.TRANSPARENT);
|
||||||
|
@ -224,6 +226,7 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements
|
||||||
break;
|
break;
|
||||||
case PREPARING:
|
case PREPARING:
|
||||||
setStatusMsg(R.string.player_preparing_msg, View.VISIBLE);
|
setStatusMsg(R.string.player_preparing_msg, View.VISIBLE);
|
||||||
|
loadMediaInfo();
|
||||||
break;
|
break;
|
||||||
case STOPPED:
|
case STOPPED:
|
||||||
setStatusMsg(R.string.player_stopped_msg, View.VISIBLE);
|
setStatusMsg(R.string.player_stopped_msg, View.VISIBLE);
|
||||||
|
@ -279,27 +282,32 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadMediaInfo() {
|
private void loadMediaInfo() {
|
||||||
Log.d(TAG, "Loading media info");
|
if (!mediaInfoLoaded) {
|
||||||
if (media != null) {
|
Log.d(TAG, "Loading media info");
|
||||||
MediaPlayer player = playbackService.getPlayer();
|
if (media != null) {
|
||||||
|
|
||||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||||
getSupportActionBar().setSubtitle(media.getItem().getTitle());
|
getSupportActionBar().setSubtitle(
|
||||||
getSupportActionBar().setTitle(
|
media.getItem().getTitle());
|
||||||
media.getItem().getFeed().getTitle());
|
getSupportActionBar().setTitle(
|
||||||
pagerAdapter.notifyDataSetChanged();
|
media.getItem().getFeed().getTitle());
|
||||||
|
pagerAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
txtvPosition.setText(Converter.getDurationStringLong((media
|
||||||
|
.getPosition())));
|
||||||
|
|
||||||
|
if (!playbackService.isShouldStream()) {
|
||||||
|
txtvLength.setText(Converter.getDurationStringLong(media
|
||||||
|
.getDuration()));
|
||||||
|
float progress = ((float) media.getPosition())
|
||||||
|
/ media.getDuration();
|
||||||
|
sbPosition.setProgress((int) (progress * sbPosition
|
||||||
|
.getMax()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
mediaInfoLoaded = true;
|
||||||
txtvPosition.setText(Converter.getDurationStringLong((player
|
|
||||||
.getCurrentPosition())));
|
|
||||||
txtvLength.setText(Converter.getDurationStringLong(player
|
|
||||||
.getDuration()));
|
|
||||||
if (playbackService != null) {
|
|
||||||
updateProgressbarPosition();
|
|
||||||
} else {
|
|
||||||
sbPosition.setProgress(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue