{ "id": "131591", "key": "TIMOB-17148", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "2", "description": "The problem described is an issue which will never be fixed.", "name": "Won't Fix" }, "resolutiondate": "2015-01-07T04:52:11.000+0000", "created": "2014-06-11T13:03:47.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "Android", "AudioPlayer", "VideoPlayer", "allowBackgr" ], "versions": [ { "id": "15971", "description": "Release 3.2.3", "name": "Release 3.2.3", "archived": false, "released": true, "releaseDate": "2014-04-30" } ], "issuelinks": [], "assignee": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2015-01-07T04:52:11.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "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].\r\n\r\nUnfortunately, {{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.\r\n\r\nIt 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]", "attachment": [], "flagged": false, "summary": "Android: Support \"allowBackground\" for Ti.Media.VideoPlayer", "creator": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "subtasks": [], "reporter": { "name": "fokkezb", "key": "fokke", "displayName": "Fokke Zandbergen", "active": true, "timeZone": "Europe/Amsterdam" }, "environment": "SDK 3.3.0.Beta", "comment": { "comments": [ { "id": "308725", "author": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Moving this new feature request to engineering for further evaluation and prioritization.", "updateAuthor": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-06-12T18:34:39.000+0000", "updated": "2014-06-12T18:34:39.000+0000" }, { "id": "337731", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "I looked into this and found out the following:-\r\n\r\nTi.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).\r\n\r\nThe [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.\r\n\r\nHence, 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.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-01-02T04:05:03.000+0000", "updated": "2015-01-02T04:05:03.000+0000" }, { "id": "337743", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Workaround in Javascript for Android. This uses the AudioPlayer to run in the background when the App goes to background.\r\n\r\n{code}\r\nvar vidWin = Titanium.UI.createWindow({\r\n title : 'Video View Demo',\r\n backgroundColor : '#fff'\r\n});\r\n\r\nvar videoPlayer = Titanium.Media.createVideoPlayer({\r\n top : 2,\r\n autoplay : true,\r\n backgroundColor : 'blue',\r\n allowBackground: true,\r\n height : 300,\r\n width : 300,\r\n mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT,\r\n scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FIT\r\n});\r\n\r\nvar currentPlaybackTime = 0;\r\n\r\nvar basicSwitch = Ti.UI.createSwitch({\r\n titleOn:'On BG',\r\n titleOff:'Off BG',\r\n value:true,\r\n width: 200, height:120\r\n});\r\n\r\nvar urlToPlay = 'rtsp://r7---sn-a5m7zu76.c.youtube.com/CiILENy73wIaGQlD0rwH11uU1RMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp';\r\n\r\nvideoPlayer.url = urlToPlay;\r\nvidWin.add(videoPlayer);\r\nvidWin.add(basicSwitch);\r\n\r\n// allowBackground: true on Android allows the \r\n// player to keep playing when the app is in the \r\n// background.\r\nvar audioPlayer = Ti.Media.createAudioPlayer({ \r\n url: urlToPlay,\r\n allowBackground: true\r\n}); \r\n\r\nvidWin.addEventListener('blur', function() {\r\n\tTi.API.info('Closing VideoPlayer at Time Played: ' + Math.round(videoPlayer.getCurrentPlaybackTime()) + ' milliseconds');\r\n\tif(basicSwitch.getValue()) {\r\n\t\tcurrentPlaybackTime = videoPlayer.getCurrentPlaybackTime();\r\n\t\taudioPlayer.setTime(currentPlaybackTime);\r\n\t\taudioPlayer.start();\r\n\t}\r\n});\r\n\r\nvidWin.addEventListener('focus', function() {\r\n\tTi.API.info('Closing AudioPlayer at Time Played: ' + Math.round(audioPlayer.getTime()) + ' milliseconds');\r\n\tif(basicSwitch.getValue()) {\r\n\t\tcurrentPlaybackTime = audioPlayer.getTime();\r\n\t audioPlayer.stop();\r\n\t audioPlayer.release();\r\n\t\tvideoPlayer.setCurrentPlaybackTime(currentPlaybackTime);\r\n\t}\r\n});\r\n\r\naudioPlayer.addEventListener('complete', function() {\r\n Ti.API.info('Audio ended at: ' + Math.round(audioPlayer.getTime()) + ' milliseconds');\r\n});\r\n\r\nvidWin.open();\r\n\r\n{code}", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-01-02T09:34:11.000+0000", "updated": "2015-01-02T09:34:11.000+0000" }, { "id": "338131", "author": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "body": "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.", "updateAuthor": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-01-07T04:51:37.000+0000", "updated": "2015-01-07T04:51:37.000+0000" }, { "id": "338132", "author": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "body": "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.", "updateAuthor": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-01-07T04:52:11.000+0000", "updated": "2015-01-07T04:52:11.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }