I have to try to play a .ts video using a MediaPlayer but it seems that is not capable.
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i2) {
Surface surface = new Surface(surfaceTexture);
try {
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(this, Uri.parse(URI));
mMediaPlayer.setSurface(surface);
mMediaPlayer.setLooping(true);
mMediaPlayer.prepareAsync();
// Play video when the media source is ready for playback.
mMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.start();
}
});
} catch (IllegalArgumentException e) {
Log.d(TAG, e.getMessage());
} catch (SecurityException e) {
Log.d(TAG, e.getMessage());
} catch (IllegalStateException e) {
Log.d(TAG, e.getMessage());
} catch (IOException e) {
Log.d(TAG, e.getMessage());
}
}
My tests are in devices over Android 4 but I have found these references URL1, URL2 and if I play the .ts video in VLC, for example, there is no problem.
I have tested the same code in two devices, one STB with android 4.0.4 and the other is a tablet ASUS Transformer TF101 with an android 4.0.3
. It works in the STB but no in the ASUS Transformer.
What would be the difference?
Thanks in advance for your time! Appreciate any help!