html5 audio player - jquery toggle click play/pause?

前端 未结 15 2265
南笙
南笙 2020-11-28 06:24

i wonder what i\'m doing wrong?

    $(\'.player_audio\').click(function() {
    if ($(\'.player_audio\').paused == false) {
        $(\'.player_audio\').paus         


        
相关标签:
15条回答
  • 2020-11-28 06:48

    if anyone else has problem with the above mentioned solutions, I ended up just going for the event:

    $("#jquery_audioPlayer").jPlayer({
        ready:function () {
            $(this).jPlayer("setMedia", {
                mp3:"media/song.mp3"
            })
            ...
        pause: function () {
          $('#yoursoundcontrol').click(function () {
                $("#jquery_audioPlayer").jPlayer('play');
          })
        },
        play: function () {
        $('#yoursoundcontrol').click(function () {
                $("#jquery_audioPlayer").jPlayer('pause');
        })}
    });
    

    works for me.

    0 讨论(0)
  • 2020-11-28 06:51

    Simple Add this Code

            var status = "play"; // Declare global variable
    
            if (status == 'pause') {
                status='play';                
            } else {
                status = 'pause';     
            }
            $("#audio").trigger(status);    
    
    0 讨论(0)
  • 2020-11-28 06:52

    I did it inside of a jQuery accordion.

    $(function() {
            /*video controls*/
                $("#player_video").click(function() {
                  if (this.paused == false) {
                      this.pause();
                  }
                });
            /*end video controls*/
    
            var stop = false;
            $("#accordion h3").click(function(event) {
                if (stop) {
                    event.stopImmediatePropagation();
                    event.preventDefault();
                    stop = false;
                }
                $("#player_video").click();
            });
    
        });
    
    0 讨论(0)
提交回复
热议问题