How can I highlight text - strictly timed - a la Karaoke without Flash on a web page. What technology choice?

Deadly 提交于 2019-12-10 18:05:09

问题


I would like to display the whole text of a poem, then have text highlighted according to a pre-established time sequence. Something like Karaoke, but without any sound track. A user would then be able to read it at exactly the "right" tempo.

I figure I can generate a subtitle track (for example, with something like Aegisum - although this keeps crashing on my Mac) with the timing data. Something line by line, such as:

1 00:00:18,067 --> 00:00:20,067 Twinkle twinkle little star

2 00:00:20,467 --> 00:00:22,467 How I wonder what you are

... or better still, a word or sylable at a time.

I don't want to use Flash for iPad/iPhone reasons.

My exact question is this as I'm somewhat naive: What would be the best technology to use? I don't need an exact solution, just some pointers on where I should concentrate my efforts. Does Timed Text in HTML5 (TTML) have anything I could use on this? Or SMIL?


回答1:


You can use Javascript and CSS to accomplish what you want. You can wrap each word in a span, then apply styles to the span elements at the proper timing intervals. If you can store timing information about when you want corresponding words highlighted, you can use setInterval to add styles at the appropriate times. If you want to use HTML5 features, you might look into using Canvas or SVG to enable more advanced animations.




回答2:


Someone posted a karaoke display engine build in js: https://github.com/sk89q/ricekaraoke




回答3:


You can achieve a karaoke effect using a javascript library from Mozilla called popcorn.js You can download it from http://mozillapopcorn.org/

Here is a tutorial http://net.tutsplus.com/articles/news/a-look-at-popcorn/

Here is a demo http://danharper.me/demo/a-look-at-popcorn/

Lots of links to related info at the bottom of the second link.



来源:https://stackoverflow.com/questions/8221854/how-can-i-highlight-text-strictly-timed-a-la-karaoke-without-flash-on-a-web

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!