[英]How is the Wami Recorder actually implemented?
我是Wami Recorder的新手,我從來沒有使用Flash,所以這實際上可能是一個愚蠢的問題。
基本上,如何實施Wami Recorder呢? 我在網站上看過它,它在那里工作得很好,但是當我下載它並嘗試在localhost中使用它作為Xampp的一部分時,它不起作用。
如果有人可以寫一個Wami Recorder for Dummies的答案,那就太棒了。
我在CakePHP 2.0中使用它,如果有人知道如何在該框架中使用它。
基本上我所要做的就是錄制音頻,將文件保存到目錄,並擁有POST信息,以便能夠將有關文件的某些詳細信息保存到數據庫中。
是的,文檔不是很清楚。 昨天我整個下午都在搞清楚。 這是一個適用於我本地計算機的簡單實現。 以下文件存儲在我的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)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.