Background story: many users (including me) browse the web from notebooks that are not constructed for sound performance. That means (besides other things) that the sound volume for most videos is too low, especially if the video itself is recorded at low volume.
Therefore...
I was wondering if there is any way of increasing the volume of such a video (especially Youtube, but could be extended to other types), because I'm interested in doing it and even publishing it as Firefox/Chrome/other browser plug-in.
Or, alternatively, if you know such a plug-in do not hesitate to post the link here.
If you want to control system volume then JavaScript has no direct access to it, you would need to write NPAPI (C++ dll) plugin.
If you want to just adjust video player's own volume (you won't be able to increase it beyond 100%) then JavaScript can do it, perhaps.
If video player is HTML5 <video> tag then controlling volume is easy. For YouTube it would be:
document.getElementsByClassName("video-stream")[0].volume = 0.5; //50%
If it is a custom made flash player then you need to rely on its JavaScript interface, if any. Youtube player happens to support controlling volume with JavaScript:
document.getElementById("movie_player").setVolume(50);
In order for this to work you would need to break out of extension sandbox first by injecting <script> tag on the page with this code.
There is no universal solution, you would need to deal with each site individually.
Use VLC Media Player. You can copy and paste links into it. Increase sound to up to 250%
You can use js-ctypes to change system's volume level. Here is an example that sets volume to 12.5%:
Components.utils.import("resource://gre/modules/ctypes.jsm");
var lib = ctypes.open("winmm.dll");
var waveOutSetVolume = lib.declare("waveOutSetVolume", ctypes.default_abi,
ctypes.uint32_t,
ctypes.int32_t, ctypes.uint32_t);
waveOutSetVolume(-1, 0x20002000);
lib.close();
However, this only changes the volume for the Firefox process. It won't have any effect on Flash because it runs in a different process now. I'm not even sure whether winmm has some way to change the global volume at all, you might need the new MMDevice API for that - and then it gets complicated because doing COM calls via js-ctypes IMHO isn't possible. Only option is creating your own library to be distributed along with your extension. That should do the COM messaging and export a plain API that can be called via js-ctypes.
You can use Sound Booster software by Letasoft, but there are some things you might encounter like crash, we are using netbooks so the built-in sound card has limit. So try to buff first before playing that's the best advice that I can give. The max volume output will be 500%.
I found this
javascript:((v,a=new AudioContext(),g=a.createGain())=>(window._g??(c=>(a.createMediaElementSource(document.querySelector('video'))[c](g),g[c](a.destination),window._g=g))("connect")).gain.value=v??1)(parseFloat(prompt("Enter gain level",window._g?.gain.value)));
If you are using Chrome, then you can:
Right-click and choose Inspect. Or simply press F12.
Go to Console.
Paste this code.
Press Enter.
A message will appear, type what level you want (0.5 - 1 - 2 - 3 - ...), and press Enter.
For more about AudioContext.createGain(): Go Here
Related
BEFORE YOU TRY AND MARK THIS AS A REPEATED QUESTION
I know this is possible, and all of the other questions are old. Here's why this question is different:
Netflix has been able to do this. Try streaming Netflix, turn subtitles on, and you can see that if you try and take a screenshot, the subtitle will appear, but the video will not.
Try this again with OBS. When you use a desktop/window capture, you can see the video from Netflix playing in the browser, but at the SAME time, OBS can't pick it up.
This Wordpress plugin (which I haven't tried out personally, so not sure if it works, but the reviews are promising)
So now that I've assured you this isn't a question with the context of 2014, are there any new ways to be able to avoid screen capture on the web? I've assumed that it's impossible for a while, but it looks like there might be an API for it somewhere, and no one hasn't asked this question in years here. It'd be useful for preventing capture in my own JS websites, so I was just wondering how I could implement this myself. Thanks.
Your initial assumption is correct, it's impossible. The Netflix example is different, because it isn't preventing a screenshot of the webpage (which is why the subtitles still get captured) but of the video stream, which is embedded in the webpage, but not actually a part of it. The video isn't captured in your example because it's protected by Encrypted Media Extensions. This also means, though, that the video isn't playable in just any browser, it's only accessible in browsers that support EME.
So, the answer to "how do you prevent screen captures on the web" is "convince every browser manufacturer to include features in their browser that allow you to control screen capturing, and then only make your website available to browsers that support that feature" (which is essentially what Netflix did for video).
You could try playing a transparent DRM-protected video on top of your content (and forward any user event to the element below it). When the user takes a screenshot, the video should produce a solid overlay on top of your actual content.
I am attaching a screenshot for reference to get more elaborated idea about the problem am facing.. Kind of hell.
I am well aware about autoplay policy and have gone through possible approches which involves user interaction. Also, am not a fond of displaying any screen or button to user to make him click, never, i do not want that.
I am developing a wordpress plugin and having microphone feature which can attach to textbpx on any wordpress website, user clicks on it (user interaction) comes in.
I have also read that i need to resume suspended audio context, which am doing and as you can see in screenshot the state of audio context "running" before and after audio elements play mathod.
I am using audio element created using Audio() constructor.
Note: screenshot is a photo of mac system, I am debugging iphone xr using usb cable.
Can somebody help me out or enlighten me on what am doing wrong or there is any technical limitation.
Sigh! after a week lasted hell finally I managed to make things works.
To give an overview of solution let me first describe high level rough idea of work flow which has problem on iOS Sfari.
Problematic workflow
clickHandler --> AudioContext creation --> Playing audio using audio element.
All the audios followed by this workflow miserably failed in 'play' promise.
Solution which worked for me
clickHandler --> Play audio using audio element -> AudioContext creation --> Playing audio using audio element.
The point of interest in a solution which worked for me is you have to play audio using audio element as first line of code in 'clickHandler'. No doubt the promise still fails but subsequent audios does play.
Also, I was creating new audio element for each new audio source to be played, Which was wrong as auto-play policy imposed on 'per-element' basis. So instead of creating new audio element for each source I just create it once on page load (or whatever suits for you as one time creation) and whenever I want to play different audio file I just change the '.src' property/attribute.
So this is how It worked for me. I must mention throughout the week lasted hell, previously answered questions here and their problem specific solutions have been guiding light which gave me new perspective in a hunt for solution. Also the articles on internet, webkit , chrome, apple's documentation on Auto play policy helped a lot.
Is there a way to programmatic-ally control audio level on tabs i want to regardless of how web app was designed (be it HTML5 Audio element or Flash, etc.)?
Just to make it clear i don't intend to research web page for some "id" "elements" or whatsoever, but something like Chrome.ThisAudioOutputLevels...?
Admitting that the audio comes from a <audio> HTML element, you can try to get all audio elements from the DOM and lower their volumes. I was suffering from this with google hangouts meetings where I couldn't lower the audio because it had no control whatsoever.
"The solution"
I selected all <audio> elements and lowered their volumes. Follow these steps:
Open your console on the given tab. (Press F12).
Select all audio elements.
Lower each audio volume.
let audios = [...document.getElementsByTagName('audio')];
audios.forEach(audio => audio.volume = 0.5) // lower volume 50%.
Volume range = {0..1} where 0 = no volume.
This is more of a comment than an answer, but I can't comment, so:
Browsers generally try not to change how the content is meant to be displayed, including sound. For this reason, I would be surprised if there were such a feature.
If you're trying to simply mute tabs, you could take a look at chrome://flags/#enable-tab-audio-muting
Alternatively you could use tampermonkey or a similar extension and run a search for all audio/video tags and change the volume, but you said you didn't want to search for specific elements. To my knowledge (and Google's) as of right now there is no volume control for an entire page.
A Deezer player widget of the kind which can be created over at http://developers.deezer.com/musicplugins/player has a couple of visual style / layout options, such as theme (dark / light) and text highlight colour, but it cannot be controlled via Javascript. Using the Deezer JS SDK to create a player enables me to control it, but there don't seem to be any of the visual options (except for format, but that doesn't do in my case). Are these options just missing from the SDK docs or are they completely unavailable when creating a player using the SDK? If the latter is the case, is there any way I could control an embed created at the Deezer Music Plugins page? By control I mean I need to be able to play / pause the player, receive play / paused events and get the currently playing track title.
Background: I'm trying to achieve a symbiosis of multiple audio and / or video playback services within a single page; the goal is to stop any currently active player when a user starts playback in another player and to have an always visible play/pause button at the top of the viewport along with the currently playing track's name. If there is any other way to do this that I'm missing, I'm all ears :-) I know I could theoretically build my own player UI, but I wanted to retain the user experience that comes with a given service.
The only visual options available are those which are mentioned here: http://developers.deezer.com/sdk/javascript/player
Adding the new visual options provided by the new version of the widget is in our backlog, it will be available soon.
How would I go about seeking or pausing an embedded video (not necessarily a swf) from javascript? I am looking for something like Google's SWFObject's API, but for Windows Media Player, Real Player, Quicktime.
I would check out camen design, that is for backup (in case HTML 5 is not available), then broken links (set the src attribute of the video tag to something else, ironic enough that link to the video is broken), you can easily play/ pause, access volume control, etc using Javascript.
Like ItzWarty said, not many video formats are supported, but you can certainly work it out.