title: Android and MediaPlayer : How to change playback rate?
body: <p>I try to add a video on my Android Application with the VideoView but it's not possible to change the Playback rate with VideoView : <a href="https://stackoverflow.com/questions/4614365/control-the-playback-speed-of-video-in-android">Control the playback speed of video in android</a></p>
  
  <p>So I try to add a video with MediaPlayer like that :</p>
  
  <pre><code>import android.media.MediaPlayer;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.SurfaceView;
  
  public class MainActivity extends AppCompatActivity {
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          // http://vjs.zencdn.net/v/oceans.mp4
  
          try {
  
              String url = "http://vjs.zencdn.net/v/oceans.mp4"; // your URL here
  
              // メディアプレイヤーの作成
              MediaPlayer mediaPlayer = new MediaPlayer();
              mediaPlayer.setDataSource(url);
              mediaPlayer.prepare(); // might take long! (for buffering, etc)
              mediaPlayer.start();
  
              SurfaceView surface = new SurfaceView(this);
              mediaPlayer.setDisplay(surface.getHolder());
              setContentView(surface);
  
          }
          catch (Exception e) {
              System.out.println("例外が発生しました。");
          }
  
      }
  
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.menu_main, menu);
          return true;
      }
  
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          int id = item.getItemId();
  
          //noinspection SimplifiableIfStatement
          if (id == R.id.action_settings) {
              return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  
  }
  </code></pre>
  
  <p>When I build my application on my Phone, the video can play (I can here the sound) but there are not pictures (the screen is white).</p>
  
  <p>Where is my error ?</p>
  
  <p>And next question : How to change playback rate ?
  Is this code ok ? </p>
  
  <pre><code>            mediaPlayer.setDisplay(surface.getHolder());
              setContentView(surface);
              mediaPlayer.start();
  
              if (android.os.Build.VERSION.SDK_INT &gt;= 23) {
                  PlaybackParams myPlayBackParams = new PlaybackParams();
                  myPlayBackParams.setSpeed(2.0f);
                  mediaPlayer.setPlaybackParams(myPlayBackParams);
              }
  </code></pre>
  
  <p>Sorry, I can't check this code by my self because there are not pictures (there is only sound and it's look like no effect).</p>
  
  <p>Thank you !</p>