Skip to content

Instantly share code, notes, and snippets.

@gdakram
Created May 23, 2014 06:44
Show Gist options
  • Select an option

  • Save gdakram/48c8a799da0b411af7f8 to your computer and use it in GitHub Desktop.

Select an option

Save gdakram/48c8a799da0b411af7f8 to your computer and use it in GitHub Desktop.

Revisions

  1. gdakram created this gist May 23, 2014.
    24 changes: 24 additions & 0 deletions yoda.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    final SurfaceView sv = (SurfaceView) findViewById(R.id.splash_surface);
    MediaPlayer mp = new MediaPlayer();

    mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    @Override
    public void onPrepared(MediaPlayer mp) {
    mp.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
    mp.setDisplay(sv.getHolder());
    mp.start();
    }
    });

    try {
    AssetFileDescriptor afd = getResources().openRawResourceFd(UiUtil.isTablet(MainActivity.this) ? R.raw.splash_td_tablet : R.raw.splash_td_phone);
    mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getDeclaredLength());
    mp.prepare();
    } catch (IllegalStateException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }