FileDocCategorySizeDatePackage
MediaFrameworkTest.javaAPI DocAndroid 1.5 API4698Wed May 06 22:42:00 BST 2009com.android.mediaframeworktest

MediaFrameworkTest

public class MediaFrameworkTest extends android.app.Activity

Fields Summary
public static android.view.SurfaceView
mSurfaceView
private android.widget.MediaController
mMediaController
private String
urlpath
private android.media.MediaPlayer
mpmidi
private android.media.MediaPlayer
mpmp3
private String
testfilepath
public static android.content.res.AssetFileDescriptor
midiafd
public static android.content.res.AssetFileDescriptor
mp3afd
Constructors Summary
public MediaFrameworkTest()

    
    
      
    
Methods Summary
public voidonCreate(android.os.Bundle icicle)
Called when the activity is first created.

        super.onCreate(icicle);
        setContentView(R.layout.surface_view);
        mSurfaceView = (SurfaceView)findViewById(R.id.surface_view);
        ViewGroup.LayoutParams lp = mSurfaceView.getLayoutParams();
        lp.width = 320;
        lp.height = 240;
        mSurfaceView.setLayoutParams(lp);
        mSurfaceView.getHolder().setFixedSize(320, 240);  
        mSurfaceView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        
        //Get the midi fd
        midiafd = this.getResources().openRawResourceFd(R.raw.testmidi);
        
        //Get the mp3 fd
        mp3afd = this.getResources().openRawResourceFd(R.raw.testmp3);
    
public booleanonKeyDown(int keyCode, android.view.KeyEvent event)

      switch (keyCode) {
          case KeyEvent.KEYCODE_0:
            MediaPlayer mp = new MediaPlayer();
            try{
              mp.setDataSource(MediaNames.VIDEO_RTSP3GP);
              Log.v("emily","awb  " + testfilepath);
              mp.setDisplay(mSurfaceView.getHolder());
              mp.prepare();
              mp.start();
            }catch (Exception e){}
              break;
          
          //start the music player intent with the test URL from PV    
          case KeyEvent.KEYCODE_1:
            startPlayback(MediaNames.STREAM_MP3_1);
            break;
          
          case KeyEvent.KEYCODE_2:
            startPlayback(MediaNames.STREAM_MP3_2);
            break;
          
          case KeyEvent.KEYCODE_3:
            startPlayback(MediaNames.STREAM_MP3_3);
            break;
          
          case KeyEvent.KEYCODE_4:
            startPlayback(MediaNames.STREAM_MP3_4);
            break;
          
          case KeyEvent.KEYCODE_5:
            startPlayback(MediaNames.STREAM_MP3_5);
            break;
          
          case KeyEvent.KEYCODE_6:
            startPlayback(MediaNames.STREAM_MP3_6);
            break;
          
          case KeyEvent.KEYCODE_7:
            startPlayback(MediaNames.STREAM_MP3_7);
            break;
          
          case KeyEvent.KEYCODE_8:
            startPlayback(MediaNames.STREAM_MP3_8);
            break;
          
          case KeyEvent.KEYCODE_9:
            startPlayback(MediaNames.STREAM_MP3_9);
            break;
          
              
              
      }
      return super.onKeyDown(keyCode, event);
     
  
public voidstartPlayback(java.lang.String filename)

      String mimetype = "audio/mpeg";
      Uri path = Uri.parse(filename);
      Intent intent = new Intent(Intent.ACTION_VIEW);
      intent.setDataAndType(path, mimetype);
      startActivity(intent);