我如何在cakephp中检索和播放音频文件

时间:2013-10-28 07:46:33

标签: apache2 cakephp-2.0

我正在使用cakephp app上传音频文件。我可以将文件成功移动到文件夹,也可以在数据库中更新其路径。但我无法成功地检索该文件。服务器回复206 Partial Content,有时回复304 Not Modified状态。任何人都可以帮我弄清楚为什么服务器响应这种状态?

1 个答案:

答案 0 :(得分:1)

你正在使用铬。对于ubuntu,chrome和firefox都不支持Mp3。您可以将mp3转换为ogg,以便在chrome和firefox中播放它们。或者,如果您不想将mp3转换为ogg,则可以安装chrome。如果要转换它们,可以使用此shell脚本

#!/bin/bash

echo "The script convert mp3->ogg or ogg->mp3.";
echo "The script takes one parameter: ";
echo "[mp3ogg] - converting mp3->ogg";
echo "[oggmp3] - converting ogg->mp3";


if [ "$1" = "" ]; then
    echo "";
    echo "Argument does not exist!!!";
    exit 102;
fi


if [ "$1" = "mp3ogg" ]; then
    for file in *.mp3; do
         avconv -i "$file" "`echo '../ogg/'${file%.mp3}.ogg`";
    done
    exit 0;
fi

if [ "$1" = "oggmp3" ]; then
    for file in *.ogg; do
         avconv -i "$file" -acodec libmp3lame "`echo ${file%.ogg}.mp3`";
    done
    exit 0;
fi


exit 104;

但你唯一的问题是chrome和firefox不支持mp3,他们只支持ubuntu中的ogg。