उपयोग में आसानी के लिए, मैं jQuery का एक संयोजन और कुछ भी है जहाँ आप HTML के साथ मीडिया एकीकृत करना चाहते हैं के लिए Popcorn.js, और वीजा विपरीत सलाह देते हैं। उदाहरण के लिए यह jsfiddle post देखें।
रिकॉर्ड के लिए, कभी jsfiddle चाहिए गायब हो जाते हैं, यहाँ कोड है:
एचटीएमएल
<audio id="greeting" src="https://dl.dropboxusercontent.com/u/17154625/greeting.ogg" controls></audio>
<div id="text">
<span id="w1" class="word" data-start="1.0">Hello</span>,
and <span id="w2" class="word" data-start="2.0">welcome</span>
to Stack <span id="w3" class="word" data-start="3.0">Overflow</span>.
Thank you for asking your question.
</div>
सीएसएस
.word {
color: red;
}
.word:hover, .word.selected {
color: blue;
cursor: pointer;
}
जे एस
var pop = Popcorn("#greeting");
var wordTimes = {
"w1": { start: 1, end: 1.5 },
"w2": { start: 1.9, end: 2.5 },
"w3": { start: 3, end: 4 }
};
$.each(wordTimes, function(id, time) {
pop.footnote({
start: time.start,
end: time.end,
text: '',
target: id,
effect: "applyclass",
applyclass: "selected"
});
});
pop.play();
$('.word').click(function() {
var audio = $('#greeting');
audio[0].currentTime = parseFloat($(this).data('start'), 10);
audio[0].play();
});
सुपर - बहुत बहुत धन्यवाद ! मेरे हाथों से मेरा हाथ पूरा हो जाएगा ... मुझे आशा है कि अगर मुझे अनुवर्ती करने की ज़रूरत है तो आप मुझे शामिल करेंगे। चीयर्स! – shecky
पी। jsfiddle डेमो में आवाज उत्पन्न करने के लिए आपने क्या उपयोग किया? – shecky
मेरे मैक पर, मैंने 'हैलो' कहा, और स्टैक ओवरफ़्लो में आपका स्वागत है। आपका प्रश्न पूछने के लिए धन्यवाद। " -o greet.ogg' – thisgeek