sound beep on mobiles like iphone: with javascript - iphone

Is this possible to make sound beep at mobiles like iPhone.....or play native sound....I testing phoneGap.js but it don't works to me......I want to make alert sound when new message arrives to end user at mobile...

javascript sound.play worked for me last time i made an html/5/jss app, which if your using phonegap, must be.... app, was a simple html/js game.

Related

Continuous HTML5 audio/video playback in iOS?

I'm working on a mobile web app and want to allow for continuous playback of HTML5 audio or video in both Android and iOS (i.e. queue up a playlist of YouTube videos or Grooveshark songs and have them all play in a row automatically).
Android doesn't seem to be an issue, but everything I've read has suggested that Safari prevents audio from playing unless it's initiated by a user, and prevents continuous play if the screen becomes locked.
That said, Grooveshark's mobile web app will play an entire playlist of songs in my iPhone 5 (iOS 7). It'll play the next song even if I'm in another Safari tab or I lock the screen.
So the question: How do they do that?
This code (jQuery) works for me in iPhone Safari iOS7 for continuous playback. Even if I have my screen locked/other tab it changes track when the first has ended (given a bit of patience for the new track to load)
<audio id="audio1" src="song1.mp3" controls></audio>
<script type="text/javascript">
$('#audio1').on('ended',function(){
$(this).attr('src','song2.mp3');
$(this)[0].play();
});
</script>
I've read has suggested that Safari prevents audio from playing unless it's initiated by a user.
=> That is true and is by design - no work around known as of today (well ... I have seen ugly attempt to make it work).

Phonegap HTML5 audio does not resume playback after incoming phone call on iPhone

I have created an app with PhoneGap that plays music from an online stream. It continues playing in background while the iPhone is locked but, and it stops when an incoming phone call arrives.
The problem is that when the phone call ends, music does not sound anymore. I use an HTML5 audio element to play the stream, and my app traces show me that play and playing HTML5 audio element events are triggered after phone call ends.
However, it simply does not produce any music or sound at all.
Hook up to the pause and resume events of Cordova in your app, if you're in paused state, then your app is suspended and would not play anything. You should invoke your play function on the resume event. Fore more info see Events: http://cordova.apache.org/docs/en/2.6.0/cordova_events_events.md.html#Events
it happens when play command is executed before audio device enabled
for your app.
yeah it is because of the app shutdown when your call arrives, to get back to app & to play audio it requires some seconds, in short it requires some seconds to start audio device after your call ends.if your play instruction executed before audio device is initiated for your application
you can solve this by cordova's resume event
As an android programmer, there are similar issues. When dealing with CordovaWeb views doing HTML5, if the activity is interrupted for something else, such as a phone call, it needs to be handled in code. In Android, when there is an interrupt, onPause or similar is called. Inside of that, you would need to save state, and the URL of the page for the webview.
When you navigate back, you need to restore the state.
I know i am speaking in Android while this is iOS, but there is some overlap when doing stuff like that.
See: Save & restoring WebView in an embedded PhoneGap app

How to play a sound while running in the background?

I need to be able to play a sound while running the application in the background.
I tried with UILocalNotifications but the file needs to be part of the bundle, and that will not be the case, as I need to generate the sound files on the fly...
So is there any way that I can play a sound while running in the background?
Thanks.
You can't, unless you continuously play audio and have the appropriate audio session category set for your app... then your app doesn't go to sleep, it continues to run (again so long as audio is playing).
This is part of the design limitations of iOS multitasking.
Apple has allowed people to get away with having a continuously looping blank audio file (AVAudioPlayer loop = -1 with a 1-sec blank CAF file) if the app is primarily audio related and it is obvious to the user that this has battery life implications (and can be disabled by the user), but YMMV... you app can also be rejected for this.

iPhone external video playback from an app

I know the iPhone can play video on an external screen if you have the Apple component output cable. I also know you can write an app that plays video. Is there a way to put those two things together and write an app that will play video specifically on an external screen?
This is currently not possible with the iPhone API. I have heard of apps that have done it on jail-broken phones, but there is not Apple-approved way of doing it at this time.
This can be done using private private APIs, but it won't get in the store. This guy wrote a class to do it here: http://dragonforged.com/DFVideoOut.shtml Haven't used it myself, but it looks very simple.

iPhone, how to detect when control is returned to browser?

I'm a newbie to cocoa programing on iPhone.
My client has a website that plays YouTube videos. Once a video is finished playing, it will automatically play the next one. This is done by using the YouTube API and swfobject.
After some research, I was told that Safari on iPhone does not support flash. This make the current swfobject code not working on the iPhone browser.
As workaround, when the user clicked on an embedded player, iPhone will launch the YouTube app.
Is to possible to determine when the YouTube app has finished playing and has returned control back to browser?
You can use UIWebView to play videos from YouTube. You'll have to control those from your application though (start, stop, play next, etc).
Also In iOS you can register custom URI schemes and then redirect the browser (or UIWebView) back to your application. This is how many application do 3-legged OAuth for example (which requires a browser interaction). Which might require having a control over the server.
No, it is not possible to jump out of your App and then come back to it again. Once you leave your App, you are finished.
You'll need to stay in a UIWebView, or come up with another method of playing the YouTube videos from within your App.
-t