3
我工作的asp.net應用程序,我撥打電話,從我的視圖控制器的動作。這個視圖需要將mp3返回到被調用的函數。什麼是ActionResult類型。被調用的函數返回mp3響應。如何在內存中的api返回的內存中保存mp3響應並返回到視圖?如何通過mp3流/響應從控制器查看?
這裏是我的控制器方法代碼:
public ActionResult getrecording()
{
byte[] file = new byte[100]; // Convert.ToByte("https://api.abc.com/api/v2/GetRecording?access_token=dfsdfsdfsdfsdfsdfsdfsdfsfsfdsf");
//return (new FileStreamResult(fileStream, "audio/mpeg"));
////return (new FileContentResult(data, "audio/mpeg"));
}
,這裏是視圖代碼
$("#jquery_jplayer_1").jPlayer({
ready: function (event) {
$(this).jPlayer("setMedia", {
mp3: "/recording/getrecording"
});
},
swfPath: "../../Content/JPlayer/js",
supplied: "mp3",
wmode: "window",
size: 100,
duration: "#duration"
});
我不想立即下載它。我想通過MP3響應jplayer http://jplayer.org/latest/developer-guide/#jPlayer-option-size – DotnetSparrow 2013-03-14 12:45:27
在我jplayer代碼,這是我的問題補充說,如果我這樣做:$(本) .jPlayer( 「setMedia」,{ MP3: 「https://api.abc.com/api/v2/GetRecording?access_token=dfsdfsdfsdfsdfsdfsdfsdfsfsfdsf」 });它的工作原理,但我需要傳遞訪問密鑰和令牌,這是不安全的,因爲用戶可以看到它們。 – DotnetSparrow 2013-03-14 12:46:44
你應該jPlayer的網址指向您的控制器動作:'MP3:「/ somecontroller/getrecording」;',而不是遠程服務。 – 2013-03-14 15:17:05