How to detect mobile phone event in browser using javascript? - javascript

Now i have a HTML5 web app designed to running on mobile devices, Android And IOS. And I'm using Web Audio Api to play sound, and I want to pause playing when there is a call coming. Searched on Google that on Android there is a TelephonyManager.ACTION_PHONE_STATE_CHANGED notification broadcast to Apps when there is a phone call, but i don't know how to handle it using javascript in browser.
Any tips about this problem will be appreciated a lot.

Check this: http://pages.stern.nyu.edu/~gcu201/websys/cordova-3.4.0/cordova-amazon-fireos/test/cordova/plugins/org.apache.cordova.device/src/android/Device.java
hope it can help !

Related

Remote Desktop in browser through Nodejs

My requirement is to develop a web page which shows the remote desktop I am connected to. The computer I am trying to connect is on the OpenStack cloud which has a static I.P(public I.P) and can be accessed by providing login credentials.
I don't mind if there is a need to add a plugin to my browser. Is there a tool or API to support this? Glad if there is a Node js solution for this.
Have you tried the remote-control-server package?. It enables you to control your PC from your web browser on your other PC or mobile device remotely. It also supports mouse movements, scrolling, clicking and keyboard input.
You can check it out here.
https://www.npmjs.com/package/remote-control-server
Hope this helps!

Is there a way to request microphone access for a chrome extension popup?

I'm currently playing around with WebKit speech API and trying to implement it in a chrome extension. Unfortunately, I'm having many troubles with getting the typical pop up that appears when a site asks for microphone permission (allowing you to accept or decline). Any idea on how to accomplish this? I have a div which triggers the web speech recognition function on click. Thanks so much! All help is appreciated!
Native method getUserMedia is what you want, and don't forget to declare audioCapture permissions.

How to interact with iPhone browser without touching it?

So, I am developing this VR website online with JavaScript.
I have a function that instantiates an object in the 3D room, at the given location that the user is "watching".
However, I don't see how I can execute that function when my iPhone is locked away in the VR headset. I have been thinking about volumeup-button on my headset that is connected to it or something, but haven't found anyone that has done that before.
Do you guys have any advice? Could there be a way of connecting a BlueTooth remote to it? Or is it simply impossible?
TLDR; How to execute a function in the browser on your phone, when you can't touch your phone.
It is possible to connect Bluetooth keyboard to iOS devices, as you suggested in your post.
You might also leverage the other sensors in the phone (such as accelerometer, gyroscope, microphone), but I'm not certain if Safari has access to those. You would have more options if you developed a standalone application rather than trying to go through a browser.

React-Native and playing music from the Soundcloud API?

I am just getting started with React-Native. Does anyone have any experience getting soundcloud songs to play? I have tried an iframe webview, but I need the song to be playing while surfing through the app. The webview only allows for me to play something while the webview is open.
I am thinking the best way to do this would be to have an invisible iframe webview that never gets refreshed. Is this possible?
I've also tried using the react-native-sound package, however I can't use that to stream from the soundcloud Stream URL.
Does anyone have any ideas/worked with this before?
I would recommend a more native implementation.
There is an Objetive C/Cocoa (iOS) wrapper available that supports the audio streaming. https://github.com/soundcloud/cocoa-api-wrapper
There is also an Android one (it looks like support was discontinued, but still should work) https://github.com/soundcloud/java-api-wrapper
You can wrap those using Native Modules and let the OS handle the playing of the audio. It will work better than some WebView based circumvention.
I have a suggestion.
Use this library for soundcloud api in react-native.
https://github.com/nhayflick/ReactNativeMusic

Phonegap/Cordova - media api - when play audio from URL, UI freeze a few seconds

After few days of investigation, i still got no luck on this issue, thanks in advance if you can help me out!
i am using cordova 3.3 to do my iOS app, one feature is to play an audio clip from a URL.
I am using cordova's offical media api, here is how i use it following their offical examples
var myMedia = new Media("http://123.com/xyz.mp3");
myMedia.play()
here is the issue: when the play event is fired, the UI freeze a few seconds,
I believe this is due to fetching a remote resource from http://123.com/xyz.mp3, when play a mp3 locally, there is no such issue.
the media api seems do not offer preload kinda function.
when loading the remote url mp3, it is using the same thread as the UI therefore it freeze until the loading task is done....
does anyone experience the similar problem? how should fix this issue?
Thank you very much for you time :)
We're currently developing an app that streams some music and we had the exact same problem.
We decide to go with the HTMLAudioElement. You can use it just like this
var myAudio = new Audio("http://123.com/xyz.mp3");
myAudio.play();
This doesn't freeze our UI while loading and I even think it loads a little bit faster.
And it's also working in the browser, which is nice for testing.
The down side is, that Android doesn't support the HTML5 Media API and has some general problems with the Audio Element as well (in some versions on some devices). So if you want to support Android you probably better use the Phonegap Media API there.

Categories