最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery jPlayer change media not working - Stack Overflow

programmeradmin2浏览0评论

I am trying to change the song on jQuery, using the developers guide, i have e 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?

I am trying to change the song on jQuery, using the developers guide, i have e 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?

Share asked May 19, 2012 at 1:24 JimmyBanksJimmyBanks 4,7389 gold badges48 silver badges73 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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.

发布评论

评论列表(0)

  1. 暂无评论