[TIMOB-20035] Windows:Ti.Media.AudioPlayer => allowBackground has no effect
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Resolved |
Resolution | Won't Do |
Resolution Date | 2020-06-30T14:48:35.000+0000 |
Affected Version/s | Release 5.1.0 |
Fix Version/s | n/a |
Components | Windows |
Labels | allowbackground, audioPlayerAPIs, win |
Reporter | Uwe Endesfelder |
Assignee | Christopher Williams |
Created | 2015-08-04T09:42:59.000+0000 |
Updated | 2020-06-30T14:48:35.000+0000 |
Description
the stream starts and plays, but if the app goes to background (tap on windows-button) or device goes into looked-mode the stream stops. the stream starts to play again if the app returns to the foreground. the "allowBackground" feature is set in the doc as available for windows from version 4.1.0.
[~endomedia] please attach a test case and steps to reproduce this issue
*Sample Code:*
And here is a short videoclip from the behaviour on a real windowsphone-device: http://www.endomedia.de/appc/winstream.mp4
PR: https://github.com/appcelerator/titanium_mobile_windows/pull/497
[~gmathews] tested on both windows 8.1 & 10.0 phones and allowBackground does not seem to work, Included the extension in the tiapp.xml and used your sample code, am I missing anything else? on the windows 10 phone I receive the following error when trying to play the stream with allowBackground set to
true
:Tested on: Windows 10 Pro Windows Phone 10.0 & 8.1 (Microsoft Lumia 640 LTE) Appc Studio: 4.6.0.201604081249 Ti SDK: 5.3.0.v20160413061223 Appc NPM: 4.2.5-1 Appc Core: 5.3.0-12 Node: v4.4.2
[~htbryant] Try this in your
tiapp.xml
, it includesExecutable="$targetnametoken$.exe"
[~gmathews] I've included the revised tiapp.xml, and allowBackground still has no effect on a Windows 10 device. The build fails completely when attempting to deploy to a Windows 8.1
Tested on: Windows 10 Pro Windows Phone 10.0 & 8.1 (Microsoft Lumia 640 LTE) Appc Studio: 4.6.0.201605030516 Ti SDK: 5.3.0.v20160503133640 Appc NPM: 4.2.5-5 Appc Core: 5.3.0-43 Node: v4.4.2
[~gmathews] that issue has been addressed but including
Executable="$targetnametoken$.exe"
still causes that error on 8.1. Additionally, allowBackground remains to have any effect whatsoever on windows 10 phones, here is the following test case performed: 1. Launch App. 2. Press "Play" to start stream. 3. Press Windows Home button. 4. Stream cuts out after a few seconds. 5. Return the backgrounded app to the foreground. 6. Stream continues. According to the documentation, allowBackground should allow the audio stream to continue playing even when the app is backgrounded. Tested on: Windows 10 Pro Windows Phone 10.0 & 8.1 (Microsoft Lumia 640 LTE) Appc Studio: 4.6.0.201605030516 Ti SDK: 5.3.0.v20160509143032 Appc NPM: 4.2.5-5 Appc Core: 5.3.0-44 Node: v4.4.4*Reopening ticket* as
allowBackground
has no effect on Windows 10 phone.Note: From my observation it seems Windows 10 mobile always immediately "suspends" the app when app goes background, and that behavior is different from Windows Phone 8.1. On WP8.1 app is not always suspended even when it goes background. And when app is explicitly suspended audio will be stopped (from what I saw). FYI you can suspends the app explicitly if you connect it from Visual Studio. Maybe related: [Suspending app from VS with BackgroundMediaPlayer stops audio](https://social.msdn.microsoft.com/Forums/en-US/fd45b867-1413-4544-adf2-84e5dc78fe95/suspending-app-from-vs-with-backgroundmediaplayer-stops-audio?forum=winappswithcsharp)
The background task seems to be cancelled by a system policy (the
BackgroundTaskCancellationReason
isSystemPolicy
) There are two reasons this could happen: - The number of background audio tasks can be at most 1, at any given time - Due to resource constraints, the system may terminate the background task https://msdn.microsoft.com/en-us/windows/uwp/audio-video-camera/background-audio#system-policies-for-background-audio-task-lifetimeRemoved 5.3.0 target, seems like it's not a trivial fix because it's due to system policy changes on Windows 10. Further investigation will be needed on how to workaround termination of it.
Removed 6.0.0 target. We could close this ticket as "Won't fix" because this is system resource policy changes on Windows 10, but I think it's better to just remove the target for now for further investigation. I will update the API docs to address this limitation soon.