Wav文件无法在Internet Explorer和Safari中的HTML5中播放音频元素 [英] Wav file not playing in audio element in HTML5 in internet explorer and safari

查看:146
本文介绍了Wav文件无法在Internet Explorer和Safari中的HTML5中播放音频元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我在MVC中有一个HTML5音频控件。我在那个控件中播放wav文件。在Chrome中工作正常但在Internet Explorer和Safari中无法正常工作。我从s3桶中取出音频

所以,请给我解决方案



我尝试了什么:



 var audioElementGrid = document.createElement('audio'); 



< br $>

 $(#profileGrid)。on(click,。btn-play,function(){
audioElementGrid.setAttribute('src', $(this).attr(data-url));
audioElementGrid.pause();
audioElementGrid.play();
$(a.btn-play)。 html( );
$(this).addClass(btn-stop);
$(this).html( );
$(。lightbox-playBtn)。addClass( lightbox-stopBtn);

audioElementGrid.addEventListener('ended',function(){
$(a.btn-play)。html( );
$('。lightbox-playBtn')。removeClass(lightbox-stopBt n);
$(。audio-btn)。addClass(btn-play);
$(。audio-btn)。removeClass(btn-stop);
},false);
});







 public FileResult GetAudio(string key)
{
Stream file = new MemoryStream();
try
{
GetObjectResponse r = s3Client.GetObject(new GetObjectRequest()
{
BucketName = bucketName,
Key = key
} );
尝试
{
返回文件(r.ResponseStream,audio / wav);
}
最后
{
}
}
catch(AmazonS3Exception)
{
//显示异常
}
返回null;
}

解决方案

(#profileGrid)。on(click,。btn-play,function (){
audioElementGrid.setAttribute('src',


(this).attr(data-url));
audioElementGrid.pause();
audioElementGrid.play();


(a.btn-play)。html( 的);

Hello,
I have an HTML5 audio control in MVC. i am playing wav file in that control. In Chrome working fine but in Internet Explorer and Safari not working. I am fetching audio from s3 buckets
So, Please give me the solution

What I have tried:

var audioElementGrid = document.createElement('audio');



$("#profileGrid").on("click", ".btn-play", function () {
           audioElementGrid.setAttribute('src', $(this).attr("data-url"));
           audioElementGrid.pause();
           audioElementGrid.play();
           $("a.btn-play").html("");
           $(this).addClass("btn-stop");
           $(this).html("");
           $(".lightbox-playBtn").addClass("lightbox-stopBtn");

           audioElementGrid.addEventListener('ended', function () {
               $("a.btn-play").html("");
               $('.lightbox-playBtn').removeClass("lightbox-stopBtn");
               $(".audio-btn").addClass("btn-play");
               $(".audio-btn").removeClass("btn-stop");
           }, false);
       });




public FileResult GetAudio(string key)
        {
            Stream file = new MemoryStream();
            try
            {
                GetObjectResponse r = s3Client.GetObject(new GetObjectRequest()
                {
                    BucketName = bucketName,
                    Key = key
                });
                try
                {
                    return File(r.ResponseStream, "audio/wav");  
                }
                finally
                {
                }              
            }
            catch (AmazonS3Exception)
            {
                //Show exception
            }
            return null;
        }

解决方案

("#profileGrid").on("click", ".btn-play", function () { audioElementGrid.setAttribute('src',


(this).attr("data-url")); audioElementGrid.pause(); audioElementGrid.play();


("a.btn-play").html("");


这篇关于Wav文件无法在Internet Explorer和Safari中的HTML5中播放音频元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆