1

jPlayerを使用する変更されたプレーヤーがページにあり、カスタムホイールボタンをボリューム関数にバインドしたい:

プレイヤーページ

$musicPlayer.jPlayer({
                            swfPath: "js/jplayer/",
                            solution: 'flash,html',
                            supplied: 'm4a, oga, mp3',
                            preload: 'metadata',
                            volume: 0.8,
                            muted: false,
                            cssSelectorAncestor: "#jp_container_N",
                            cssSelector: {
                                play: '.jp-play',
                                pause: '.jp-pause',
                                seekBar: '.jp-seek-bar',
                                playBar: '.jp-play-bar',
                            },
                            errorAlerts: false,
                            warningAlerts: false,
                            ready: function () {
                              $(this).jPlayer("setMedia", {
                                mp3: $first_song,
                                solution: 'flash, html',
                              });
                            },
                        }).bind($.jPlayer.event.ended, function(event){
                            var $o = $('.selected').next('li'),$json = $.parseJSON($o.find('img').attr('data-src'));
                            if(!$o.is(':last')){
                                playSong($o,$json);
                            }
                        });

                });

カスタムボリュームホイール:

//js code for the metal style wheel - below

        $('#metal .indicator-cw').bind('touchmove', function(event){
            updateMetal();
        });
        $("#metal .indicator-cw").mousemove(updateMetal);

        function updateMetal(){
    var number = $("#metal .result-cw").text();
    var Degrees = parseInt(number);

    $("#rotateit").css({'transform':'rotate(' + (Degrees) + 'deg)', '-webkit-transform':'rotate(' + (Degrees) + 'deg)', '-o-transform':'rotate(' + (Degrees) + 'deg)', '-moz-transform':'rotate(' + (Degrees) + 'deg)', '-ms-transform':'rotate(' + (Degrees) + 'deg)' });

        }
        //js code for the metal style wheel - above

HTML:

<div id="metal">
        <div class="result-cw"></div>
        <div class="indicator-cw1"><img src="img/metal_indicator.png" id="rotateit" class="indicator-cw-img" /></div>
        <div class="indicator-cw"></div>
    </div>

jPlayerの音量をそのホイールボタンに割り当てるにはどうすればよいですか?

4

1 に答える 1

2

jPlayer のドキュメントでは、jPlayer の API にボリューム処理用の機能があることがわかります。

回転角度を 0 ~ 1 の数値に変換するだけです。360 度が最大値であるため、現在の回転角度に (1/360) を掛けて、次のように渡すだけです。 volume メソッドへのパラメータ。

あなたの例では、次のようになります。

var vol = parseInt($("#metal .result-cw").text()) * (1/360);    
$("#player").jPlayer("volume", vol);
于 2013-01-24T12:50:03.640 に答える