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

iOS: AudioPlayer progress event stops firing when state changes to stopping

    Details

    • Type: Bug
    • Status: Open
    • Priority: None
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: iOS
    • Environment:

      Mac / iPhone simulator and device
      Titanium Studio, build: 3.2.3.201404181442
      sdk-version 3.2.0.GA

      Description

      Problem Description

      AudioPlayer progress event stops firing when state changes to stopping.

      Test Environments

      Ti CLI 3.3.0-rc
      Titanium SDK: 3.3.0.RC, 3.2.X.GA
      iOS Simulator 7.1

      Test Code

      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 audioPlayer = Ti.Media.createAudioPlayer({
      url: 'https://ia600200.us.archive.org/1/items/testmp3testfile/mpthreetest.mp3',
      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();
       
      

      IOS Output

       
      [INFO] : State: starting (1)
      [INFO] : State: waiting_for_data (2)
      [INFO] : State: waiting_for_queue (3)
      [INFO] : State: playing (4)
      [INFO] : Time Played: 360 milliseconds
      [INFO] : Time Played: 1360 milliseconds
      [INFO] : Time Played: 2361 milliseconds
      [INFO] : Time Played: 3360 milliseconds
      [INFO] : Time Played: 4360 milliseconds
      [INFO] : Time Played: 5361 milliseconds
      [INFO] : Time Played: 6360 milliseconds
      [INFO] : Time Played: 7360 milliseconds
      [INFO] : Time Played: 8361 milliseconds
      [INFO] : Time Played: 9360 milliseconds
      [INFO] : State: stopping (6)
      [INFO] : State: stopped (7)
      [INFO] : State: initialized (0)
      

      STEPS TO TEST

      1. Create a new project
      2. Update app.js file with sample code
      4. And run on Android emulator and iOS simulator
      5. Remote audio will play.

      Test Result

      In iOS AudioPlayer progress event stops firing when state changes to stopping

      Thanks

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              oshevans Osian Evans
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Backbone Issue Sync

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

                  Git Integration