• <bdo id='Xb2Dr'></bdo><ul id='Xb2Dr'></ul>

      <small id='Xb2Dr'></small><noframes id='Xb2Dr'>

        <tfoot id='Xb2Dr'></tfoot><legend id='Xb2Dr'><style id='Xb2Dr'><dir id='Xb2Dr'><q id='Xb2Dr'></q></dir></style></legend>
      1. <i id='Xb2Dr'><tr id='Xb2Dr'><dt id='Xb2Dr'><q id='Xb2Dr'><span id='Xb2Dr'><b id='Xb2Dr'><form id='Xb2Dr'><ins id='Xb2Dr'></ins><ul id='Xb2Dr'></ul><sub id='Xb2Dr'></sub></form><legend id='Xb2Dr'></legend><bdo id='Xb2Dr'><pre id='Xb2Dr'><center id='Xb2Dr'></center></pre></bdo></b><th id='Xb2Dr'></th></span></q></dt></tr></i><div id='Xb2Dr'><tfoot id='Xb2Dr'></tfoot><dl id='Xb2Dr'><fieldset id='Xb2Dr'></fieldset></dl></div>

        PHP 流媒体 MP3

        PHP Streaming MP3(PHP 流媒体 MP3)

      2. <i id='yY5Xn'><tr id='yY5Xn'><dt id='yY5Xn'><q id='yY5Xn'><span id='yY5Xn'><b id='yY5Xn'><form id='yY5Xn'><ins id='yY5Xn'></ins><ul id='yY5Xn'></ul><sub id='yY5Xn'></sub></form><legend id='yY5Xn'></legend><bdo id='yY5Xn'><pre id='yY5Xn'><center id='yY5Xn'></center></pre></bdo></b><th id='yY5Xn'></th></span></q></dt></tr></i><div id='yY5Xn'><tfoot id='yY5Xn'></tfoot><dl id='yY5Xn'><fieldset id='yY5Xn'></fieldset></dl></div>
          <bdo id='yY5Xn'></bdo><ul id='yY5Xn'></ul>
          <legend id='yY5Xn'><style id='yY5Xn'><dir id='yY5Xn'><q id='yY5Xn'></q></dir></style></legend>
          • <tfoot id='yY5Xn'></tfoot>

            <small id='yY5Xn'></small><noframes id='yY5Xn'>

                <tbody id='yY5Xn'></tbody>

                  本文介绍了PHP 流媒体 MP3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的情况与提问的人非常相似:我可以使用 PHP 提供 MP3 文件吗?基本上我试图保护 mp3 文件不被直接下载,所以用户必须先通过 php 来获得身份验证.这是我的代码:

                  I have a very similar situation to the person who asked: Can I serve MP3 files with PHP? Basically I am trying to protect mp3 files from direct download, so users have to go through php to get authenticated first. Here's my code:

                  header('Content-type: audio/mpeg');
                  header('Content-length: ' . filesize($file));
                  header('X-Pad: avoid browser bug');
                  Header('Cache-Control: no-cache');
                  header("Content-Transfer-Encoding: binary"); 
                  header("Content-Type: audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3");
                  readfile($file);
                  

                  这是我的问题:该文件仅播放开头的一小部分(通过浏览器中的 Quicktime)然后停止 - Quicktime 似乎认为文件的长度仅与它管理的块一样长下载.当我重新加载时 - 它会播放一个稍微大一点的块 - 无论它设法下载到那个点.

                  Here's my problem: The file only plays a very small chunk of the beginning (via Quicktime in the browser) and then stops - Quicktime seems to think the length of the file is only as long as the chunk it managed to download. When I reload - it plays a slightly larger chunk - whatever it managed to download up to that point.

                  这是我发送的标头中的问题吗?我将如何流式传输这样的文件?如果 swf 正在从该文件中读取,会不会有问题?

                  Is that a problem in the headers I am sending? How would I stream such a file? Is it a problem if an swf is reading from that file?

                  谢谢!

                  谢谢大家的回答.尽管这些东西都不能完全解决问题,但它们中的许多都将我引向了正确的方向.非常感激.有关完整的解决方案,请参阅下面的答案

                  推荐答案

                  这就是诀窍.

                  $dir = dirname($_SERVER['DOCUMENT_ROOT'])."/protected_content";
                  $filename = $_GET['file'];
                  $file = $dir."/".$filename;
                  
                  $extension = "mp3";
                  $mime_type = "audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3";
                  
                  if(file_exists($file)){
                      header('Content-type: {$mime_type}');
                      header('Content-length: ' . filesize($file));
                      header('Content-Disposition: filename="' . $filename);
                      header('X-Pad: avoid browser bug');
                      header('Cache-Control: no-cache');
                      readfile($file);
                  }else{
                      header("HTTP/1.0 404 Not Found");
                  }
                  

                  这篇关于PHP 流媒体 MP3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  <legend id='DDFMI'><style id='DDFMI'><dir id='DDFMI'><q id='DDFMI'></q></dir></style></legend>
                  <tfoot id='DDFMI'></tfoot>
                  <i id='DDFMI'><tr id='DDFMI'><dt id='DDFMI'><q id='DDFMI'><span id='DDFMI'><b id='DDFMI'><form id='DDFMI'><ins id='DDFMI'></ins><ul id='DDFMI'></ul><sub id='DDFMI'></sub></form><legend id='DDFMI'></legend><bdo id='DDFMI'><pre id='DDFMI'><center id='DDFMI'></center></pre></bdo></b><th id='DDFMI'></th></span></q></dt></tr></i><div id='DDFMI'><tfoot id='DDFMI'></tfoot><dl id='DDFMI'><fieldset id='DDFMI'></fieldset></dl></div>

                        <tbody id='DDFMI'></tbody>

                      1. <small id='DDFMI'></small><noframes id='DDFMI'>

                          <bdo id='DDFMI'></bdo><ul id='DDFMI'></ul>