0

I wrote a basic code to play a video. That code is working on my phone :

@Override
public void surfaceCreated(SurfaceHolder holder) {
    Log.d(TAG, "surface created");
    mp.setAudioStreamType(AudioManager.STREAM_MUSIC);

    try {

        File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),"a.wmv");
        Log.d(TAG,file.getPath());
        mp.setDataSource("/storage/emulated/0/Download/a.wmv");
        mp.setOnPreparedListener(MainActivity.this); //Une fois le buffer pret
        mp.setOnErrorListener(MainActivity.this); //gestion des erreurs

        mp.setDisplay(holder);
        mp.prepareAsync(); //Peut prendre du temps (buffering)!

    } catch (IOException e) {
        Log.e(TAG, "error " + e.getMessage());
        e.printStackTrace();
    }
}

@Override
public void onPrepared(MediaPlayer mp) {
    int videoWidth = mp.getVideoWidth();
    int videoHeight = mp.getVideoHeight();

    int screenWidth = getWindowManager().getDefaultDisplay().getWidth();

    android.view.ViewGroup.LayoutParams lp = mSurfaceView.getLayoutParams();

    //Set the width of the SurfaceView to the width of the screen
    lp.width = screenWidth;
    lp.height = (int) (((float)videoHeight / (float)videoWidth) * (float)screenWidth);
    mSurfaceView.setLayoutParams(lp);

    mp.start();
}

When I try to use it on my android wearable, I have that following error :

setDataSourceFD failed.: status=0x80000000

Could that be linked to a codec problem not supported on my android wearable?

krakig
  • 1,515
  • 1
  • 19
  • 33
  • possible duplicate of [MediaPlayer.setDataSource causes IOException for valid file](http://stackoverflow.com/questions/9657280/mediaplayer-setdatasource-causes-ioexception-for-valid-file) – Dr.Avalanche Sep 04 '15 at 15:02

1 Answers1

0

There are no hardware-backed codecs on the wearable devices, so if you do need to play something like that, you would need to write a software decoder and that may not perform well due to the limited resources there.

Ali Naddaf
  • 16,951
  • 2
  • 21
  • 28