summaryrefslogtreecommitdiff
path: root/src/de
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2012-08-05 16:27:10 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2012-08-05 16:27:10 +0200
commit6901e4a08ff33945330251a3e515c9520394d836 (patch)
treeed3e697dc28b5a801ef23696ff7a58502574460c /src/de
parentd657c9ffb738f2bef05b853485fe037006bac90f (diff)
downloadAntennaPod-6901e4a08ff33945330251a3e515c9520394d836.zip
Added listener for buffering information and progressbar in videoplayer
Diffstat (limited to 'src/de')
-rw-r--r--src/de/danoeh/antennapod/activity/AudioplayerActivity.java10
-rw-r--r--src/de/danoeh/antennapod/activity/MediaplayerActivity.java8
-rw-r--r--src/de/danoeh/antennapod/activity/VideoplayerActivity.java20
-rw-r--r--src/de/danoeh/antennapod/service/PlaybackService.java21
4 files changed, 56 insertions, 3 deletions
diff --git a/src/de/danoeh/antennapod/activity/AudioplayerActivity.java b/src/de/danoeh/antennapod/activity/AudioplayerActivity.java
index e85dac186..5144a40cf 100644
--- a/src/de/danoeh/antennapod/activity/AudioplayerActivity.java
+++ b/src/de/danoeh/antennapod/activity/AudioplayerActivity.java
@@ -186,4 +186,14 @@ public class AudioplayerActivity extends MediaplayerActivity {
}
}
+ @Override
+ protected void onBufferStart() {
+ postStatusMsg(R.string.player_buffering_msg);
+ }
+
+ @Override
+ protected void onBufferEnd() {
+ clearStatusMsg();
+ }
+
}
diff --git a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java
index be0179e64..5c844d317 100644
--- a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java
+++ b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java
@@ -127,6 +127,8 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity imple
* not the correct one for the current activity.
*/
protected abstract void onReloadNotification(int notificationCode);
+ protected abstract void onBufferStart();
+ protected abstract void onBufferEnd();
protected BroadcastReceiver notificationReceiver = new BroadcastReceiver() {
@@ -162,6 +164,12 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity imple
case PlaybackService.NOTIFICATION_TYPE_SLEEPTIMER_UPDATE:
invalidateOptionsMenu();
break;
+ case PlaybackService.NOTIFICATION_TYPE_BUFFER_START:
+ onBufferStart();
+ break;
+ case PlaybackService.NOTIFICATION_TYPE_BUFFER_END:
+ onBufferEnd();
+ break;
}
} else {
diff --git a/src/de/danoeh/antennapod/activity/VideoplayerActivity.java b/src/de/danoeh/antennapod/activity/VideoplayerActivity.java
index 7bf87448e..87d0b3a7b 100644
--- a/src/de/danoeh/antennapod/activity/VideoplayerActivity.java
+++ b/src/de/danoeh/antennapod/activity/VideoplayerActivity.java
@@ -16,6 +16,7 @@ import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
+import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.VideoView;
@@ -30,6 +31,7 @@ public class VideoplayerActivity extends MediaplayerActivity implements
private LinearLayout videoOverlay;
private VideoView videoview;
+ private ProgressBar progressIndicator;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -64,6 +66,7 @@ public class VideoplayerActivity extends MediaplayerActivity implements
super.setupGUI();
videoOverlay = (LinearLayout) findViewById(R.id.overlay);
videoview = (VideoView) findViewById(R.id.videoview);
+ progressIndicator = (ProgressBar) findViewById(R.id.progressIndicator);
videoview.getHolder().addCallback(this);
videoview.setOnClickListener(playbuttonListener);
videoview.setOnTouchListener(onVideoviewTouched);
@@ -85,14 +88,15 @@ public class VideoplayerActivity extends MediaplayerActivity implements
@Override
protected void postStatusMsg(int resId) {
- // TODO Auto-generated method stub
+ if (resId == R.string.player_preparing_msg) {
+ progressIndicator.setVisibility(View.VISIBLE);
+ }
}
@Override
protected void clearStatusMsg() {
- // TODO Auto-generated method stub
-
+ progressIndicator.setVisibility(View.INVISIBLE);
}
View.OnTouchListener onVideoviewTouched = new View.OnTouchListener() {
@@ -229,6 +233,16 @@ public class VideoplayerActivity extends MediaplayerActivity implements
super.onStopTrackingTouch(seekBar);
setupVideoControlsToggler();
}
+
+ @Override
+ protected void onBufferStart() {
+ progressIndicator.setVisibility(View.VISIBLE);
+ }
+
+ @Override
+ protected void onBufferEnd() {
+ progressIndicator.setVisibility(View.INVISIBLE);
+ }
diff --git a/src/de/danoeh/antennapod/service/PlaybackService.java b/src/de/danoeh/antennapod/service/PlaybackService.java
index 53bed27ca..d65b0257a 100644
--- a/src/de/danoeh/antennapod/service/PlaybackService.java
+++ b/src/de/danoeh/antennapod/service/PlaybackService.java
@@ -79,6 +79,8 @@ public class PlaybackService extends Service {
public static final int NOTIFICATION_TYPE_RELOAD = 3;
/** The state of the sleeptimer changed. */
public static final int NOTIFICATION_TYPE_SLEEPTIMER_UPDATE = 4;
+ public static final int NOTIFICATION_TYPE_BUFFER_START = 5;
+ public static final int NOTIFICATION_TYPE_BUFFER_END = 6;
/** Is true if service is running. */
public static boolean isRunning = false;
@@ -171,6 +173,7 @@ public class PlaybackService extends Service {
player.setOnSeekCompleteListener(onSeekCompleteListener);
player.setOnErrorListener(onErrorListener);
player.setOnBufferingUpdateListener(onBufferingUpdateListener);
+ player.setOnInfoListener(onInfoListener);
mediaButtonReceiver = new ComponentName(getPackageName(),
MediaButtonReceiver.class.getName());
audioManager.registerMediaButtonEventReceiver(mediaButtonReceiver);
@@ -356,6 +359,7 @@ public class PlaybackService extends Service {
player.setOnSeekCompleteListener(onSeekCompleteListener);
player.setOnErrorListener(onErrorListener);
player.setOnBufferingUpdateListener(onBufferingUpdateListener);
+ player.setOnInfoListener(onInfoListener);
status = PlayerStatus.STOPPED;
setupMediaplayer();
}
@@ -446,6 +450,23 @@ public class PlaybackService extends Service {
}
};
+ private MediaPlayer.OnInfoListener onInfoListener = new MediaPlayer.OnInfoListener() {
+
+ @Override
+ public boolean onInfo(MediaPlayer mp, int what, int extra) {
+ switch (what) {
+ case MediaPlayer.MEDIA_INFO_BUFFERING_START:
+ sendNotificationBroadcast(NOTIFICATION_TYPE_BUFFER_START, 0);
+ return true;
+ case MediaPlayer.MEDIA_INFO_BUFFERING_END:
+ sendNotificationBroadcast(NOTIFICATION_TYPE_BUFFER_END, 0);
+ return true;
+ default:
+ return false;
+ }
+ }
+ };
+
private MediaPlayer.OnErrorListener onErrorListener = new MediaPlayer.OnErrorListener() {
private static final String TAG = "PlaybackService.onErrorListener";