FileDocCategorySizeDatePackage
MediaFrameworkTest.javaAPI DocAndroid 5.1 API4662Thu Mar 12 22:22:30 GMT 2015com.android.mediaframeworktest

MediaFrameworkTest

public class MediaFrameworkTest extends android.app.Activity implements SurfaceHolder.Callback

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
public static android.graphics.Bitmap
mDestBitmap
public static android.widget.ImageView
mOverlayView
private android.view.SurfaceHolder
mSurfaceHolder
private String
TAG
private PowerManager.WakeLock
mWakeLock
Constructors Summary
public MediaFrameworkTest()


      
    
Methods Summary
public static booleancheckStreamingServer()

      InetAddress address = InetAddress.getByAddress(MediaNames.STREAM_SERVER);
      return address.isReachable(10000);
  
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);
        mOverlayView = (ImageView)findViewById(R.id.overlay_layer);
        ViewGroup.LayoutParams lp = mSurfaceView.getLayoutParams();
        mSurfaceHolder = mSurfaceView.getHolder();
        mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        mSurfaceHolder.addCallback(this);

        //Get the midi fd
        midiafd = this.getResources().openRawResourceFd(R.raw.testmidi);

        //Get the mp3 fd
        mp3afd = this.getResources().openRawResourceFd(R.raw.testmp3);
        mOverlayView.setLayoutParams(lp);
        mDestBitmap = Bitmap.createBitmap((int)640, (int)480, Bitmap.Config.ARGB_8888);
        mOverlayView.setImageBitmap(mDestBitmap);

        //Acquire the full wake lock to keep the device up
        PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE);
        mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "MediaFrameworkTest");
        mWakeLock.acquire();
    
public voidonDestroy()

        super.onDestroy();
        mWakeLock.release();
    
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);
    
public voidsurfaceChanged(android.view.SurfaceHolder holder, int format, int w, int h)

        //Do nothing in here. Just print out the log
        Log.v(TAG, "Test application surface changed");
    
public voidsurfaceCreated(android.view.SurfaceHolder holder)

    
public voidsurfaceDestroyed(android.view.SurfaceHolder holder)

        //Can do nothing in here. The test case will fail if the surface destroyed.
        Log.v(TAG, "Test application surface destroyed");
        mSurfaceHolder = null;
    
public static voidtestInvalidateOverlay()

      mOverlayView.invalidate();