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

Android: On 5.0.1 AudioPlayer stream starts takes about 10 seconds

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Cannot Reproduce
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Android
    • Environment:

      SDK: 3.5.1.GA, 4.1.0.v20150325213629

    • Story Points:
      1

      Description

      On Android 5.0.1 (Samsung Galaxy S4) device it takes up to 10 seconds before a Titanium.Media.AudioPlayer remote stream starts playing audio. Same device, same APK but wiht Android 4.4 installed no issues! Both installs 5.0.1 and 4.4 were factory resets of the phone.

      Nexus 6 with Android 5.1 with same APK: no issues.
      Playback of stream (SHOUTcast) starts immediately.

      See sample code + attached logs for both Galaxy S4 + Nexus 6.

      logs

      Ti SDK 3.5.1.GA / Motorola Nexus 6 - Android 5.1
      Audio is playing within a couple of milliseconds ...
      ======================================================
      [INFO] : 16/4/2015-15:00:01.869 DEBUG: audioPlayer.start()
      [INFO] : 16/4/2015-15:00:01.884 DEBUG: State: starting (4)
      [ERROR] : MediaPlayer: Should have subtitle controller already set
      [INFO] : 16/4/2015-15:00:01.974 DEBUG: State: initialized (1)
      [INFO] : 16/4/2015-15:00:01.975 DEBUG: State: playing (3)
      [INFO] : 16/4/2015-15:00:02.976 DEBUG: Time Played: 885 milliseconds
      [INFO] : 16/4/2015-15:00:03.976 DEBUG: Time Played: 1886 milliseconds
      [INFO] : 16/4/2015-15:00:04.979 DEBUG: Time Played: 2887 milliseconds

      Ti SDK 3.5.1.GA / Samsung Galaxy S4 - Android 5.0.1
      It takes up to 9 (:16.135 ~ :25.136) seconds before audio is initialized
      ======================================================
      [INFO] : 16/4/2015-14:56:16.135 DEBUG: audioPlayer.start()
      [ERROR] : E/ExtMediaPlayer-JNI: QCMediaPlayer could not be located....
      [ERROR] : E/MediaPlayer-JNI: QCMediaPlayer mediaplayer NOT present
      [INFO] : 16/4/2015-14:56:16.177 DEBUG: State: starting (4)
      [INFO] : I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
      [INFO] : I/System.out: (HTTPLog)-Static: isShipBuild true
      [INFO] : I/System.out: (HTTPLog)-Thread-4268-418455975: SmartBonding Enabling is false, SHIP_BUILD is true, log to file is false, DBG is false
      [INFO] : I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
      [INFO] : I/System.out: KnoxVpnUidStorageknoxVpnSupported API value returned is false
      [WARN] : MediaPlayer: info/warning (973, 0)
      [ERROR] : MediaPlayer: Should have subtitle controller already set
      [INFO] : 16/4/2015-14:56:25.134 DEBUG: State: initialized (1)
      [INFO] : 16/4/2015-14:56:25.136 DEBUG: State: playing (3)
      [WARN] : MediaPlayer: info/warning (702, 0)
      [INFO] : 16/4/2015-14:56:26.139 DEBUG: Time Played: 837 milliseconds
      [INFO] : 16/4/2015-14:56:27.139 DEBUG: Time Played: 1826 milliseconds
      [INFO] : 16/4/2015-14:56:28.134 DEBUG: Time Played: 2828 milliseconds

      app.js

      function getDateTimeString(secs,msecs) {
          
          var sDate = '';
          
          if(msecs == undefined) msecs = false;
          if(secs == undefined) secs = false;
          var date = new Date();
          sDate +=  date.getDate()+ '/' + String((date.getMonth()+1)) + '/' + date.getFullYear();
          var minutes = date.getMinutes();
          if (minutes < 10) minutes = String( '0' + minutes);
          sDate += '-' + date.getHours()+':'+ minutes;
          if (secs) {
              secs = date.getSeconds();
              if (secs < 10) secs = String( '0' + secs);
              sDate += ':' + secs;
          }
          if (msecs) {
              msecs = date.getMilliseconds();
              if (msecs < 10) msecs = String( '0' + msecs);
              sDate += '.' + msecs;
          }
          
          return sDate + ' ';
      }
       
      function log(msg) {
          Ti.API.info(getDateTimeString(true,true) + 'DEBUG: ' + msg);
      }
       
      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: 'http://eu7.fastcast4u.com:8128/stream?' + (new Date()).getTime(), 
          //Adding timestamp GET param to the url because of issue: https://jira.appcelerator.org/browse/TIMOB-18297
          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.url = 'http://eu7.fastcast4u.com:8128/stream?' + (new Date()).getTime();
              //Adding timestamp GET param to the url because of issue: https://jira.appcelerator.org/browse/TIMOB-18297
              log('audioPlayer.start()');
              audioPlayer.start();
              pauseResumeButton.enabled = true;
          }
      });
       
      pauseResumeButton.addEventListener('click', function() {
          if (audioPlayer.paused) {
              audioPlayer.start();
          }
          else {
              audioPlayer.pause();
          }
      });
       
      audioPlayer.addEventListener('progress',function(e) {
         log('Time Played: ' + Math.round(e.progress) + ' milliseconds');
      });
       
      audioPlayer.addEventListener('change',function(e)
      {
          log('State: ' + e.description + ' (' + e.state + ')');
      });
       
      win.addEventListener('close',function() {
          audioPlayer.stop();
          if (Ti.Platform.osname === 'android')
          { 
              audioPlayer.release();
          }
      });
       
      win.open();
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              karaoak Frank Eijking
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

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

                  Git Integration