0

我正在使用 android textureview 播放视频播放列表,每次电影结束时,我都会监听 endstate 重新加载数据源并播放下一个视频。我正在使用 EXOPLAYER 并将纹理视图的表面发送给玩家。播放列表工作正常,但有时在视频之间切换时,视频不显示,仅显示音频,并且运行 30 分钟后设备重新启动。有人可以帮我找出原因。谢谢你..我附上了相关代码

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.adplayertexture);   
        AdplayerTexture=(TextureView)findViewById(R.id.AdPlayerTexture);
        AdplayerTexture.setBackgroundColor(Color.BLACK);
            AdplayerTexture.setSurfaceTextureListener(this);
      }
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width,
        int height) {

     AdPlayerSurface = new Surface( surface); 
     playMedia(AdPlayerSurface);
}


private void playMedia(Surface surface){
    mediaplayer=new ExoPlayer();
    mediaplayer.play(this,Videopathlist[CurrentVideoIndex],surface;
     mediaplayer.addListener(this);   
   }

@Override
public void onStateChanged(boolean playWhenReady, int playbackState) {

    if (playbackState == ExoPlayer.STATE_ENDED) {
    //releasing the resources   
        mediaplayer.DestroyPlayer();
    AdPlayerSurface.release();

    AdPlayerSurface=new Surface(AdplayerTexture.getSurfaceTexture());
        CurrentVideoIndex++;
    playMedia(AdPlayerSurface);
    }
4

0 回答 0