1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Microsoft.VisualBasic;
using System.Runtime.InteropServices;
using System.IO;
namespace audioo.Controllers
{
[HandleError]
public class HomeController : Controller
{
[DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);
public ActionResult Index()
{
return View();
}
public ActionResult rec()
{
mciSendString("stop recsound ", "", 0, 0);
mciSendString("close recsound ", "", 0, 0);
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
mciSendString("record recsound", "", 0, 0);
Session["recor"] = "enregistrement encours ";
Session["OK"] = "";
return RedirectToAction ("index");
}
public ActionResult save()
{ // stop and save
//mciSendString("close", "", 0, 0);
//mciSendString("save recsound c://record.wav", "", 0, 0);
//mciSendString("close recsound ", "", 0, 0);
//Session["recor"] = "";
//Session["OK"] = "enregistrement sauvegarder ";
mciSendString("stop recsound ", "", 0, 0);
string directoryString = "C://";
Directory.SetCurrentDirectory(directoryString);
mciSendString("save recsound record.wav", "", 0, 0);
mciSendString("close recsound ", "", 0, 0);
Session["recor"] = "";
Session["OK"] = "enregistrement sauvegarder ";
mciSendString("stop", "", 0, 0);
return RedirectToAction("index");
}
}
} |
Partager