我对Wami录音机很新,我从来没有使用Flash,所以这可能是一个愚蠢的问题.
基本上,如何实施Wami记录仪?我在网站上看到它,它在那里很好,但是当我下载它并尝试在本地主机中使用它作为Xampp的一部分,它不起作用.
如果有人可以写一个Wami录音机的Dummies答案,那将是完全令人敬畏.
如果有人知道如何在框架内使用它,我在CakePHP 2.0中使用这个.
解决方法
是的,文档不是很清楚.我昨天下午度过了解,这是一个简单的实现,适用于我的本地机器.以下文件存储在我的Apache文档根目录下的“/ temp / wami / test”中,因此URL为“http:// localhost / temp / wami / test /”:
的index.html
recorder.js
save_file.PHP
Wami.swf
的index.html
<!-- index.html --> <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> <script src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script></script> <script src="recorder.js"></script> </head> <body> <div id="recorder"> <button id="record">Record</button> <button id="play">Play</button> </div> <div id="flash"></div> </body> <script> // initialize Wami Wami.setup({ id: 'flash' // where to put the flash object }); // initialize some global vars var recording = ''; var recordingUrl = ''; var playBackUrl = ''; // get button elements var record = $('#record'); var play = $('#play'); // define functions function startRecording() { recording = 'temp.wav'; recordingUrl = 'http://localhost/temp/wami/test/save_file.PHP?filename=' + recording; Wami.startRecording(recordingUrl); // update button attributes record .html('Stop') .unbind() .click(function() { stopRecording(); }); } function stopRecording() { Wami.stopRecording(); // get the recording for playback playBackUrl = 'http://localhost/temp/wami/test/' + recording; // update button attributes record .html('Record') .unbind() .click(function() { startRecording(); }); } function startPlaying() { Wami.startPlaying(playBackUrl); // update button attributes play .html('Stop') .unbind() .click(function() { stopPlaying(); }); } function stopPlaying() { Wami.stopPlaying(); // update button attributes play .html('Play') .unbind() .click(function() { startPlaying(); }); } // add initial click functions record.click(function() { startRecording(); }); play.click(function() { startPlaying(); }); </script> </html>
save_file.PHP
<?PHP /* save_file.PHP */ // get the filename parse_str($_SERVER['QUERY_STRING'],$params); $file = isset($params['filename']) ? $params['filename'] : 'temp.wav'; // save the recorded audio to that file $content = file_get_contents('PHP://input'); $fh = fopen($file,'w') or die("can't open file"); fwrite($fh,$content); fclose($fh);
应该这样做不幸的是,似乎没有办法暂停,然后恢复录音.每次开始录制时,它会覆盖以前的音频.还没有一种方法来检索有关音频文件的信息(例如长度,大小).有关录音机功能的完整列表,请参阅Wami录音机文件(recorder.js).