php/html5播放列表使用glob()
php/html5 playlist using glob()
我正在使用php glob()获取歌曲文件夹中的所有歌曲然后使用array_rand来获得一首随机歌曲,然后使用foreach循环来循环歌曲。不管怎样,我都可以让工作
<!DOC TYPE HTML>
<html>
<head>
<title>ymp</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<h1>YMP RADIO</h1>
<?php require ("dropmenu.html"); ?>
<?php
$music = glob("songs/*"); // get all files in the music directory
shuffle($music);
foreach ($music as $song){ // try and loop a random songs
}
var_dump($song)
?>
<audio id="player" src="<?php $song ?>" type="audio/mpeg"></audio>
<audio id="player" src="<?php $song ?>" type="audio/ogg"></audio>
<br /><br /><br />
<div>
<table border="1px" >
<tr>
<td class="tdpage" >
<img src="ymplogo5.jpg" alt="" />
<p><button class="botton"; onclick="document.getElementById('player').play()">Play</button>
<button class="botton"; onclick="document.getElementById('player').pause()">Pause</button>
<button class="botton"; onclick="document.getElementById('player').volume+=0.1">Volume up </button>
<button class="botton"; onclick="document.getElementById('player').volume-=0.1">Volume down</button>
</td>
</tr>
</table>
</div>
<br /><br /><br />
</body>
</html>
我相信你想以随机顺序循环它们,在这种情况下使用shuffle()
$music = glob("songs/"); // get all files in the music directory
shuffle($music);
foreach ($music as $song){
//code
}
您当前的glob模式只是匹配一个目录。
要使匹配目录中的所有文件,请使用通配符"*"。
$music=glob("songs/*");
相关文章:
- Canvas Html5绘图应用程序,移动画布会导致重大问题
- 如何使用phaser使html5游戏在移动设备浏览器上运行
- HTML5音频加载和播放获胜'我不能在iPad上工作
- HTML5页面底部棒
- Google/html5语音识别JavaScript SDK Chrome网络工具包SpeechRecognition
- Is onfling available for html, html5
- 为什么HTML5拖放的目标是孩子?(可排序列表)
- 安卓平台上的QWebView HTML5地理位置
- HTML5在画布中加载较小的图像并保存实际大小的图像
- 如何检查用户在html5视频播放器中观看了完整的视频
- 使用具有内联样式的tidy-html5
- 从所有元素中删除HTML5验证
- javascript:将数据库中的数据插入到html5文本字段中
- html5视频中的Youtube类型注释
- JavaScript HTML5画布未显示
- 是否可以为HTML5输入滑块触发oninput事件
- 如何使用HTML5与UDP套接字通信
- AngularJS ui路由器html5模式中断路由
- Possibile使用Manifest v2下的HTML5地理位置API将lat/long转换为国家/地区
- php/html5播放列表使用glob()