How to play audio from WebView - javascript

I've been looking for how to play audio from the WebView when using socket.io to make a sound notification with my web chat application.
I've noticed Chrome Browser playing the audio but my WebView app doesn't play it. Can you please provide me any resource or code snippet?
Thanks in Advance!

Related

Is there a way to open an HTML5 video in the Native Android Video Player?

I am using Cordova to create an APK.
The Android WebView does not allow scrubbing of HTML5 video.
Is possible to open my app's video in Android's Native Video Player.
The HTML is simple:
<video src="video.mp4"></video>
For the scrubbing issue, I have tried to render the video as an iframe and embedded element but neither have worked.
I have also tried to invoke JS commands on the video. While these work in my browser, they do not work when exported to an APK.
I have also researched related SO posts but found no solidifying answers.
How would you make a call to another app on the device?
I read about using Intent but that appears to be a Native solution, such as developing the app in Android Studio.
you will have to use cordova-plugin-media.
read this documentation https://cordova.apache.org/docs/en/11.x/reference/cordova-plugin-media/index.html
additionally you can also use any freely available jquery media player plugins
for eg. https://videojs.com/

Web Audio API and Bluetooth

I programmmed a website which uses text to speech engine to generate audio files.
Then these mp3 files are started using Web Audio API.
Everything works fine when hearing aufio from speakers on a computer or on a smart phone.
However, as soon as I connect my bluetooth helmet to the smart phone, the audio is not played.
Is it a famous issue that Web Audio API doesn't work with bluetooth devices, or does the issue come from my code?
Do I need to change the context's destination ? How can I set it to buetooth? (ex : https://www.html5rocks.com/en/tutorials/webaudio/intro/)
source.connect(context.destination); // connect the source to the context's destination (the speakers)
Thanks,
LL

How to detect mobile phone event in browser using 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 !

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

Audio players in Chrome packaged apps

I'm trying to embed a music player in a Chrome app, and at the moment I'm using the default tag to embed music, but the problem is that I can't seek the song unless the song has been fully downloaded before playing (I'm streaming it from a file host).
The file host has its own music player, but is made in flash and so it doesn't work in Chrome apps. What should I do?

Categories