wami Recorder实现

时间:2013-05-26 20:52:18

标签: javascript jquery

如何从下面的代码中替换basic.hml中的URL?

  

Blockquote https://code.google.com/p/wami-recorder/source/browse/example/client/basic.html?r=f355776b862b3e8f4fa168dfc5adb79ae8cf6c58

代码是

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<!-- swfobject is a commonly used library to embed Flash content -->
<script type="text/javascript"
        src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>

<!-- Setup the recorder interface -->
<script type="text/javascript" src="recorder.js"></script>

<script>
        function setup() {
                Wami.setup("wami");
        }

        function record() {
                status("Recording...");
                Wami.startRecording("https://wami-recorder.appspot.com/audio");
        }

        function play() {
                Wami.startPlaying("https://wami-recorder.appspot.com/audio");
        }

        function stop() {
                status("");
                Wami.stopRecording();
                Wami.stopPlaying();
        }

        function status(msg) {
                document.getElementById('status').innerHTML = msg;
        }
</script>
</head>

<body onload="setup()">
        <input type="button" value="Record" onclick="record()"></input>
        <input type="button" value="Stop" onclick="stop()"></input>
        <input type="button" value="Play" onclick="play()"></input>
        <div id="status"></div>
        <div id="wami"></div>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

您可以使用以下内容替换网址:

Wami.startRecording("http://www.example.com/record.php?filename=test.wav");

Wami.startPlaying("http://www.example.com/test.wav");

record.php可能是:

<?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);
?>