0

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

块引用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>
4

1 回答 1

0

您可以将 URL 替换为以下内容:

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);
?>
于 2013-11-02T03:08:35.993 回答