Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Android- Not able to Play audio in background service (startForeground) from the provided sample


Hello

From the answer provided on query (Android - Play audio in background service (startForeground))
https://support.jwplayer.com/customer/en/portal/questions/17032020-android-play-audio-in-background-service-startforeground-?

Want to add more details on this to get clarification.

Member from JW team provided sample source (http://qa.jwplayer.com.s3.amazonaws.com/~george/BackgroundAudioService.zip) from the above link you can check details.

By using sample code from the given link I am getting crash from jwplayerview class and here I've given link for the crash log
https://gist.github.com/adneerav/853af0cc717ead6b16eec443c7eb9145

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.longtailvideo.jwplayer.c.g.a(boolean)' on a null object reference


What else I tried... ?

Removed mPlayerView.onPause(); from onPause method of activity where its giving NPE. and also make some changes to bind and start service.


VideoAcitivity
https://gist.github.com/adneerav/dd822d42cf5e5164259e3b117a082646

Foreground service
https://gist.github.com/adneerav/f76bac3d8f6904f59938b23f7a7a58fc

Here application is not crashing & Service starting in foreground also,but after playing audio in service and if reopen the app after that Player's pause & play method is not functioning from service.

Steps to reproduce Play and pause method not responding.
1)Play Audio from activity
2)Exit from application
3)Play & pause from notification (in this it will work)
4)Open application from notification tap or from launcher icon
5)Repeat Step 4 here(Play button from notification not responding)


Please provide details on above and guide on what I am missing or doing wrong. So I can proceed with the next process.

Thanks

3 Community Answers

George

JW Player Support Agent  
0 rated :

Hi,

If you have a paid account please submit a support ticket from your dashboard. Also, I was unable to reproduce the crash in this project:
http://qa.jwplayer.com.s3.amazonaws.com/~george/BackgroundAudioService.zip

The project above does not have any issues continuing playback from the notification tray.

t...

User  
0 rated :

Hello George,

Thanks for the response.

I don't have Paid account right now. But if the JW player supporting features which are required (& needy) for our Product then we can convert Free to Paid account.And just to check feasibility before converting into PAID I am requesting for your support.

I am stuck with one the main feature like Playing audio in background service.This is one the main feature of Product and of course for any Audio Player application.

So if JW team can provide little bit more support before going in the financial process and paid account process than it would be really helpful.

Now as you mentioned, "The project above does not have any issues continuing playback from the notification tray."

I have just imported the project in Studio and found below result

1)After Starting song if I exit from the application(Close the application by BackPress or in any other way) > Notification GONE from the notification tray and Stopped playing. (Below I've given Recorded Video URL, Dropbox public URL)

2)For me, it's giving crash and I have given the link for the crash log

---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Please check the video to reproduce crash log.
From recorded video its visible that notification is not maintained and service is not in the foreground too.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------

Sample source code download URL: http://qa.jwplayer.com.s3.amazonaws.com/~george/BackgroundAudioService.zip

Video URL to generated crash: https://goo.gl/osrSuo

Crash Log URL: https://goo.gl/wiBwxT

Tested Devices and Android versions Details

Nexus 5X: 6.0.0
Moto G: 5.1.0
Samsung S3: 4.3


Request to give support on this as I need to confirm functionalities and player feasibilities before converting to PAID account.

Thanks.

George

JW Player Support Agent  
0 rated :

That’s interesting, that wasn’t the case when I was testing it, and now it is. The OS used to call onStop only when exiting the activity, now however it’s calling onDestroy.

Overall, this is a development question, this is not an issue with the SDK. You will have to read through the Android docs and see why an Activity marked as a singleTask will call onDestroy etc.

JW Player support does not offer custom code solutions, I just happened to have a demo for background audio.

This question has received the maximum number of answers.