0

我正在开发由 HTML 扩展提供支持的音乐。

隐藏()后如何停止播放歌曲;或淡出();函数已被调用?

这是 HTML 和 PHP(是的,安全问题,仍处于开发阶段,所以我会修复所有安全和错误)

<?php
    require "core/database.php";

    $id = $_GET['id'];

    $select_song = mysql_query("SELECT * FROM music_player WHERE song_id='$id'") or die("we got an error");
    $retrive_song = mysql_fetch_array($select_song);
    $song_id = $retrive_song['song_id'];
    $song_path = $retrive_song['song_path'];
    $song_name = $retrive_song['song_name'];
    $band = $retrive_song['band'];
    echo($song_name);


    echo "
    <html>
    <head>
    </head>
    <script src='js/jquery.js'></script>
    <script src='js/custom.js'></script>

        <div id='content' style='display:none;'>
    <audio style=' display:block;' controls>

      <source src='music/$song_path'>
    Your browser does not support the audio element.
    </div>
    </audio>
        <b>Other Songs From $band</b>

    ";
        $select_band = mysql_query("SELECT * FROM music_player WHERE band='$band'");

        while($get_band = mysql_fetch_array($select_band)) {

        $band_song = $get_band['song_name'];
        if($song_name!=$band_song) {
    echo "
    <p> 

    <a href='#' class='songs_link'> $band_song </a> <br>

    </p>
    </html>


    ";
    }
    }

?>

这是 jQuery 做一些自定义更改

$(document).ready(function() {
$('#content').show();


    $('.songs_link').click(function() {

    $('#content').hide();

    });
});

我正在尝试淡出当前歌曲,然后在单击链接后转到用户选择的新歌曲。

4

1 回答 1

0

向音频元素添加 id 并:

(...).fadeOut(function(){
   $('#audio_element').get(0).pause(); // or .stop()
});
于 2013-06-15T13:17:23.143 回答