2016-08-16 80 views

回答

0

我建議你試着利用ExoPlayer,因爲它現在在Android中得到很好的支持。

有一個螺紋這裏在ExoPlayer .SRT字幕支持:https://github.com/google/ExoPlayer/issues/587

線程包括本實施例中的代碼:

MediaFormat mediaFormat = MediaFormat.createTextFormat("0", MimeTypes.APPLICATION_SUBRIP, MediaFormat.NO_VALUE, C.MATCH_LONGEST_US, null); 
Uri uri = Uri.parse("file:///android_asset/german.srt"); 
SingleSampleSource textSampleSource = new SingleSampleSource(uri, new AssetDataSource(this), mediaFormat); 
TrackRenderer renderer = new TextTrackRenderer(textSampleSource, this, getMainLooper()); 

exo = ExoPlayer.Factory.newInstance(1); 
exo.addListener(this); 
exo.prepare(renderer); 
exo.setPlayWhenReady(true); 

有一個庫,ExoMedia,其提供了圍繞包裝ExoPlayer,並允許您使用類似的方法,因爲你會與視頻視圖:https://github.com/brianwernick/ExoMedia/

+0

謝謝,但沒有工作 –

+0

米克 - 你如何使用這個在外媒體? –

+0

它似乎仍在開發分支上進行開發 - 請參閱https://github.com/brianwernick/ExoMedia/issues/115。你是否需要將文本疊加到視頻視圖上,因爲可能有更簡單的方法來實現這一點? – Mick