{"action":"created","issue":{"url":"https://api.github.com/repos/appcelerator/titanium_mobile_windows/issues/497","labels_url":"https://api.github.com/repos/appcelerator/titanium_mobile_windows/issues/497/labels{/name}","comments_url":"https://api.github.com/repos/appcelerator/titanium_mobile_windows/issues/497/comments","events_url":"https://api.github.com/repos/appcelerator/titanium_mobile_windows/issues/497/events","html_url":"https://github.com/appcelerator/titanium_mobile_windows/pull/497","id":121388558,"number":497,"title":"[TIMOB-20035] Implement Ti.Media.AudioPlayer.allowBackground","user":{"login":"garymathews","id":8366993,"avatar_url":"https://avatars.githubusercontent.com/u/8366993?v=3","gravatar_id":"","url":"https://api.github.com/users/garymathews","html_url":"https://github.com/garymathews","followers_url":"https://api.github.com/users/garymathews/followers","following_url":"https://api.github.com/users/garymathews/following{/other_user}","gists_url":"https://api.github.com/users/garymathews/gists{/gist_id}","starred_url":"https://api.github.com/users/garymathews/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garymathews/subscriptions","organizations_url":"https://api.github.com/users/garymathews/orgs","repos_url":"https://api.github.com/users/garymathews/repos","events_url":"https://api.github.com/users/garymathews/events{/privacy}","received_events_url":"https://api.github.com/users/garymathews/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-10T02:39:36Z","updated_at":"2015-12-16T02:40:51Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/appcelerator/titanium_mobile_windows/pulls/497","html_url":"https://github.com/appcelerator/titanium_mobile_windows/pull/497","diff_url":"https://github.com/appcelerator/titanium_mobile_windows/pull/497.diff","patch_url":"https://github.com/appcelerator/titanium_mobile_windows/pull/497.patch"},"body":"- Implemented ```Titanium.Media.AudioPlayer.allowBackground``` functionality\r\n- Added ```AudioBackground``` background task to ```TitaniumWindows_Media```\r\n- Fixed ```CurrentStateChanged``` switch statement\r\n- Added ```Extentions``` support into ```tiapp.xml``` to enable the audio background task\r\n\r\n##### IMPORTANT NOTE\r\n- Both Windows Phone and Windows Store apps require an ```Audio``` _BackgroundTask_ extension in the ```Package.appxmanifest```\r\n- Background audio plays from a separate media player [BackgroundMediaPlayer](https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.playback.backgroundmediaplayer.current.aspx) which means we need to switch between media players when setting the ```allowBackground``` property\r\n\r\n###### tiapp.xml Background Audio Extention\r\n```XML\r\n<windows>\r\n  <manifest>\r\n    <Extentions>\r\n      <Extension Category=\"windows.backgroundTasks\" EntryPoint=\"TitaniumWindows_Media.AudioBackground\">\r\n        <BackgroundTasks>\r\n          <Task Type=\"audio\" />\r\n        </BackgroundTasks>\r\n      </Extension>\r\n    </Extentions>\r\n  </manifest>\r\n</windows>\r\n```\r\n\r\n###### TEST CASE\r\n```Javascript\r\nvar audioPlayer = Ti.Media.createAudioPlayer({url: 'http://media-the.musicradio.com:80/SmoothExtraMP3'}),\r\n    win = Titanium.UI.createWindow({backgroundColor: 'red'}),\r\n    play_btn = Titanium.UI.createButton({title: 'play/pause', top: '33%'}),\r\n    background_btn = Titanium.UI.createButton({title: 'allowBackground: false', top: '66%'});\r\n\r\nplay_btn.addEventListener('click', function() {\r\n    audioPlayer.isPlaying() ? audioPlayer.stop() : audioPlayer.start();\r\n});\r\nbackground_btn.addEventListener('click', function() {\r\n    audioPlayer.setAllowBackground(!audioPlayer.allowBackground);\r\n    background_btn.setTitle('allowBackground: ' + audioPlayer.allowBackground);\r\n});\r\n\r\nwin.add(play_btn);\r\nwin.add(background_btn);\r\nwin.open();\r\n```\r\n\r\n[JIRA Ticket](https://jira.appcelerator.org/browse/TIMOB-20035)"},"comment":{"url":"https://api.github.com/repos/appcelerator/titanium_mobile_windows/issues/comments/164968241","html_url":"https://github.com/appcelerator/titanium_mobile_windows/pull/497#issuecomment-164968241","issue_url":"https://api.github.com/repos/appcelerator/titanium_mobile_windows/issues/497","id":164968241,"user":{"login":"infosia","id":1661068,"avatar_url":"https://avatars.githubusercontent.com/u/1661068?v=3","gravatar_id":"","url":"https://api.github.com/users/infosia","html_url":"https://github.com/infosia","followers_url":"https://api.github.com/users/infosia/followers","following_url":"https://api.github.com/users/infosia/following{/other_user}","gists_url":"https://api.github.com/users/infosia/gists{/gist_id}","starred_url":"https://api.github.com/users/infosia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/infosia/subscriptions","organizations_url":"https://api.github.com/users/infosia/orgs","repos_url":"https://api.github.com/users/infosia/repos","events_url":"https://api.github.com/users/infosia/events{/privacy}","received_events_url":"https://api.github.com/users/infosia/received_events","type":"User","site_admin":false},"created_at":"2015-12-16T02:40:51Z","updated_at":"2015-12-16T02:40:51Z","body":"CR: pass, FT: pass\r\nawesome!"}}