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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

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

【原創文章】,轉載請注明作者博客:www.92ez.com或博客園地址

作者:KBdancer

前段時間由于項目需要,客戶需求中有一條是要實現WEB端的錄音功能,起初想到的是HTML5實現,經過幾輪百度之后無果。

PS:谷歌時不時被墻,非必要時請不要使用百度搜索。

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

話不多說,奉上API文檔,雖然是英文的,但是應該不會影響閱讀,關鍵的幾個 方法我都已經用中文注釋了(大概的意思翻譯了一下,如有不對請告訴我)。先暫時把API文檔發出,后面有時間的時候整理下DEMO也上傳一下,希望能夠幫 助需要的猿們(因為之前找了好久沒找到好的解決方案,費了好多時間,猿們找資料都很辛苦)

有圖有真相:

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(注:用于同步回放與動畫

    • 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(注:上傳進度)

    • 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(注:返回錄音持續時間?)

    • name - of the recording

    init: setup the recorder for saving recordings

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

    • 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"}]
    • (注:表單數據 指定一個鍵值對 數組?)

    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.

    (注:顯示權限許可對話框 大小至少 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()
    • (注:表單數據 ?額外的表單數據)

    configure: configure microphone settings

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

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

    • yes_no

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

    • yes_no

    getMicrophone: returns the microphone object ? ?(注:返回麥克風對象)

    轉載于:https://www.cnblogs.com/cydmk/archive/2013/04/09/3009755.html

    總結

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

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。