Record audio only in browser on iPads - ios

I am working with a school group that has a Django website with a page that allows the users to press a button, record audio, and save this audio to their user pages. This website was built to work on computers and Samsung tablets with Dolphin browsers using the HTML Media Capture to capture the audio by launching the microphone app on the tablets. The group wants to now switch to iPads. I have been researching ways to launch the microphone app from iPads but it seems this is not possible using HTML5. I have done some research and seen the links below, but I don't know what the best strategy is to modify the existing website to make it work on the iPad.
What is the best way forward to allow this group to record audio (not video) from their iPads using a browser-based website?
Research--
http://caniuse.com/#search=getUser - shows getUserMedia will not work on iPads
http://www.html5audio.org/2012/11/capturing-audio-on-ios-6-via-the-videotag.html - looks pretty hacky, does it work?
How to record and play voice in ios6 using HTML5 - using PhoneGap might work, but how would the recording app be launched from the browser and then save back the audio to the users account?
Thanks,
Lee

After having the same problem for a year, I found a new article with a solution: How to record audio from a mobile web page on iOS and Android
One of the newer APIs available is the MediaRecorder API. My first attempt at building this application started with this class. I implemented the entire application and it worked great on my desktop. It was easy to capture audio and the data was already compressed into .ogg format and ready to ship to my server. Then I tried it on iOS. It turns out that the MediaRecorder API is not supported and wouldn’t meet my needs. After I stopped cursing Apple, I began again from scratch.
... That was the last piece of the puzzle that allowed me to construct a working demo and it revolves around three steps:
1. Capture the microphone so we can begin recording
2. Accumulate captured audio data into a series of byte array chunks
3. Combine the chunks into one large array and massage the array into the format of a .wav file
There is a bunch of code on the website. And here is the demo file: https://www.gmass.co/blog/wp-content/uploads/2018/03/wzrecorder.zip
I have tested it and it works on iPad.
Demo: https://q2apro.github.io/wzrecorder/

Safari iOS does not (yet) support the accept="audio/*" part of the <input> element even though it does support taking videos and images through HTML Media Capture.
<input type="file" accept="audio/*" > on iOS 10 will prompt the user to select between:
Take Photo or Video
Photo Library
iCloud Drive
More...
The same code works just fine in Chrome on Android.
Safari in iOS6 was the 1st mobile Safari to support the <input ... > element and I've tested all the way up to iOS10. Chrome on iOS uses the same rendering engine so the same limits apply.

Related

iOS Browsers not respecting HTML5 audio preload tag

Has anyone else noticed that Safari (and even Chrome) for iOS attempt to preload all audio tags even if you use the preload="none":
<audio src="test.mp3" preload="none"></audio>
Desktop browsers appear to work correctly, but as soon as I load the page from the iPhone the Apache server registers a request for the file.
According to Apple Docs, Mobile Safari never loads music file or metadata until user touch is detected. This is to make sure a webpage doesn't request a lot of music or data to be downloaded on mobile devices which might take up a lot of mobile data. So preload tag is essentially always set to "none" in mobile Safari regardless of what your code has. Here's the link to the docs where they explain everything.
Quote straight from the docs "Note: The preload attribute is supported in Safari 5.0 and later. Safari on iOS never preloads."

HTML5 Audio callback fails on safari/iOS

I have built an app, designed to play each sound as the first one is finished by using 'ended' event.
In my initial version, each sound has its own audio element, resulting in something like:
function play_next_audio(){
speaker = $('audio#' + sounds[i++]).get(0);
speaker.addEventListener('ended',play_next_audio);
speaker.play();
}
This works great on all desktop browsers, including Safari, but does not go beyond the very first letter on iOS.
I have also tried a different approach - a single audio element that loads each sound in turn. There I experimented with binding the 'ended' event as well as loading first and binding 'canplaythrough' event instead. In both cases, it fails to work even on the desktop Safari - this time successfully playing the first two letters.
Here is the isolated test:
http://dev.connectfu.com:42001/app/test-sounds.html
Note that audio.load() is commented out several places - having it in or out seems to make no difference.
What am I doing wrong? How can I play series of sounds on iOS? Thank you so much for the help!
update As of 2017, the ended event doesn't fire on Safari (or Chrome) on iOS under several conditions. More information can be found here: It's almost 2017, and HTML5 audio is still broken on iOS.
I've built an HTML5 audio player (Chavah Messianic Radio) that "works" on Safari on iOS.
By "works", I mean, it plays the best it can on Apple's crippled iOS <audio> implementation. At the time of this writing, this includes iOS 5. I've tested this on iPhone 3 and up, and iPad original, iPad 2, and iPad 3.
Here are my findings:
Apple does not allow you to call .play on any audio until user interaction. For me, this means detecting iOS, then showing the music as paused until the user clicks play. Their reasoning is that this will consume data and battery; in practice, though, it just cripples web apps and stifles the evolution of the web.
If you want to play successive sounds (one after another), use a single element. When it's time to play the next sound, set existingAudio.src, then call existingAudio.load(), then call existingAudio.play(). This will allow you to play successive sounds.
Audio events don't fire if Safari is in the background.. While audio will continue playing if the user switches to a different app, the .ended event won't fire. This means it's practically impossible to build a music player app.
Hope this helps.
<rant>
In the meantime: Apple, please, please, please give us better support for HTML5 in iOS Safari. Here are your action items, Apple:
Let HTML5 audio work in the background.
Support OGG.
Support pre-loading audio.
Support concurrent audio.
Let us play audio without user interaction.
Do those things, Apple, you'll be the industry leader in mobile HTML5 audio, everyone will emulate you, you'll once again be leading the way, and web apps will work perfectly on your platforms, while being crippled on other mobile platforms. Yes, these features will use data and the battery, but native apps already do this. Stop crippling web apps and be the leader. Make HTML5 <audio> a first-class citizen on iOS.
</rant>
I don't believe the .play() method is supported for audio or video in iOS. Apple does not like the idea of videos or audio automatically playing upon visiting a page.
Here is a helpful reading about the state of HTML5 audio support across platforms: http://www.phoboslab.org/log/2011/03/the-state-of-html5-audio

Mobile-friendly audio player for Rails app?

I'm currently building a Rails app, where a user can upload an mp3 and listen to it. I'm using paperclip for the data upload, but I'm not sure how I'd arrange the playback of the soundfile, so that it can be used on a mobile phone as well (so no flash).
Thoughts?
The two main cross-browser media playback frameworks are jPlayer and SoundManager.
Both will handle playback of your audio, regardless of device. Both will play the audio using either HTML5 or Flash according to
which solution is available
which solution you specified as higher priority (e.g. use HTML if available, Flash if not)
I'm using JW Player and I'm very happy about it. There is a HTML 5 mode that runs on newer mobile devices like the iPhone.

Sharepoint 2010, HTML5 video won't work on iPad

I created simple html page with content like:
...<body><video width="848" height="352" class="shown" id="videoShowcase" controls="controls" ><source src="http://myportal/PublishingImages/apple-html5-demo-tron-us_848x352.m4v" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
and its NOT working on ipad(ios4), while it works in chrome. If I change src attribute to "http://movies.apple.com/media/us/html5/showcase/2011/demos/" for example, it works on both(even IE in 9.0 mode).
It makes me think that the probles is 1) SP2010 access to "PublishingImages" list, but i break role inheritence, and granted anonimous access to this
2)the way SP2010 stream videos, my guess is SP2010 handlers over IIS
Any thoughts?
The file extension is irrelevant - mp4, m4v, mov etc. are all just container format extensions. The real format of the file is declared internally, and it's most likely the internal format that's the problem.
I believe that iOS will only play .h264 encoded videos. I'm not sure what avc1.42E01E is, but I'm guessing iPad doesn't support it.
I suggest you try ripping the video to an iPad compatible .h264 video using Quicktime Pro. If you find a copy of Quicktime 7 and pay the $30 license fee for pro, it comes with a bunch of easy-to-use export options for videos that will work correctly on iPad.
There are other free video rippers such as Handbrake if $30 for QTP seems a bit steep - YMMV.
Mobile Safari on Apple i-devices uses hardware acceleration to play videos. So instead of making request to video in the current(authenticated) context, it makes new request to the video.That request has authentication failed. So, the only "solution" to this is to store public videos allowing anonimous login.

Is there any way to have a web page record sound from an iPad?

I don't think this is currently possible with straight HTML (although I've heard that HTML5 may support this in the future):
I'd like a web app that can record audio from the iPad (and also, ideally iPhone).
This will not be an iOS app. It's a web page.
Unfortunately, no. The only hardware functions you can get access to via HTML/JS are the location service and the accelerometer.

Resources