文本高亮显示在jQuery的音频同步

编程入门 行业动态 更新时间:2024-10-11 23:15:35
本文介绍了文本高亮显示在jQuery的音频同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要同步文本和音频许多Web页面。

I need to sync text and audio on many web pages.

在播放文本音频应(通过文字或字符,这样的同步是必要的只为那句开始不字)被强调的词组短语。

While the audio is played the text should be highlighted phrase by phrase (not word by word or by character so sync is necessary only for the start of the phrase).

我想不使用闪光灯唯一的解决办法,我会preFER使用的东西更多的HTML友好。

I'd like not to use a flash only solution and I'd prefer to use something more HTML friendly.

我想用两个插件的组合:

I thought to use a combination of two plugins:

  • JPlayer 用于音频
  • jQuery的highligheter 以突出显示文本
  • JPlayer for the audio
  • Jquery highligheter for highlighting the text

我可以再编写一个jQuery脚本到周期的各种短语。第一个问题是,JPlayer只有个出场的​​事件,而不是precise时间轴事件,所以我需要分割为更小的音频文件所说的文字的全部MP3音频为每个词组(长的编辑工作和preLOAD管理需要)。

I could then write a jquery script to cycle on the various phrases. The first problem is that JPlayer has only percentage played events and not precise timeline events so I would need to split the full mp3 audio of the spoken text in smaller audio files for each phrase (long editing work and preload management needed).

是否有这更好的解决办法?我应该回到更容易充分SWF的解决方案?

Is there a better solution for this? Should I go back to the easier full swf solution?

推荐答案

你可以做的是脚本JavaScript中的时间表。当音频开始播放,您在时间轴上的每个动作设置超时。这需要你的音频当然没有任何延迟播放。

What you could do is script the timeline in javascript. When the audio starts to play, you set timeouts for each action on the timeline. This will require your audio to play without any delays of course.

这将是这个样子:

<div>one</div> <div>two</div> <div>three</div> <script> // this is the timeline var actions = [ { time : 1, action : function() { $('div:eq(0)').css('color','red') } }, { time : 1.5, action : function() { $('div:eq(1)').css('color','green') } }, { time : 2, action : function() { $('div:eq(2)').css('color','blue') } } ]; $(document).ready( function() { // execute the timeline for( var i in actions ) { setTimeout( actions[i].action, actions[i].time * 1000 ); } }); </script>

更多推荐

文本高亮显示在jQuery的音频同步

本文发布于:2023-11-30 19:24:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1651215.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本   音频   高亮   jQuery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!