日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

网页录音解决方案 FlashWavRecorder For Website API 关键地方已注释

發(fā)布時(shí)間:2025/4/16 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 网页录音解决方案 FlashWavRecorder For Website API 关键地方已注释 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

【原創(chuàng)文章】,轉(zhuǎn)載請(qǐng)注明作者博客:www.92ez.com或博客園地址

作者:KBdancer

前段時(shí)間由于項(xiàng)目需要,客戶需求中有一條是要實(shí)現(xiàn)WEB端的錄音功能,起初想到的是HTML5實(shí)現(xiàn),經(jīng)過幾輪百度之后無(wú)果。

PS:谷歌時(shí)不時(shí)被墻,非必要時(shí)請(qǐng)不要使用百度搜索。

谷歌幾番后發(fā)現(xiàn)一個(gè)實(shí)現(xiàn)錄音的flash+js的插件,之前一直糾結(jié)的難題終 于解決。這款插件可以高度定制,自帶眾多與js交互的接口,(本人對(duì)action script實(shí)在是不怎么了解)能夠輕松的使用js來(lái)控制錄音的開始與停止和回放。對(duì)此款插件熟悉之后偶然在github上發(fā)現(xiàn)此插件的作者公開的API 文檔,寫的很詳細(xì)。

話不多說(shuō),奉上API文檔,雖然是英文的,但是應(yīng)該不會(huì)影響閱讀,關(guān)鍵的幾個(gè) 方法我都已經(jīng)用中文注釋了(大概的意思翻譯了一下,如有不對(duì)請(qǐng)告訴我)。先暫時(shí)把API文檔發(fā)出,后面有時(shí)間的時(shí)候整理下DEMO也上傳一下,希望能夠幫 助需要的猿們(因?yàn)橹罢伊撕镁脹]找到好的解決方案,費(fèi)了好多時(shí)間,猿們找資料都很辛苦)

有圖有真相:

Simple Microphone Recorder

Use flash to record audio data from a microphone. Converts the audio data to a WAV file. Uploads the WAV file to the server. The WAV file is POSTed as a multpart form-data request. Additional fields can be added to the request, such as authenticity_token, (response) formart, etc... The flash recorder creates serveral external interfaces. This allows the recorder to be controlled through javascript. Only the save button must be clicked inside the flash application, see?Upload and download require user interaction?for more information.

Embedding the Recorder

[javascript] view plaincopy
  • <script>??
  • ??var?appWidth?=?24;??
  • ??var?appHeight?=?24;??
  • ??var?flashvars?=?{'event_handler':?'microphone_recorder_events',?'upload_image':?'images/upload.png'};??
  • ??var?params?=?{};??
  • ??var?attributes?=?{'id':?"recorderApp",?'name':??"recorderApp"};??
  • ??swfobject.embedSWF("recorder.swf",?"flashcontent",?appWidth,?appHeight,?"10.1.0",?"",?flashvars,?params,?attributes);??
  • </script>??
  • The event_handler is a javascript function that is called from the flash application. The first argument to the event_handler is always the name of the event as a string. The other arguments may vary depending on the event.

    Flash vars

    event_handler: javascript function called from the flash application

    upload_image: image used as the save button

    font_color: font color for the save text, default #0000EE

    font_size: font size for the save text, default 12

    save_text: text used for the save link, default Save

    background_color: background color of the flash app, only used when using a save link

    if upload_image failes recorder will use a save link instead

    Flash Events

    ready: recorder is ready for use

    • width - save button's width
    • height - save button's height

    no_microphone_found: no microphone was found when trying to record

    microphone_user_request: user needs to allow the recorder to access the microphone

    microphone_connected: user allowed access to the microphone

    • microphone - Microphone object from flash, can be used to get the name of the microphone, i.e. microphone.name

    microphone_not_connected: user denied access to the microphone,?at this point the recorder CAN NOT be used until the user reloads the page

    recording: recording audio data from the microphone

    • name - of the recording that was specified when record was called

    recording_stopped: stopped recording audio data

    • name - of the recording that was specified when record was called
    • duration - of the recording as a floating point value in seconds

    playing: playing back the recorded audio data

    • name - of the recording that was specified when play was called

    playback_started: useful for synchronizing playback with animation(注:用于同步回放與動(dòng)畫

    • name - of the recording that was specified when play was called
    • latency - number of milliseconds before playback starts?(在回放之前延遲多久)

    stopped: stopped playing back the recorded audio data(注:停止播放錄音?)

    • name - of the recording that was specified when play was called

    save_pressed: save button was pressed in the recorder, good place to update the form data in the recorder(注:按下保存按鈕)

    • name - of the recording

    saving: upload is in progress(注:正在上傳?)

    • name - of the recording

    saved: upload is complete(注:上傳錄音成功?)

    • name - of the recording
    • response - from the server as a string, can use var data = jQuery.parseJSON(arguments[2]) if response is json

    save_failed: the recorder failed to upload the audio data(注:保存失敗?)

    • name - of the recording
    • error - message as a string

    save_progress: upload progress(注:上傳進(jìn)度)

    • name - of the recording
    • bytes_loaded - number of bytes uploaded
    • bytes_total - number of bytes to upload

    Recorder JS Interface

    record: tells the recorder to record audio data from the microphone

    • name - of the recording, basically a reference to the recording, use this name for playback
    • filename - [optional] if saving the file on the server, this is the name of the file to save the WAV file as

    will also stop recording if currently recording

    playBack: tells the recorder to playback the recorded audio(注:回放錄音)

    • name - of the recording

    will stop playback if called before playback ends

    stopPlayBack: tells the recorder to stop recording or playback(注:停止回放)

    duration: returns the duration of the recording(注:返回錄音持續(xù)時(shí)間?)

    • name - of the recording

    init: setup the recorder for saving recordings

    (注:為保存錄音做準(zhǔn)備)

    • url - upload url
    • (注:上傳的url地址)
    • field_name - name of the form field for the WAV file
    • (注:WAV文件在表單中的name)
    • form_data - additional form data. Specified as an array of name/value pairs. ex: [{"name": 'authenticity_token', "value": "xxxx"}, {"name": "format", "value": "json"}]
    • (注:表單數(shù)據(jù) 指定一個(gè)鍵值對(duì) 數(shù)組?)

    permit: show the permissions dialog for microphone access, make sure the flash application is large enough for the dialog box before calling this method. Must be at least 240x160.

    (注:顯示權(quán)限許可對(duì)話框 大小至少 240X160)

    show: show the save button(注:顯示保存按鈕)

    hide: hide the save button(注:隱藏保存按鈕)

    update: update the form data

    • form_data - additional form data, in jQuery you can use $('#upload_form').serializeArray()
    • (注:表單數(shù)據(jù) ?額外的表單數(shù)據(jù))

    configure: configure microphone settings

    • rate - at which the microphone captures sound, in kHz. default is 22. Currently we only support 44 and 22.
    • (注:比特率 ?麥克風(fēng)捕獲聲音的默認(rèn)比特率為22kHz ,目前只支持44kHz和22kHz)
    • gain - the amount by which the microphone should multiply the signal before transmitting it. default is 100
    • (注:增益 ?麥克風(fēng)在傳輸之前增加信號(hào)的總量,默認(rèn)是100)
    • silence_level - amount of sound required to activate the microphone and dispatch the activity event. default is 0
    • (注:靜音等級(jí) ?此設(shè)置是設(shè)置麥克風(fēng)在音頻高于特定值時(shí)才激活錄音,有利于節(jié)約帶寬 默認(rèn)是0,表示長(zhǎng)連接)
    • silence_timeout - number of milliseconds between the time the microphone stops detecting sound and the time the activity event is dispatched. default is 4000
    • (注:靜音時(shí)間 ?描述靜音多久之后自動(dòng)激活麥克風(fēng)錄音 默認(rèn)4000)

    setUseEchoSuppression: use echo suppression ? ??(注:使用回聲抑制)

    • yes_no

    setLoopBack: routes audio captured by a microphone to the local speakers?(注:本地?fù)P聲器播放從麥克風(fēng)捕獲到的音頻)

    • yes_no

    getMicrophone: returns the microphone object ? ?(注:返回麥克風(fēng)對(duì)象)

    轉(zhuǎn)載于:https://www.cnblogs.com/cydmk/archive/2013/04/09/3009755.html

    總結(jié)

    以上是生活随笔為你收集整理的网页录音解决方案 FlashWavRecorder For Website API 关键地方已注释的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。