Record audio without simultaneous playback html5 - javascript

I've looked at many demos and every one of them when recording audio, plays back what you are saying at the same time. The issue with this is when recording without an external mic it causes the laptop's speakers and mic to interfere and spit out loud-ear piercing white noise.
Is there a way to record audio using html5 and javascript without having it playback while you record?

Related

Html/Js Audio without System Audio Controls

I want to program a little browser game which needs some audio.
<audio id='my-audio' src='...'></audio>
That works on desktop and mobile but I have one problem: I can control this audio with the system audio controls. So when I press pause/play on my computer keyboard it affects this audio and on my phone's lock screen there appears a huge audio control widget. Is it possible to disable/remove these controls?
I also tried using
new Audio('...')
in Javascript instead of the audio-tag. That did not solve the problem.
I suggest using the Web Audio API. The link is to an example that I think covers a use case similar to what you requested. In addition to running the tutorial, I've also successfully used this API to read raw audio data (PCM array of float values) and play back on demand, which is a bit more involved than what you are asking. In either case, there was no issue with popups of any sort.

How do mobile websites pause videos when other apps start playing audio?

Some mobile sites, like YouTube and Twitch, will pause html <video> elements if other apps (like Spotify, or a podcast player that puts media controls in the notifications) start to play audio.
Interestingly, these don't just take audio focus - they also stop playing if they can't obtain it. As an example, I'm using firefox for android, so I tried disabling its ability to take audio focus with adb:
cmd appops set org.mozilla.firefox TAKE_AUDIO_FOCUS ignore
But now, videos just immediately pause, since it can't pause the other audio source.
How do the sites detect this? I attached a debugger to my phone and looked through the docs but I didn't see anything in either place.
I'm not sure about how this specific flag "TAKE_AUDIO_FOCUS" is interpretted, but modern Android focus management is based on "requesting" (not taking) audio focus. Apps would request it and either get it immediately or listen for updates from the AudioManager as to whether they got it. Similarly they will get updates when someone else requests (and then subsequently receives) focus, and they should react accordingly (i.e. pause/duck themselves). Presumably the apps you mention have asked for audioFocus and were denied it and then hadn't received focus yet, so they just chose to stay paused rather than start playing audio/video and blare out over the app that hadn't released focus yet.
source: https://developer.android.com/guide/topics/media-apps/audio-focus

Video with multiple audio tracks

I want to make a web page where I display a video with options of multiple audio tracks where user can switch between different tracks available and just the audio will switch or maybe if possible video goes back 10 seconds and continues with selected audio track (eg. VLC player where we can select between different tracks).
How should i go about it? I read about VideoJs but couldn't understand how to do it.
It is not possible to add audio tracks through HTML like you can with text tracks. They must be added programmatically.
Video.js only stores track representations. Switching audio tracks for playback is not handled by Video.js and must be handled elsewhere - for example, videojs-contrib-hls handles switching audio tracks to support track selection through the UI.
Reference: https://docs.videojs.com/tutorial-audio-tracks.html

Html audio tag to preload entire stream

Is there a way to preload entire mp3 in html audio tag.
I'm having this problem for a long time. I have soundcloud player that uses html audio tag, im setting the audio source, the audio starts playing and the buffering starts.
The problem is that, soundcloud audio source is protected with short life token, when audio pre-buffer more data, buffering stops, when audio wants to continue reading the stream, it gets 404 from soundcloud and can't resume buffering.
I've noticed that if i pause the audio, whole track will be loaded at once, but this is not a solution that i need.
According to http://www.w3schools.com/tags/att_audio_preload.asp, you should set preload="auto".
Different browsers behave differently. Chrome buffers whole track on pause (for whatever reason). preload=auto does not do much but fills the buffer from the time url is set rather than on play event.
Flash is different. It loads whole track anyway. But it can not seek to unbuffered position because it can not do byte range requests. And it also wastes your and our bandwidth.

Synchronising SoundCloud audio and Vimeo/Youtube video playing together

Alright, I'm working on one project which involves html5 audio, in addition to that a video is shown while audio is playing (Just video, no controls etc). Video is a visualisation (sometimes called equaliser) of audio that is playing, made beforehand in adobe after effects. both files (video and audio) are same length e.g. 3 min 20 sec. I need a way to synchronise both, as video might load slower than audio or vice versa. Therefore I need to make it so that on computers with slow internet connection if video stops loading at some point and starts buffering I need to pause audio, and once video resumes start audio again, both at exactly same time, also when user skips to a certain bit in a song, video should skip to that bit as well, I'll use custom api made player for video so there would be no controls on video, only on soundcloud player.
It is almost as if I was using soundcloud custom player to control video. I'm struggling to find any resources on this anywhere, and would really like to know how to achieve this functionality.
javascript or jQuery solutions are preferable.
What makes it even more complicated is that I use SoundCloud's custom player to play songs:
http://developers.soundcloud.com/docs/custom-player#
And upload videos to Vimeo/YouTube (all done to decrease load on a website)
Check here: http://html5demos.com/two-videos
The sample is for syncing 2 videos, but with some hacking probably you can manage to sync audio and video.
Second, don't use Custom player, make your own HTML5 Audio element, check the SoundCloud API there is a property stream_url for every streamable track on soundcloud, just put that URL as source on your html5 audio tag.
Keep on mind that this will not work on Firefox and Opera for some time. Firefox will integrate native mp3 support in v20, not sure about opera

Categories

Resources