0

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!

4

1 回答 1

0

问题不在于 .ts 封装,问题在于视频的编码。它具有 MPEG-2 视频编码,但默认情况下在 Android 上不受支持。

于 2015-04-08T14:10:44.617 回答