Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-1608

Android: Audio not stopped on incoming call

    Details

      Description

      Issue

      createAudioPlayer() do not stop audio playback on an incoming. No events actually passed through these objects in order to check for calls.

      Target environment

      TiSDK 3.1.1.GA & new HTC One/Android 4.1.2

      Sample

      To reproduce run snippet, start audio playback then call to phone.

      var win = Titanium.UI.createWindow({  
          title:'Audio Test',
          backgroundColor:'#fff',
          layout: 'vertical'
      });
       
      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:false
      });
       
      win.add(startStopButton);
      win.add(pauseResumeButton);
       
      // allowBackground: true on Android allows the 
      // player to keep playing when the app is in the 
      // background. 
      var audioUrl = 'http://broadcast.infomaniak.net:80/energyzuerich-high.mp3';
      var audioPlayer = Ti.Media.createAudioPlayer({ 
          url: audioUrl,
          allowBackground: true
      });           
          
      startStopButton.addEventListener('click',function() {
          // When paused, playing returns false.
          // If both are false, playback is stopped.
          if (audioPlayer.playing || audioPlayer.paused)
          {
              audioPlayer.stop();
              pauseResumeButton.enabled = false;
              if (Ti.Platform.name === 'android')
              { 
                  audioPlayer.release();
              }   
          }
          else
          {
              audioPlayer.start();
              pauseResumeButton.enabled = true;
          }
      });
       
      pauseResumeButton.addEventListener('click', function() {
          if (audioPlayer.paused) {
              audioPlayer.start();
          }
          else {
              audioPlayer.pause();
          }
      });
       
      audioPlayer.addEventListener('progress',function(e) {
          Ti.API.info('Time Played: ' + Math.round(e.progress) + ' milliseconds');
      });
       
      audioPlayer.addEventListener('change',function(e)
      {
          Ti.API.info('State: ' + e.description + ' (' + e.state + ')');
      });
       
      win.addEventListener('close',function() {
          audioPlayer.stop();
          if (Ti.Platform.osname === 'android')
          { 
              audioPlayer.release();
          }
      });
       
      win.open();
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pwang Ping Wang
                Reporter:
                andrewheebner Andrew Heebner
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-1456
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration