javascript - Disable Sound In Browser Window With JS or Jquery - Stack Overflow

Is there any way to disable all sound on a browser window that may have embedded videos?I'm not lo

Is there any way to disable all sound on a browser window that may have embedded videos?

I'm not looking for particular solutions such as targeting Youtube with js etc... I need something general that will shut off all sound for that page so if any video plays it has NO sound. Need something that shuts off sound at the page level, not individually addressing each player via js etc...

I'm not aware of anything that could do that but thought I'd ask.

Many thanks if you could point me in the right direction.

PS: I know about How to mute all sound in a page with JS? but it's not what I need.

Is there any way to disable all sound on a browser window that may have embedded videos?

I'm not looking for particular solutions such as targeting Youtube with js etc... I need something general that will shut off all sound for that page so if any video plays it has NO sound. Need something that shuts off sound at the page level, not individually addressing each player via js etc...

I'm not aware of anything that could do that but thought I'd ask.

Many thanks if you could point me in the right direction.

PS: I know about How to mute all sound in a page with JS? but it's not what I need.

Share Improve this question edited May 23, 2017 at 12:01 CommunityBot 11 silver badge asked Apr 15, 2014 at 12:58 Noodle HeadNoodle Head 4313 gold badges11 silver badges23 bronze badges 1
  • Did you read that thread? The solution states "But you get the idea, iterate through media, check/store playing status, and mute/unmute" This is NOT what I want to do as I clearly stated in my op. – Noodle Head Commented Apr 15, 2014 at 13:25
Add a ment  | 

1 Answer 1

Reset to default 3

You necessary have to iterate in all audio/video tag and set volume to 0.

HTML

<div id="mute-button"><img src=""/><div>

JQuery

$('#mute-button').on('click', function(){

    $('audio,video').each(function(){
       $(this).volume = 0.0;
    });

});

Alternatively you can pause source:

$(this).pause();

For other embedded tag (youtube, vimeo..), take a look at this discussion.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744339557a4569322.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信