How I can retrieve and play audio file in cakephp

回眸只為那壹抹淺笑 提交于 2020-01-16 18:32:30

问题


I am uploading audio files using cakephp app. I can move file successfully to folder and can update its path in database too. But I can not retrive that file successfully. server reply with 206 Partial Content AND some times with 304 Not Modified status. can anyone help me to figure out why server respondig with such status?


回答1:


You are using chromium. Mp3 is not supported in both chromium and firefox for ubuntu. You can convert mp3 to ogg to play them in chromium and firefox. Or you can install chrome if you don't want to convert mp3 to ogg. If you want to convert them, you can do it with this shell script

#!/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;

But you only problem is that chromium and firefox will not support mp3, they will support only ogg in ubuntu.



来源:https://stackoverflow.com/questions/19629469/how-i-can-retrieve-and-play-audio-file-in-cakephp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!