ホームページ >php教程 >php手册 >html网页音乐播放器自带播放列表

html网页音乐播放器自带播放列表

WBOY
WBOYオリジナル
2016-06-13 09:34:592376ブラウズ

基于网页的音乐播放器demo  http://pan.baidu.com/s/1dDgm7HR

自己diy了一个手机端在线音乐播放器演示地址http://shanxi2014.com/zhuandizhi/dom.php

全面支持手机端浏览器。

主要修改引用路径(不要修改文件相对存放地址)

第二就是正则拼接参数了

<script src="/city/js/libs/jquery-1.10.2.min.js"></script>
<script src="/city/js/libs/jquery-ui.min.js"></script>
<script src="/city/js/libs/bootstrap.min.js"></script>

<!-- Style CSS -->
<link href="/city/css/bootstrap.css" media="screen" rel="stylesheet">
<link href="/city/style.css" media="screen" rel="stylesheet">

<!-- General Scripts -->
<script src="/city/js/general.js"></script>

<!-- custom input -->
<script src="/city/js/jquery.customInput.js"></script>

<!-- Placeholders -->
<script src="/city/js/jquery.powerful-placeholder.min.js"></script>
<script><span>
    jQuery(document)</span>.ready(<span>function</span><span>($) {
        </span><span>if</span>($("[placeholder]").size() > 0<span>) {
            $</span>.Placeholder.<span>init();
        }
    });
</span></script>

<!-- CarouFredSel  -->
<script src="js/jquery.carouFredSel-6.2.1-packed.js"></script>

<!-- Lightbox prettyPhoto -->
<link href="css/prettyPhoto.css" rel="stylesheet">
<script src="js/jquery.prettyPhoto.js"></script>

<!-- Video Player -->
<link href="/city/css/video-js.css" rel="stylesheet">
<script src="/city/js/video.js"></script>
<script><span>
    videojs</span>.options.flash.swf = "js/video-js.swf"<span>;
</span></script>

<!-- Audio Player -->
<link href="/city/css/jplayer.css" rel="stylesheet">
<script src="/city/js/jquery.jplayer.min.js"></script>
<script src="/city/js/jplayer.playlist.min.js"></script>
<script type="text/javascript">
    <span>//</span><span><![CDATA[</span>
    $(document).ready(<span>function</span><span>(){

        </span><span>new</span><span> jPlayerPlaylist({
            jPlayer</span>: "#jquery_jplayer_1",<span>
            cssSelectorAncestor</span>: "#jp_container_1"<span>
        }</span>, [<?php <span>if</span>(<span>strlen</span>(<span>$a</span>[2])>6){<span>foreach</span> (<span>$a</span> <span>as</span> <span>$va</span><span>) {
        </span><span>echo</span> <span>$tittle</span>.<span>$va</span><span>;
};}</span>?><span>
        {title</span>:"<div class='item-image'><img  src='http://www.bkjia.com/uploads/allimg/140519/1213052329-0.jpg'  / alt="html网页音乐播放器自带播放列表" ></div>终于等到你",m4a:"http://cc.stream.qqmusic.qq.com/C100003GF7MY2P0fz7.m4a?fromtag=52"},{title:"<div class='item-image'><img  src='http://www.bkjia.com/uploads/allimg/140519/1213052329-0.jpg'  / alt="html网页音乐播放器自带播放列表" ></div>陪你走到底",m4a:"http://cc.stream.qqmusic.qq.com/C100003GX33X2aLY1R.m4a?fromtag=52"},{title:"<div class='item-image'><img  src='http://www.bkjia.com/uploads/allimg/140519/1213052329-0.jpg'  / alt="html网页音乐播放器自带播放列表" ></div>如果爱下去",m4a:"http://cc.stream.qqmusic.qq.com/C10000395SnV0rl1hZ.m4a?fromtag=52"},{title:"<div class='item-image'><img  src='http://www.bkjia.com/uploads/allimg/140519/1213052329-0.jpg'  / alt="html网页音乐播放器自带播放列表" ></div>天下无双",m4a:"http://cc.stream.qqmusic.qq.com/C100002sjtbA1K4ASF.m4a?fromtag=52"<span>} 
        ]</span>,<span> {
            swfPath</span>: "js",<span>
            supplied</span>: "oga, mp3,m4a",<span>
            wmode</span>: "window",<span>
            smoothPlayBar</span>: <span>false</span>,<span>
            keyEnabled</span>: <span>false</span><span>
        });
    });
    </span><span>//</span><span>]]></span>
</script>

搜狗音乐地址获取

<?<span>php
</span><span>$query</span>=<span>$_GET</span>['s'<span>];
</span><span>$q</span>= mb_convert_encoding(<span>$query</span>,"GBK","UTF-8"<span>);
</span><span>$ew</span>=<span>urlencode</span>(<span>$query</span><span>);
</span><span>$jsrc</span> = "https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q={<span>$ew</span>}"<span>;
</span><span>$json</span> = <span>file_get_contents</span>(<span>$jsrc</span><span>);
</span><span>$jset</span> = json_decode(<span>$json</span>, <span>true</span><span>);
</span><span>$src</span>=<span>$jset</span>["responseData"]["results"][0]["url"<span>];
</span><span>$image</span>="<div class='item-image'><img  src='http://www.bkjia.com/uploads/allimg/140519/1213052329-0.jpg'  / alt="html网页音乐播放器自带播放列表" ></div>"<span>;
</span><span>$query</span>=<span>urlencode</span>(<span>$query</span><span>);
</span><span>$url</span>="http://mp3.sogou.com/music.so?query={<span>$query</span>}"<span>;
</span><span>function</span> curl_get(<span>$url</span>, <span>array</span> <span>$get</span> = <span>NULL</span>, <span>array</span> <span>$options</span> = <span>array</span><span>())
{
    </span><span>$defaults</span> = <span>array</span><span>(
            CURLOPT_URL </span>=> <span>$url</span>. (<span>strpos</span>(<span>$url</span>, '?') === <span>FALSE</span> ? '?' : ''). <span>http_build_query</span>(<span>$get</span>),<span>
            CURLOPT_HEADER </span>=> 0,<span>
            CURLOPT_RETURNTRANSFER </span>=> <span>TRUE</span>,<span>
            CURLOPT_TIMEOUT </span>=> 4<span>
    );

    </span><span>$ch</span> =<span> curl_init();
    curl_setopt_array(</span><span>$ch</span>, (<span>$options</span> + <span>$defaults</span><span>));
    </span><span>if</span>( ! <span>$result</span> = curl_exec(<span>$ch</span><span>))
    {
        </span><span>trigger_error</span>(curl_error(<span>$ch</span><span>));
    }
    curl_close(</span><span>$ch</span><span>);
    </span><span>return</span> <span>$result</span><span>;
}
</span><span>$html</span>=curl_get(<span>$url</span>,<span>array</span>(), <span>array</span><span>());
</span><span>iconv</span>("GB2312","UTF-8//IGNORE",<span>$html</span><span>);

    </span><span>$c</span>="+onclick=\"qqDownload.*http://cc\.stream\.qqmusic\.qq\.com.*\.m4a\?fromtag=52+i"<span>;
    </span><span>$elemment</span>=<span>$html</span><span>;
    
    </span><span>if</span> (<span>preg_match_all</span>(<span>$c</span>, <span>$elemment</span>,<span>$matches</span>)){<span>$i</span>=0<span>;

</span><span>$a</span> = <span>array</span><span>();
</span><span>$t</span>=<span>array</span><span>();
</span><span>foreach</span> (<span>$matches</span>[0] <span>as</span> <span>$val</span><span>) {
        </span><span>$val</span>=<span>explode</span>("@@", <span>$val</span>, 11<span>);
        </span><span>$t</span>[<span>$i</span>]="<a href=\"{<span>$val</span>[10]}\" class=\"btn btn-red btn-round\"><span >{<span>$val</span>[1]}</span></a><br/>"<span>;
        </span><span>$i</span>++<span>;
                </span><span>$val</span>[1]=<span>$image</span>.<span>$val</span>[1<span>];
        </span><span>$a</span>[<span>$i</span>]="{title:\"{<span>$val</span>[1]}\",". "m4a:\"{<span>$val</span>[10]}\"},"<span>;
                    
    }    
}

</span>?>

 

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。