2016-08-25 8 views
0

ビデオ再生リストを読み込むためにhapyakを使用しています。ユーザーが再生速度を増減できるカスタムスピードボタンを追加しました。 (1回クリックすると、最も遅い100%から80%である、ビデオの5%を遅くする)ビデオスピード変数はリセットされませんが、以前の効果も発生していませんか?

遅いです。

ノーマルクリックするとビデオが100%に戻ります。

ファスト遅いですが高速ですが、最大150%です。ビデオの変更(なしページのリロード)ボタンは、現在の番号(通常は150%)に滞在するとき

は、基本的に何が起こっていることですが、効果が映像上に存在しません。より速く再生ボタンをクリックすると、何もしないが、あなたがクリックした場合、それは150%のペースでビデオを継続し、より速く再生するために戻ってクリックして、145パーセントにそれをドロップする「遅く遊び」でしょう。

速度変数と再生リスト全体に持ちこたえる効果の両方を得る方法はありますか?

var currentSpeed = 1; 
    var fadeout_timer = setTimeout(function() { 
    $("#videoSpeed").fadeOut(); 
    }, 1600); 

    function updateSpeed() { 
    document.getElementById("videoSpeedCounter").innerHTML = (Math.round(currentSpeed * 100)) + "%"; 

    if ($("#videoSpeed").is(":hidden")) { 
     $("#videoSpeed").fadeIn(); 
    } 

    // Fade out after 1600ms from last click -- clearTimeout resets the fadeout timer. 
    clearTimeout(fadeout_timer); 

    fadeout_timer = setTimeout(function() { 
     $("#videoSpeed").fadeOut(); 
    }, 1600); 
    return false; 

    } 

    function speedIncrease() { 
    if (currentSpeed < 1.50) { 
     currentSpeed = currentSpeed + 0.05; 
     hapyak.playlist.get()._player.playbackRate(currentSpeed); 
     updateSpeed(); 
    } 
    return false; 
    } 

    function speedDecrease() { 
    if (currentSpeed > .8) { 
     currentSpeed = currentSpeed - 0.05; 
     hapyak.playlist.get()._player.playbackRate(currentSpeed); 
     updateSpeed(); 
    } 
    return false; 
    } 

    function resetSpeed() { 
    currentSpeed = 1; 
    hapyak.playlist.get()._player.playbackRate(currentSpeed); 
    updateSpeed(); 
    } 

    function nextVideo() { 
     currentSpeed = currentSpeed 
     hapyak.playlist.get()._player.playbackRate(currentSpeed); 

    } 

    var hapyakPlaylist = hapyak.playlist.get(); 
    console.log("Playlists: " + hapyakPlaylist); 

は理論的には、私はちょうどそれが先頭にリセットされませんので、それはcurrentSpeedを救う持ってする方法が必要と考えています。

<div class="video-speed-buttons-container"> 
    <a onclick="speedDecrease()"><div class="video-speed-button first">Play slower</div></a> 
    <a onclick="resetSpeed()"><div class="video-speed-button">Normal speed</div></a> 
    <a onclick="speedIncrease()"><div class="video-speed-button">Play faster</div></a> 
    <div class="video-speedometer" id="videoSpeed">Speed: <span id="videoSpeedCounter">100%</span></div> 
</div> 

答えて

0

これはHapYakのカイルです。 HapYak Viewerオブジェクトは、playbackRateが設定されているプレイヤーへの参照を保持します。別のビデオに変更すると、ビューアオブジェクトが破棄され、新しく読み込まれたビデオの新しいインスタンスがセットアップされます。何をする必要がありますと、現在のビューアオブジェクトへの参照を取得し、playbackRateにプレイリスト内の異なるビデオが再生されるたびにリセットされます。

あなたはhapyak.instances.viewerコレクションからの参照を取得することができます。あなたがあなたのページ/実装に私のリンクを送信した場合

私はより具体的な例を支援しようとすることができます。

関連する問題