<!-- Title for track number in music gadget -->
<string name="gadget_track">Track <xliff:g id="track_number">%d</xliff:g></string>
+
+ <!-- Toast after streamStarter activity receives PLAYBACK_COMPLETE in case of an error -->
+ <string name="fail_to_start_stream">Failed to play the requested stream.</string>
</resources>
import android.os.RemoteException;
import android.view.Window;
import android.widget.TextView;
+import android.widget.Toast;
public class StreamStarter extends Activity
{
try {
IntentFilter f = new IntentFilter();
f.addAction(MediaPlaybackService.ASYNC_OPEN_COMPLETE);
+ f.addAction(MediaPlaybackService.PLAYBACK_COMPLETE);
registerReceiver(mStatusListener, new IntentFilter(f));
MusicUtils.sService.openfileAsync(getIntent().getData().toString());
} catch (RemoteException ex) {
private BroadcastReceiver mStatusListener = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if (action.equals(MediaPlaybackService.PLAYBACK_COMPLETE)) {
+ // You would come here only in case of a failure in the
+ // MediaPlayerService before PrepareAsync completes
+ String msg = getString(R.string.fail_to_start_stream);
+ Toast mt = Toast.makeText(StreamStarter.this, msg, Toast.LENGTH_SHORT);
+ mt.show();
+ finish();
+ return;
+ }
try {
MusicUtils.sService.play();
intent = new Intent("com.android.music.PLAYBACK_VIEWER");