我有一个带有JW Player字幕的VTT文件,我正在尝试创建一个交互式笔录。为此,我需要将VTT文件读入数组,然后与数据进行交互。
这是VTT文件的摘录:
1
00:00:00 --> 00:00:05
65 MEP we have twitter handles for both of us on screen as well so if you want
2
00:00:05 --> 00:00:08
to interact with those afterwards that's the best way to do so now been going to
3
00:00:08,051 --> 00:00:12,310
be talking about a topic that's extremely important topic in my mind and
到目前为止,这是我的Javascript:
$.get('http://dev.sharepoint-videos.com/test.vtt', function(data) {
// Read all captions into an array
var items = data.split('\n\r');
console.log(items);
//Loop through all captions
$.each(items, function( index, value ) {
var item = items[index].split('\n');
console.log(item);
});
});
这是我的Console.log返回的内容
0: "1
↵00:00:00 --> 00:00:05
↵65 MEP we have twitter handles for both of us on screen as well so if you want
"
1: "↵2
↵00:00:05 --> 00:00:08
↵to interact with those afterwards that's the best way to do so now been going to
"
2: "↵3
↵00:00:08,051 --> 00:00:12,310
↵be talking about a topic that's extremely important topic in my mind and
"
乳白色不是理想的结果。我还是Java语言的新手,我想做的就是将每个标题读入数组,然后循环获取开始时间和结束时间以及标题,以便可以在JW Player JS API中使用它们。
最佳答案
这终于对我有用。
$.get('http://dev.sharepoint-videos.com/test.vtt', function(data) {
// Read all captions into an array
var items = data.split('\n\r\n');
console.log(items);
//Loop through all captions
$.each(items, function( index, value ) {
var item = items[index].split('\n');
console.log(item);
});
});