How to play audio using Java Script on IPad? - iphone

I am trying to implement functionality to play an audio using Java Script. Its working fine on Google Chrome, Firefox and Other Browser. But when I try to play sound on iPad or iPhone or MAC I am getting below error.
Unhandled Promise Rejection: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.
Below is my Sample Code.
var APlayer = document.createElement("AUDIO");
APlayer.setAttribute("controls", "controls");
APlayer.src = audioUrl;
APlayer.play();
Can any body help me to find out the solution.

Related

how to let Iphone load videojs using "vhs.xhr.beforeRequest"?

Facing an issue with Iphone only, that can't process what inside "beforeRequest", on any browser including chrome and firefox, otherwise on Ipad and android works as a rock.
I tried to use true and false for "overrideNative" also nothing.
tried to console inside "beforeRequest" on Iphone and there is no return.
I found this error on debugger:
ERRORVIDEOJS: ERROR: (CODE:3 MEDIA_ERR_DECODE) The media playback was aborted due to a corruption problem or because the media used features your browser did not support. [object Object]
player.tech({ IWillNotUseThisInPlugins: true }).vhs.xhr.beforeRequest = (options)=> console.log('beforeRequest'))
anyone has a solution ?
Unfortunately you can't. VHS is used to play HLS with Media Source Extensions, which iPhone doesn't not support. Only native playback is possible.

Looking for a way to record video from an iphone embedded within a web browser and saved to a server

Ok, so I'm working on a project that will allow users to record themselves within a browser and have the video save to the server for later watching.
Right now I have an implementation where I'm using Red5 server with Red5 Recorder and that is working fine, but I'm wondering how exactly you could go about this on an iphone as that is expected to be a large user base.
As far as my research has shown there is no universal way to gather this video within the browser as there is no HTML5 solution and Flash seems to be by far the best way to record webcam to a server.
So what I'm wondering is has anybody encountered this issue and found a solution, whether it be for Iphone only, or a universal solution that would work across all platforms.
At the moment, the only way to accomplish this on the iPhone would be to write a native application. The web browser doesn't give access to the camera, and it doesn't support Flash, Java etc.

Opening a website as an iPad/iPhone in xcode

I'm trying to parse streaming video websites in order to play them in an iPad/iPhone app.
For example, in www.veetle.com, opening a channel with an iPad or iPhone you can see the video, because the code for this finds a .m3u (or .m3u8) file which can be played. But opening from a computer browser, or parsing the channel address in Xcode doesn't show you this .m3u file, it uses flash.
What I want is to get this .m3u file to be able to play the channel, I have been searching all around the web how to open a website as a mobile in Xcode, but I haven't found anything. Any idea?
Thanks.
You need to change the so called user agent string in your request.
See here: Changing the userAgent of NSURLConnection
and here: What is the iOS 5.0 user agent string?
Developer tools for safari also offers the ability so quickly change the user agent which is nice if you just want to quickly check a site: http://designshack.net/articles/developer-tools-in-safari/
Use eg this to see your current user agent: https://duckduckgo.com/?q=user+agent+

"The Server is not configured correctly" message while playing movie in iphone

I am trying to play video files from iPhone media player in my iphone application.I am reading the stream from one Media server.
but i am getting error message as "The server is not configured correctly".
Here is my observation:
-> I kept five different video files on server.(i am sure that all of these files are properly encoded and in right format.)
-> When i try to run same video URL in Mobile Safari i works perfectly without any error.
-> When i try to run any of video it doesn't create any stream on media server.(Usually when i try to play video it create stream on media server.but here the stream is not created on server side.)
-> I tried to play this files using Apple's sample application MoviePlayer but i am facing same issue.(Here i tried to run the application on Simulator)
-> I also checked on my iphone 2G having OS 3.1.2 (jailbreak) but i face same issue.
Please let me know your response on this.
Thanks,
Jim.
You basically need a web server which supports progressive downloads. Apache does support it.
Maybe you want to try the same scenario with the videos hosted on apache.
If that does not work, do post your code.
I have figure out the solution.Actually for some links that i am getting from Server contains bad characters so the URL wasn't right one.
After correcting that issue now i am unable to play all the video file from media server.
Thanks a lot for your help and suggestions.
Thanks,
Jim.

How do i stream an audio file from the server to iphone?

I need to stream an audio file which is saved on my server. Is it possible for me to stream that file in order to play it on my iPhone? Or is there any other way to play an audio file from the server to iPhone? help me please.
Thanks,
Shibin
This link was useful to me : http://cocoawithlove.com/2008/09/streaming-and-playing-live-mp3-stream.html
He's got a project linked from that page http://projectswithlove.com/projects/iPhoneStreamingPlayer.zip
In this project, interesting lines are in iPhoneStreamingPlayerViewController.m, lines 82-89 start streaming the audio from a url.
I've manged to get this running on my iPhone and tested it using an mp3 on another server and it works fine. However, I've not picked through the code so I can't help you anymore than this, sorry!
Sam
NS To get the project to compile I had to change the SDK to 3.0 - if you right click on the project name and choose Get Info, then change the option called Base SDK to iPhone Device 3.0 and it should work.
There's a couple of ways to get the file playing on the iPhone, but the first problem is that you need to decide how to serve the file from your server.
One great way is to share the file out via HTTP using a Web Server. If the server is Windows, look into 'IIS'. If it's a Mac or Linux, Apache is your friend.
Once you've got the serving going, here are the options on the iPhone:
1) Use iPhone Safari to navigate to http://your-server/your-folder/the-file.ext. If the serving is correct, it'll open the mediaplayer and stream it.
2) Write an iPhone application that uses the AVMediaPlayer framework to play the file. Non-trivial, but there are plenty of samples.