Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net NET中的WAMI记录器_.net_Asp.net Mvc 3_Flash_Voice Recording - Fatal编程技术网

.net NET中的WAMI记录器

.net NET中的WAMI记录器,.net,asp.net-mvc-3,flash,voice-recording,.net,Asp.net Mvc 3,Flash,Voice Recording,我正在看这台闪存录音机: 有人在.NET(特别是MVC3 C)中成功地实现了它吗?我在该网站上看到的只是PHP实现,没有实际的演示网站 另外,如果有人有录音的好选择,那就太好了。谢谢 您只需设置recordUrl和playUrl 作为基本实现,您可以执行以下操作: @{ var payUrl = "http://yourdomain/recordings/recording-" + Session["recordingId"] + ".wav"; <!-- saves t

我正在看这台闪存录音机:

有人在.NET(特别是MVC3 C)中成功地实现了它吗?我在该网站上看到的只是PHP实现,没有实际的演示网站


另外,如果有人有录音的好选择,那就太好了。谢谢

您只需设置recordUrl和playUrl

作为基本实现,您可以执行以下操作:

@{
    var payUrl = "http://yourdomain/recordings/recording-" + Session["recordingId"] + ".wav";
    <!-- saves the wav file to local folder called recodings using a session value to make unique file names -->
}
<script>
        function setupRecorder() {
            Wami.setup({
                id: "wami",
                onReady: setupGUI
            });
        }

        function setupGUI() {
            var gui = new Wami.GUI({
                id: "wami",
                recordUrl: "http://yourdomain/home/Save",
                playUrl: "@payUrl"
            });

            gui.setPlayEnabled(false);
        }
</script>

在页面中输入以下代码:

<div id="wami"></div>
创建一个网页,比如说RecorderPage.aspx,将html保留为空,并将以下内容放在代码中:

protected override void OnPreRender(EventArgs e) {
    ScriptManager.RegisterStartupScript(Page, GetType(), "setupRecorder", "setupRecorder();", true);
    base.OnPreRender(e);
}
private const string Path = "/App_Data/recordings";
private static readonly string FileName = string.Format("audio-{0}-{1}.wav", DateTime.Now.ToString("yyyyMMdd"), Guid.NewGuid());
private static readonly string Directory = HttpContext.Current.Server.MapPath(Path);

protected void Page_Load(object sender, EventArgs e) {
    string mapPath = HttpContext.Current.Server.MapPath(Path);
    string action = Request.QueryString["action"];
    if (!action.HasValue()) {
        return;
    }
    if (action.Equals("save")) {
        if (!System.IO.Directory.Exists(Directory)) {
            System.IO.Directory.CreateDirectory(Directory);
        }
        Request.SaveAs(Server.MapPath(Path + "/" + FileName), false);
    } else if (action.Equals("play")) {
        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.ClearContent();
        HttpContext.Current.Response.ClearHeaders();
        HttpContext.Current.Response.Buffer = true;
        HttpContext.Current.Response.BufferOutput = true;
        HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName);
        HttpContext.Current.Response.Charset = "utf-8";
        HttpContext.Current.Response.AddHeader("Content-Type", "audio/x-wav");
        HttpContext.Current.Response.ContentType = "audio/x-wav";
        HttpContext.Current.Response.AddHeader("Pragma", "no-cache");
        Response.WriteFile(mapPath + "/" + FileName);
        HttpContext.Current.Response.Expires = -1;
        HttpContext.Current.Response.Flush();
        HttpContext.Current.Response.End();
    }
}
确保正确导入了所有必需的文件(buttons.png、gui.js、recorder.js和Wami.swf)

最后,在页面的脚本部分包括这两个功能,根据您的配置修改
recordUrl
playUrl

function setupRecorder() {
    Wami.setup({
        id: "wami",
        onReady: setupGUI
    });
}

function setupGUI() {
    var gui = new Wami.GUI({
        id: "wami",
        recordUrl: "http://localhost/RecorderPage.aspx?action=save",
        playUrl: "http://localhost/RecorderPage.aspx?action=play"
    });

    gui.setPlayEnabled(false);
}
function setupRecorder() {
    Wami.setup({
        id: "wami",
        onReady: setupGUI
    });
}

function setupGUI() {
    var gui = new Wami.GUI({
        id: "wami",
        recordUrl: "http://localhost/RecorderPage.aspx?action=save",
        playUrl: "http://localhost/RecorderPage.aspx?action=play"
    });

    gui.setPlayEnabled(false);
}