How can avoid audio streaming to stop after 5 minuter? - android

I made an PhoneGap app that contains an audio player with start / stop.
Player stream audio from shoutcast streaming.
It works perfectly on iOS and it also works on Android, even if the app goes is in background and the phone is lock
but after around 5 minutes audio stops
I tested on OnePlus 6t and has been tested on a Sony Xperia with same results
JS code
myaudio = new Audio(streamurl);
myaudio.id = 'playerMyAdio';
myaudio.play();

All apps without background tasks will get snoozed on Android after a while. You need to set up a background task so your app doesn't go into snooze.
Maybe you can try this plugin
https://github.com/katzer/cordova-plugin-background-mode

Related

Android webview microphone capture issue

I am trying to record audio using an app that runs WebView. For example, I load the app in the URL https://online-voice-recorder.com/ and records some audio over the mic. I have given enough permissions and able to record and replay the audio. On Windows 10, it works perfectly. But on my Android Oreo 8.1.0 running Chrom version 80, this audio is fully distorted. I tested it another device and the audio is partially legible.
Is this a standard behavior?
What I have tried to see what is the problem: I wrote a backend netcore3.1 app to play the audio and it plays the same distorted sound.
I have also tried using default sampling rates and custom and in either case, the audio remains distorted.

How to stream webrtc video from the phone in background

I have an application that allows users to stream video and audio from their phones using webrtc to the server. The streaming should not be interrupted if the device locks down or the app goes to background. Everything works perfectly in the first case. In the second case, however, when I press the home button, audio still works perfectly but the video freezes. Any help would be much appreciated here.
P.S. I'm using ionic with capacitor.

How to keep recording video when device is locked?

I'm working on a video recording app designed to keep recording despite interruptions (phone calls, etc.). My use case would be a user in the app pushing a button on screen to start a recording, and then at some later time manually locking the phone. I'm trying to keep the app recording video even while the phone is locked.
On devices running earlier versions of Android (tested on Android 4.1, DROID 4), the video recording keeps going when the phone has been locked. Testing on various devices, I have been unable to get the video to continue recording on any Android version past 4.1. On devices past 4.1, the video stops recording, but the audio still continues recording, while the last video frame stays on screen.
Is there any way to keep the app recording when the user locks the phone?
Basically, lock screen does not affect the working of services in an application. So if you use a service, then your recording will proceed. check out this link for more information:
Android app video recording when screen off

Icecast: pause in the beginning of streaming on Android

I have a server Icecast working with Liquidsoap to stream internet radio and I noticed there is a problem with receiving the music on some Android devices (Samsung Galaxy tab, for example) - after a few seconds of buffering of the music the playing of the music starts for about a second, then it abruptly stops, then there is a silence for a few more seconds, and only after that it starts playing normally. On some other Android devices, like HTC desire - no such thing occurs - music starts playing normally after the bufferization.
Here is the example of the stream in question: http://rdsradio.ru:8000/4th.mp3
That happens when I open the link in the browser (Google Chrome) on the Android device. With the same result I connected to the Icecast stream from the Android app, which I currently develop, using the android.media.MediaPlayer class: mediaPlayer.setDataSource("http://rdsradio.ru:8000/4th.mp3");
Also, even on those problem devices I could normally connect and listen the streams of other Icecast radio sources, like http://dancewave.hopto.org:9990/dance.mp3
- that is why I think there could be something wrong in my settings of Icecast + Liquidsoap - what makes that music stops playing in the beginning.
<burst-on-connect>1</burst-on-connect>
<burst-size>64000</burst-size>
I tried to change those parameters in /etc/icecast2/icecast.xml, like increasing the burst-size to 10-20 times or setting burst-on-connect to 0, but did not notice any difference at all (I run /etc/init.d/icecast2 reload after changing the parameters to reload the configuration).
Any idea - how to fix that behavior?
UPDATED: I tried to open the stream in VLC player on Android and it worked with no problem, so it seems the problem in using the android.media.MediaPlayer (probably the built-in HTML5 audio player in Google Chrome uses the same library). I will try to use a different Media Player in the app.
Actually, the solution was simple. The burst-size setting to 500000 in icecast.xml fixed the problem. Earlier I used /etc/init.d/icecast2 reload after changing the icecast.xml and for some reason I thought that the burst-size would also change in Icecast in the similar way, but it didn't happen. Only restart of icecast actually changed that setting.

No Video on HLS Stream Android 4.4.2 Samsung Galaxy S5

The HLS streams do not play video, but they do play audio.
Device information:
Samsung Galaxy S5
Android 4.4.2 / Build KOT49H
Chrome 36.0.1985.131
HLS Streams that play on other Android builds and devices:
JWPlayer test videos do not play video:
http://www.jwplayer.com/html5/hls/
These Apple HLS streams also do not play video (but do play audio)
http://devimages.apple.com/iphone/samples/bipbopgear1.html
http://devimages.apple.com/iphone/samples/bipbopgear2.html
http://devimages.apple.com/iphone/samples/bipbopgear3.html
http://devimages.apple.com/iphone/samples/bipbopgear4.html
http://devimages.apple.com/iphone/samples/bipbopall.html
Using the browser application "Internet" on the Samsung S5, it will play the video for an HLS stream, which made me think this could possibly be an issue with Chrome, however, when tested on a Nexus 5 device with the exact same Chrome build (except Android 4.4.4) and the video plays fine.
Android Issue Queue has Issue 63810: No video in HLS live streaming on Android KitKat and I have contributed what I can.
What can I do to get more information about the nature of the problem?
Is this a legitimate bug with the Android 4.4.2 Samsung S5?
I've noticed this behavior among other issues on 4.4.2 with issues seeming to vary by device and manufacturer. Through experimentation I've noticed the following:
Entering or exiting full screen seems to reset the renderer. I suspect this forces the browser to create a new View or something
Reloading the video seems to help the renderer
Changing sources seems to make things worse
Our product works essentially on a playlist -- when the ended event triggers for one video we change the video src and call .load() and .play() to go to the next one. On some devices if the first src is HLS video plays fine, but if the first src is mp4 or webm then switching to HLS causes you to lose video. On other devices it's the opposite behavior -- starting in HLS fails but switching to it succeeds. On some devices HLS has video if you enter full screen before it starts to play, on others it only has video if you enter full screen after it starts to play. On some devices the full screen button disappears after you start to play.
It's not ideal and it's honestly very hacky, but I've come up with this ugly solution:
// 1.
video.addEventListener('click', requestFullScreen);
// 2.
function requestFullScreen() {
video.removeEventListener('click', requestFullScreen);
video.webkitRequestFullScreen();
}
// 3.
function reloadVideo() {
var ext = video.src.substr( video.src.lastIndexOf('.') ).toLowerCase();
if( ext == '.m3u8' ) {
video.load();
video.play();
}
}
// 4.
video.addEventListener('webkitbeginfullscreen', reloadVideo, false);
video.addEventListener('webkitendfullscreen', reloadVideo, false);
// 5.
video.addEventListener('webkitfullscreenchange', reloadVideo, false);
This is to fix the "full screen button disappears after you start playing on some devices" bug
We give this function a name so we can remove it later. If they request to exit fullscreen then they will not blame your player if the full screen button disappears. At this point they'll blame the phone and they'll refresh the page. This way people don't get pissed off if they accidentally fullscreen it again while trying to scroll
A helper function. We don't want to restart videos when going fullscreen unless we have to
The stock Internet browser throws these two events
Chrome throws this event
There are a number of other hacks I've had to implement, as well. For instance, the stock Internet browser on the Galaxy S4 does not always throw an ended event when reaching the end of a video. For this reason I have a setInterval checking every 1 second. If the video has moved less than 0.5 seconds in the last 1 seconds and it was never paused (I have a flag that's set in the resume and pause events) then assume you've hit the end.
I've had success using preload="none". Switching to auto will only play audio, using none will play both video and audio properly. This was tested on a Samsung S3, Android 4.4.2.
EDIT: autoplay also contributes to the problem. Removing it appears necessary.

Categories

Resources