jellyfin / jellyfin-android

Android Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
1.45k stars 240 forks source link

Exo- and Webplayer not able to play during phone call #402

Open c0dycode opened 3 years ago

c0dycode commented 3 years ago

Hey there,

# TLDR: Exo- and Webplayer cannot play videos while on a phone call. AFAIK this is due to androids audio focus.

Managed to work around this for ExoPlayer by changing true to false here: https://github.com/jellyfin/jellyfin-android/blob/3e15ad49ba7274d13800370c9061a2159eed4ab6/app/src/main/java/org/jellyfin/mobile/utils/MediaExtensions.kt#L77

Not exactly sure if this would/could introduce any issues, as I'm not really familiar with android development. Therefore am opening an issue instead of a PR. #

this might be just an edge-case for myself and very very few others. So, I frequently am on a call while watching YouTube, Netflix and so on. Unfortunately androids audio focus (AFAIK) often prevents me from doing so, in specific apps.

For example, while on a call I cannot watch videos in a browser. What happens is:

Due to this I currently can only do this with Jellyfin if I use VLC as external player for example. That by itself would be a workaround/solution I'd be fine with. But since I'd like to use SyncPlay eventually with this and I saw #20, I thought this might be worth looking into.

I was able to work around this by passing false as the handleAudioFocus parameter. https://github.com/jellyfin/jellyfin-android/blob/3e15ad49ba7274d13800370c9061a2159eed4ab6/app/src/main/java/org/jellyfin/mobile/utils/MediaExtensions.kt#L77

As I'm not really familiar with android development, I'm not sure what possible issues this might cause. Hence the issue instead of a PR.

The same thing happens with the web-player. Though I have no idea if that behavior can be controlled by Jellyfin at all.

jacobandgeckos commented 1 year ago

I came across this issue after trying to watch a video with a friend on a call. I would also like to be able to use SyncPlay while calling, you aren't the only one!

It looks like that line of code above lets you use exoplayer while calling, but SyncPlay is only supported in the web player.

I'm not an Android developer either, so I don't know how helpful this is but here's my 2 cents:

To fix this, either SyncPlay support would have to be added in exoplayer (#20), or there would have to be some other workaround that lets you watch web videos while being on a call. Either way, seems like this is a nice to have for a few people but might not be worked on soon (this kind of thing may be on hold for the Playback Rewrite)

This Stackoverflow Answer says that using Audio Focus, two different apps can output to the same stream. (I imagine phone calls are a particular type of stream which might complicate this?) But, the answer also points out that the default behavior on android is one app playing audio at a time, and other behavior could be annoying to a user who doesn't expect it.

ebkalderon commented 10 months ago

For anyone looking for a temporary workaround: I was able to get the desired behavior by switching over to Findroid instead (a third-party Jellyfin client app) and switched on the experimental mpv backend in the settings. With this setting enabled, I am able to play back video during ongoing voice calls.

EDIT: Also, I echo the above sentiment that this behavior is something that the Jellyfin app could control. For instance, MX Player (one of the recommended external players mentioned by name in the Jellyfin Android app's "video player type" setting, along with VLC) has a relevant checkbox called "Play alone" in the settings. If this box is unchecked, MX Player behaves identically to other media apps (e.g. VLC, YouTube, the default Samsung Video Player) and permits audio/video playback during an ongoing phone call.