Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15598] Tizen: Cannot play audio in the background when the app is minimized or when the lockscreen is on.

GitHub Issuen/a
TypeStory
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2013-11-12T16:28:13.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTizen
Labelsn/a
ReporterRicardo Alcocer
AssigneeIngo Muschenetz
Created2013-10-28T19:05:58.000+0000
Updated2017-03-16T20:30:53.000+0000

Description

User is not able to play audio in the background when the app is minimized or when the lockscreen is on.

Comments

  1. Ingo Muschenetz 2013-10-28

    Can we get steps to reproduce the issue?
  2. Josh Lewis 2013-10-28

    Hi Ingo, Here is the code for the appropriate page. It's pretty standard, and works well with iOS and Android, but with Tizen, as soon as the lockscreen is engaged, or the home button is clicked, audio cuts off. I'm testing on an actual device, I can't run the emulator until HAXM is updated for Maverick
       var win = Titanium.UI.currentWindow;
       var media = win.response; //this object contains all information (artist, song name, url, etc.  All works)
       Ti.App.player.url = media.item_play_url;  /The player is created in app.js so it is global.  Tried making it local to this JS file, no change
       
       
       Ti.App.player.play();
       	
       
       var artist_label = Titanium.UI.createLabel({
                       color : '#000',
                       right : 0,
                       left : 0,
                       top : 0,
                       text : media.item_artist_name,
                       textAlign:'center',
                       height : Ti.UI.SIZE,
                       className : 'row',
                       font : {
                           fontFamily : 'Helvetica Neue',
                           fontSize : '30dp',
                           fontWeight : 'bold'
                       }
       });win.add(artist_label);
       
       var album_label = Titanium.UI.createLabel({
                       color : '#000',
                       right : 0,
                       left : 0,
                       top : 0,
                       text : media.item_album_name,
                       textAlign:'center',
                       height : Ti.UI.SIZE,
                       className : 'row',
                       font : {
                           fontFamily : 'Helvetica Neue',
                           fontSize : '24dp',
                           fontWeight : 'bold'
                       }
       });win.add(album_label);
       
       
       var song_label = Titanium.UI.createLabel({
                       color : '#000',
                       right : 0,
                       left : 0,
                       top : 0,
                       text : media.item_song_name,
                       textAlign:'center',
                       height : Ti.UI.SIZE,
                       className : 'row',
                       font : {
                           fontFamily : 'Helvetica Neue',
                           fontSize : '18dp',
                           fontWeight : 'bold'
                       }
       });win.add(song_label);
       
       var startStopButton = Titanium.UI.createButton({
           title:'Start/Stop Streaming',
           top:10,
           width:200,
           height:40
       });
       
       var pauseResumeButton = Titanium.UI.createButton({
           title:'Pause/Resume Streaming',
           top:10,
           width:200,
           height:40,
           enabled:true
       });
       
       win.add(startStopButton);
       win.add(pauseResumeButton);
       
       // allowBackground: true on Android allows the 
       // player to keep playing when the app is in the 
       // background.
           
       startStopButton.addEventListener('click',function() {
           // When paused, playing returns false.
           // If both are false, playback is stopped.
           if (Ti.App.player.playing || Ti.App.player.paused)
           {
               Ti.App.player.stop();
               Ti.App.player.url = media.item_play_url;
               Ti.App.player.start();
               pauseResumeButton.enabled = true;
               if (Ti.Platform.name === 'android')
               { 
                   Ti.App.player.release();
               }   
           }
           else
           {
           	Ti.App.player.url = media.item_play_url;
               Ti.App.player.start();
               pauseResumeButton.enabled = true;
           }
       });
       
       pauseResumeButton.addEventListener('click', function() {
           if (Ti.App.player.paused) {
               Ti.App.player.start();
           }
           else {
               Ti.App.player.pause();
           }
       });
       
       Ti.App.player.addEventListener('progress',function(e) {
           Ti.API.info('Time Played: ' + Math.round(e.progress) + ' milliseconds');
       });
       
       Ti.App.player.addEventListener('change',function(e)
       {
           Ti.API.info('State: ' + e.description + ' (' + e.state + ')');
       });
       
  3. Josh Lewis 2013-10-31

    Hi Ingo, Have you had time to figure out a fix for this?
  4. Ingo Muschenetz 2013-11-11

    [~joshlewis] According to our research this is expected behavior for web-based apps where the audio stops. Evidently the Samsung app store reviewers block app that continue play music after window go to background. Do you have information that says otherwise?
  5. Josh Lewis 2013-11-11

    Hi Ingo, I've read the same, but I assumed creating a Tizen app would make this native, and not web-based. Is that not the case?
  6. Josh Lewis 2013-11-11

    Ingo, according to a contact at Samsung, they have another developer who is working on a music app, and it plays in the background and when the screen is locked.
  7. Ingo Muschenetz 2013-11-11

    Is it a web app or a native app? To your previous question, Tizen has two versions, a web version and a native version. The web came first, and that is the platform we implemented. Samsung followed with a native platform and we will look at supporting that in the future.
  8. Josh Lewis 2013-11-12

    I believe there's is native, and I assumed that Appcelerator's was well..
  9. Josh Lewis 2013-11-12

    Hi Ingo, Just an FYI, I was able to get it working. In the tiapp.xml file, in the tizen group, you have to add
       <tizen:setting background-support="enable" />
       
    And it will play in the background, and while navigating other apps.
  10. Ingo Muschenetz 2013-11-12

    Great to hear. I'll mark this ticket as invalid since all it was was a configuration issue, but let me know if we need to do anything else.
  11. Lee Morris 2017-03-16

    Closing ticket as invalid.

JSON Source