FileDocCategorySizeDatePackage
StreamStarter.javaAPI DocAndroid 1.5 API3712Wed May 06 22:42:46 BST 2009com.android.music

StreamStarter

public class StreamStarter extends android.app.Activity

Fields Summary
private android.content.BroadcastReceiver
mStatusListener
Constructors Summary
Methods Summary
public voidonCreate(android.os.Bundle icicle)

        super.onCreate(icicle);
        setVolumeControlStream(AudioManager.STREAM_MUSIC);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.streamstarter);
        
        TextView tv = (TextView) findViewById(R.id.streamloading);
        
        Uri uri = getIntent().getData();
        String msg = getString(R.string.streamloadingtext, uri.getHost());
        tv.setText(msg);
    
public voidonPause()


    
       
        if (MusicUtils.sService != null) {
            try {
                // This looks a little weird (when it's not playing, stop playing)
                // but it is correct. When nothing is playing, it means that this
                // was paused before a connection was established, in which case
                // we stop trying to connect/play.
                // Otherwise, this call to onPause() was a result of the call to
                // finish() above, and we should let playback continue.
                if (! MusicUtils.sService.isPlaying()) {
                    MusicUtils.sService.stop();
                }
            } catch (RemoteException ex) {
            }
        }
        unregisterReceiver(mStatusListener);
        MusicUtils.unbindFromService(this);
        super.onPause();
    
public voidonResume()

        super.onResume();

        MusicUtils.bindToService(this, new ServiceConnection() {
            public void onServiceConnected(ComponentName classname, IBinder obj) {
                try {
                    IntentFilter f = new IntentFilter();
                    f.addAction(MediaPlaybackService.ASYNC_OPEN_COMPLETE);
                    registerReceiver(mStatusListener, new IntentFilter(f));
                    MusicUtils.sService.openfileAsync(getIntent().getData().toString());
                } catch (RemoteException ex) {
                }
            }

            public void onServiceDisconnected(ComponentName classname) {
            }
        });