Cuepoint.jsを使用してHTML5ビデオを特定のテキスト行に対応する時間マーカーにキューするテキストリンクを作成しています。配列に既に書き込まれた時間値を動的に文字列として割り当てることができます。配列から配列を取得するときに、値を整数として再利用するには、parseInt()を使用する必要があります。また、彼らはその後、別の配列にプッシュされているforループ内のリンクに彼らの時間を割り当てる必要があります。ここで私は、コードを実行すると、しかし、私はこのエラーが発生した修正方法 "Uncaught TypeError: 'HTMLMediaElement'の 'currentTime'プロパティを設定できません
var cueTimes = [];
for (var j = 0; j < textItems.length; j++) {
var times = parseInt(timeItems[j]);
cueTimes.push(times);
$(".field-name-field-text-"+(j+1)+" > div > div").click(function(){ cuepoint.setTime(cueTimes[j])});
console.log(cueTimes[j]);
}
コードだ。
Uncaught TypeError: 'HTMLMediaElement'の 'currentTime'プロパティを設定できませんでした:指定されたdouble値は非有限です。
私が知る限り、整数はjQueryによって正しく読み込まれていません。しかし、私はコンソールに時間値を出力すると、整数として表示されます。静的配列インデックス(たとえば、cueTimes [0]の設定)を使用してコードをテストすると、コードが実行され、期待どおりに動作します。
この問題を修正/回避する方法についてのご意見は大変ありがたいです。
ありがとうございます! 。
Cuepoint.prototype.setTime = function(time) {
this.time = time;
this.video.currentTime = time;
return this.video.play();
};
Cuepoint.jsコード:ここ
エラーを促すCuepoint.jSファイルからのラインである
(function() {
/* Cuepoint Coffee. A simple library for HTML5 Video Subtitles and Cuepoints */
/**
* @class Utils
*/
var Cuepoint, Utils, utils;
Utils = (function() {
function Utils() {}
Utils.prototype.log = function(args) {
this.args = args;
if (window.console) {
return console.log(Array.prototype.slice.call(this, arguments));
}
};
return Utils;
})();
/**
* @class Cuepoint
*/
Cuepoint = (function() {
function Cuepoint() {
this.nativeKeys = Object.keys;
}
Cuepoint.prototype.init = function(slides) {
var key, value, _results;
this.slides = slides;
this.subtitles = document.getElementById("subtitles");
this.video = document.getElementById("video");
_results = [];
for (key in slides) {
value = slides[key];
this.addSlide(key, value);
_results.push(this.events.call);
}
return _results;
};
Cuepoint.prototype.events = function() {};
Cuepoint.prototype.currentTime = function() {
return this.video.currentTime;
};
Cuepoint.prototype.update = function(html) {
this.html = html;
return this.subtitles.innerHTML = this.html;
};
Cuepoint.prototype.setTime = function(time) {
this.time = time;
this.video.currentTime = time;
return this.video.play();
};
Cuepoint.prototype.addSlide = function(time, html) {
var self;
this.time = time;
this.html = html;
self = this;
return this.video.addEventListener("timeupdate", function() {
if (this.currentTime >= time && this.currentTime <= time + 0.3) {
return self.update(html);
}
},
false);
};
Cuepoint.prototype.play = function() {
return this.video.play();
};
Cuepoint.prototype.pause = function() {
if (!this.video.paused) {
return this.video.pause();
}
};
return Cuepoint;
})();
utils = new Utils;
window.cuepoint = new Cuepoint;
})呼び出し(この)。
異なり、ここでCURRENTTIMEのは言及しない、単なる「時間」、。あなたはフィドルや少なくともいくつかのHTMLやjQueryの投稿を投稿できますか? –
確かに、エラーが発生するCuepoint.jsコードがあります。元の投稿に追加してください。 – Alpinist1974
hmm ..まだHTMLがありません。ちょうどjavascriptで問題を再現できません...あなたはhttp://www.jsfiddle.netまたはhttp://www.jsbin.comでfiddeを作成できます –