2017-02-15 63 views
0

我使用ExoPlayer可以播放來自URL的音頻。我有看起來像這樣的XML格式的字幕:ExoPlayer:顯示字幕

[ 
    { 
     "id": 1, 
     "startTime": "00:00:00", 
     "endTime": "00:00:05", 
     "textEn": "towns, in late 15th-century England.", 
     "textRu": null 
    }, 
    { 
     "id": 2, 
     "startTime": "00:00:05", 
     "endTime": "00:00:10", 
     "textEn": "the first thing to note is that in stark contrast to today, England was an overwhelmingly rural country.", 
     "textRu": null 
    } 
] 

我知道有一種方法可以在使用ExoPlayer播放時顯示字幕。但是,我在開發人員指南中掃描了一切:ExoPlayer Developer's guide,但沒有找到如何操作,因爲文檔非常差。 另外,字幕的XML格式是否適合ExoPlayer,如果現在,我應該如何將它們轉換爲什麼格式。 ExoPlayer忍者請幫助我)

回答

0

您可以將您的json轉換爲.str格式並將其另存爲文件。現在ExoPlayer可以顯示.str文件。這裏是一個str格式的示例:

1 
00:02:17,440 --> 00:02:20,375 
Senator, we're making 
our final approach into Coruscant. 

2 
00:02:20,476 --> 00:02:22,501 
Very good, Lieutenant.