最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin6浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论