【问题标题】:How to host an mp3 player that accepts mp3 file as GET request如何托管接受 mp3 文件作为 GET 请求的 mp3 播放器
【发布时间】:2019-06-15 12:08:45
【问题描述】:

我想在我的 SiteGround 托管站点上放置一个 mp3 播放器,它允许我通过将第三方 mp3 url 作为参数传递来播放文件。我需要播放/暂停/时间线/音量控制。

所以我尝试了这个,但它不起作用:

<?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>

页面与播放器一起加载但不播放。

【问题讨论】:

  • Stackoverflow 不是免费的代码编写服务。
  • 我不是在寻找免费代码,而是在寻找建议的“解决方案”。 Stackoverflow 只提供了几个可能相关的类别,我认为这与编码比其他选项更相关。您有更合适的方式或方法来请求帮助的建议吗?并不是我自己在这里和其他地方都没有寻找过答案。 @DerekPollard
  • 这应该可以。

标签: javascript php html


【解决方案1】:

我敢肯定,这不是最优雅的,但这符合我的目的:

<?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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多