[TIMOB-17148] Android: Support "allowBackground" for Ti.Media.VideoPlayer
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2015-01-07T04:52:11.000+0000 |
Affected Version/s | Release 3.2.3 |
Fix Version/s | n/a |
Components | Android |
Labels | Android, AudioPlayer, VideoPlayer, allowBackgr |
Reporter | Fokke Zandbergen |
Assignee | Ingo Muschenetz |
Created | 2014-06-11T13:03:47.000+0000 |
Updated | 2015-01-07T04:52:11.000+0000 |
Description
The
Ti.Media.AudioPlayer
has a property [allowBackground
](http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.Media.AudioPlayer-property-allowBackground) to allow the audio not to be paused with the activity is paused, as implemented in [AudioPlayerProxy.java
on line #226](https://github.com/appcelerator/titanium_mobile/blob/e7334c98aaff370d5bbfa4bfe08656726d43baf9/android/modules/media/src/java/ti/modules/titanium/media/AudioPlayerProxy.java#L226).
Unfortunately, Ti.Media.VideoPlayer
does not have such a property. Though it might sound logical to pause the audio when the user can't see the video anymore, there are use cases where this is not the desired behaviour. Take the TED app, where the audio continues as well since the video is just to support the audio.
It seems to me this could be easily fixed in a similar way in [VideoPlayerProxy.java
around line #668](https://github.com/appcelerator/titanium_mobile/blob/1b98dcd8c45953e5d5e93805594472ea6a9bd23e/android/modules/media/src/java/ti/modules/titanium/media/VideoPlayerProxy.java#L668)
Moving this new feature request to engineering for further evaluation and prioritization.
I looked into this and found out the following:- Ti.Media.VideoPlayer in Android uses VideoPlayerProxy that uses [TiVideoView8 | https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/media/src/java/android/widget/TiVideoView8.java] to play the video. When the Activity is sent to background, the TiVideoView8 has a [surfaceDestroyed | https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/media/src/java/android/widget/TiVideoView8.java#L630] method that destroys the view. This happens when the Activity holding the TiViewView8 goes to onPause (aka Background). The [surfaceDestroyed | https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/media/src/java/android/widget/TiVideoView8.java#L637] also stops and release the MediaPlayer that is used to play the music and show the video. Hence, it is not similar to the AudioPlayerProxy as the AudioPlayerProxy had no View objects being used. Implementing this for the VideoPlayerProxy would not be the same.
Workaround in Javascript for Android. This uses the AudioPlayer to run in the background when the App goes to background.
Closing this ticket and won't be including this in the SDK, considering that it is not of common use case. Please use Ashraf's JS workaround if need be. Will be considered for the SDK in the future if ticket gets more support.
Closing this ticket and won't be including this in the SDK, considering that it is not of common use case. Please use Ashraf's JS workaround if need be. Will be considered for the SDK in the future if ticket gets more support.