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?