katzer / cordova-plugin-background-mode

Keep app running in background
Apache License 2.0
1.38k stars 1.02k forks source link

Audio streaming in background is not working #239

Open abelrsuing opened 7 years ago

abelrsuing commented 7 years ago

We are using the mediaelementjs.com (Audio Player) in our Cordova Android project.

vibhor-daffodil commented 7 years ago

I'm using Media Plugin for Streaming, the app is working good in Android (When Background Mode is Active & also When the Background Mode is Inactive)

But in iOS, When the app goes in Background Mode, I'm PAUSING the Stream, the Media get Paused

But when I tried I tried to PLAY it again it gives MEDIA_ERROR code = 4

srsarcasmo commented 7 years ago

Friend, I have an equal problem but it is with the sending of data to web service;

I in particular use javascript for my thread execution, what are you using?

As a solution to my problem I started to use an alarm type plugin, which allows me to execute functions every time in the background

vibhor-daffodil commented 7 years ago

I'm using this plugin in Ionic 2.

Actually, The functionality that is going on Background Mode are (Live Audio Streaming, Receiving Data from Web Service, TTS)

Live Streaming Music is Playing in Background mode and simultaneously data is also coming from Server.

If any change occurs from SERVER Side, then Live Streaming Music will be PAUSED & TTS will vocalise the changes, When vocalisation is completed then Live Streaming Music will be PLAYED again

Now, when I PLAY it again, the app will crash

srsarcasmo commented 7 years ago

Very well I recommend using the background_geolocation_master plugin Est eplugin what it does is keep your app in the background, without returning a calback; So I can see you can initialize your audio streaming service when the application starts and in turn using this plugin keep everything in the background

srsarcasmo commented 7 years ago

`function nativo_a_javascript(){ document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { navigator.geolocation.getCurrentPosition(function() { }, function(error) { calldialog(); // cuando no esta GPS encendido, pedimos encenderlo });

var bgLocationServices = window.plugins.backgroundLocationServices; bgLocationServices.configure({ //Both android and ios desiredAccuracy: 10, //Precisión deseada de las actualizaciones de ubicación (menor significa más exacta pero más consumo de batería) distanceFilter: 0, //(Medidores) Hasta qué punto debe moverse desde el último punto para activar una actualización de ubicación debug: false, // <--Habilitar para mostrar las indicaciones visuales cuando recibe una actualización de la ubicación de fondo interval: 240000, //(Milisegundos) Intervalo solicitado entre actualizaciones de ubicación. useActivityDetection: false, // Utiliza la detección de Actividad para apagar los gps cuando todavía está (mejora enormemente la duración de la batería)

 //Android Only
 notificationTitle: 'StarUp', // title of the notification
 notificationText: 'Android Service', //text of the notification
 fastestInterval: 240000 // <--(Milisegundos) Intervalo más rápido que su aplicación o servidor puede manejar actualizaciones

});

//Registrar una devolución de llamada para las actualizaciones de ubicación, aquí es donde los objetos de ubicación se enviarán en segundo plano bgLocationServices.registerForLocationUpdates(function(location) { inicio_notif_bg ();

}, function(err) { // alert("Error: Didnt get an update ForLocationUpdates", err); });

bgLocationServices.registerForActivityUpdates(function(activities) { // alert("We got an activity update" + activities); }, function(err) { }); bgLocationServices.start(); } }`