Uploading an audio recording to mysql and playing in website

后端 未结 8 1515
生来不讨喜
生来不讨喜 2020-12-03 09:44

I have an upload phone app that uploads either images or audio recordings. The image can be uploaded to a mysql database and displayed no problem in a webpage, The problem i

相关标签:
8条回答
  • 2020-12-03 09:49

    Yes, the audio file is just a binary file and can be saved an a blob data field. Then recalled from a query. Then play it any way you want.You may be better off saving the audio file to local storage and keeping track of where you put it in the database.

    0 讨论(0)
  • 2020-12-03 09:51

    Yes.

    // Get the file contents from the database...
    
    // Assuming a DB wrapper here.
    $results = $db->query('SELECT `file_contents` FROM `mp3s` WHERE `id` = :id', array(':id' => $_GET['id'])->execute();
    $fileContents = $results[0]['file_contents'];
    
    // Send appropriate headers for content type and force download
    header('Content-Type: mpeg/audio');
    header('Content-Disposition: attachment; filename="BullsOnPowerade.mp3"')
    echo $fileContents;
    
    0 讨论(0)
  • 2020-12-03 09:53

    You could use Flash on the web page. On 2.3 you could use the audio tag. See HTML5 <audio> tag on Android .

    0 讨论(0)
  • 2020-12-03 09:55

    If you want to embed a video on your webpage, you can read this support article on Apple's website and this is a list of tag attributes... Hope this can help! :)

    0 讨论(0)
  • 2020-12-03 10:01

    This is a really really broad question, but here are some starter tips:

    • Look at the apache httpcomponents project for a good HTTP library, including the ability to do multi-part MIME attachments and POST requests
    • Take a look at the PHP docs for handling file uploads
    • If you don't want your app to lock up during uploads, I would encourage you to look at the android AsyncTask pattern and supporting classes so that your UI thread does not block during the uploads
    • There are any number of ways to play an audio file in a web page (Flash being the most prevalent probably)
    0 讨论(0)
  • 2020-12-03 10:12

    easiest method is to use nowadays is HTML5 tag..
    html5 audio
    <audio src="horse.ogg" controls="controls"> Your browser does not support the audio element. </audio>

    using google mp3 player - replace mp3_file_url with the actual url of the file... although im not sure if it runs .amr files
    <embed type="application/x-shockwave-flash" flashvars="audioUrl=MP3_FILE_URL" src="http://www.google.com/reader/ui/3523697345-audio-player.swf" width="400" height="27" quality="best"></embed>

    EDIT:

    quicktime - change WIDTH and HEIGHT in both cases.. and choose false/true in the params you want <OBJECT classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' width="_WIDTH_" height="_HEIGHT_"codebase='http://www.apple.com/qtactivex/qtplugin.cab'>
    <param name='src' value="apr.amr">
    <param name='autoplay' value="true/false">
    <param name='controller' value="true/false">
    <param name='loop' value="true/false">
    <EMBED src="apr.amr" width="_WIDTH_" height="_HEIGHT_" autoplay="true" controller="true" loop="true" pluginspage='http://www.apple.com/quicktime/download/'>
    </EMBED>
    </OBJECT>

    0 讨论(0)
提交回复
热议问题