[英]How to host an mp3 player that accepts mp3 file as GET request
我想在我的SiteGround托管網站上放置一個mp3播放器,允許我通過傳遞第三方mp3網址作為參數來播放文件。 我需要播放/暫停/時間線/音量控制。
所以我嘗試了這個並不起作用:
<?php
if( $_GET["thefile"]) {
echo '<audio controls>';
echo '<source src="'. $_GET["thefile"]. '" type="audio/mpeg">';
echo '</audio>';
exit();
}
?>
<html>
<body>
<form action = "<?php $_PHP_SELF ?>" method = "GET">
Enter MP3 URL: <input type = "text" name = "thefile" />
<input type = "submit" />
</form>
</body>
</html>
頁面加載播放器但不播放。
我確定,這不是最優雅的,但這符合我的目的:
<?php
if( $_GET["thefile"]) {
$encoded_url = urldecode($_GET["thefile"]);
echo '<audio controls src="'. $encoded_url. '"></audio>';
exit();
}
?>
<html>
<body>
<form action = "<?php $_PHP_SELF ?>" method = "GET">
Enter MP3 URL: <input type = "text" name = "thefile" />
<input type = "submit" />
</form>
</body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.