jQuery jPlayer change media not working

試著忘記壹切 提交于 2020-01-03 10:56:08

问题


I am trying to change the song on jQuery, using the developers guide, i have come up with this function:

<script type="text/javascript">
$(document).ready(function(){
    $('.embedinfo').click(function() {
        $("#jquery_jplayer_1").jPlayer( "clearMedia" );
        $("#jquery_jplayer_1").jPlayer({
        ready: function () {
            $(this).jPlayer("setMedia", {
                mp3:"/audio/<?php echo $audioarray[0]['audio']; ?>"

            }).jPlayer("<?php if(empty($auto)){ echo "pause"; }     elseif($auto==1){ echo "play"; } ?>");
        },
        swfPath: "/js/Jplayer.swf",
        supplied: "mp3",
        wmode: "window",
        solution:"flash,html",
        volume:"1"
        });
    });

});

The setMedia function is actually identical to the function i use to set the music initially (which does work), however this function to change the music from a click is not working.

The clearMedia function is working, just the set isnt. Why is it not working?


回答1:


I found a solution

instead of using

$("#jquery_jplayer_1").jPlayer( "clearMedia" );

which removes the media, use

$("#jquery_jplayer_1").jPlayer( "destroy" );

which unbinds all instances of .jPlayer, allowing the media to be updated from scratch.



来源:https://stackoverflow.com/questions/10661567/jquery-jplayer-change-media-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!