2017-09-01 260 views
0

我使用exoplayer與循環功能如下:Exoplayer停止循環

private fun prepareExoPlayerFromFileUri(uri: Uri, mediaView: SurfaceView) { 
    val exoPlayer = ExoPlayerFactory.newSimpleInstance(DefaultRenderersFactory(this), DefaultTrackSelector(null as BandwidthMeter?), DefaultLoadControl()) 
    exoPlayer.setVideoSurfaceView(mediaView) 

    val dataSpec = DataSpec(uri) 
    val fileDataSource = FileDataSource() 
    try { 
     fileDataSource.open(dataSpec) 
    } catch (e: FileDataSource.FileDataSourceException) { 
     e.printStackTrace() 
    } 

    val factory = DataSource.Factory { fileDataSource } 
    val mediaSource = ExtractorMediaSource(fileDataSource.uri, factory, DefaultExtractorsFactory(), null, null) 

    exoPlayer.prepare(mediaSource) 
    exoPlayer.repeatMode = Player.REPEAT_MODE_ONE 
    exoPlayer.playWhenReady = true 
} 

然而,一段時間後,我觀察到的視頻剛剛停在最後一幀。 我無法看到任何與外星人相關的日誌。

這裏是我的設置:

華碩Tinkerboard與MARSHMELLOW,並通過HDMI端口連接一臺電視機。屏幕始終打開。

編輯:我已經創建了ExoPlayer回購的問題: https://github.com/google/ExoPlayer/issues/3239

回答

0

它好像這是由音頻軌道,這是比視頻軌道較短,而當前版本ExoPlayer造成的,在那個時候,會因爲這個而掛。

ExoPlayer小組在issue 1874中解決了這個問題,該問題已在ExoPlayer 2.6.0中發佈,所以不應該在最新版本上發生。