Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16638] Android: Unable to determine audio playback position with createAudioPlayer

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2014-09-04T07:40:22.000+0000
Affected Version/sRelease 3.2.2
Fix Version/sRelease 3.3.0, Release 3.4.0
ComponentsAndroid
Labelsn/a
ReporterScott Blum
AssigneeIngo Muschenetz
Created2014-03-17T21:55:58.000+0000
Updated2014-09-12T22:35:29.000+0000

Description

I’m porting over a Titanium application to Android that currently works on iOS that essentially plays streaming audio files. For some reason I’m getting stuck on the very simple task of determining the current playback position of the audio file being played. The first part works fine, just simply playing a streaming audio file: sound = Ti.Media.createAudioPlayer({ url: ‘http://server.com/audiofile.mp3' }); sound.play(); Then, I created a simple Interval routine that runs every second and shows what the “time”, “getTime”, and “progress” variables are showing. The documentation says that “time” and “getTime” are for Android only, and the “progress” is for iOS only. As expected, the “progress” variable says “undefined”, which makes sense. But “time” and “getTime” shows as “0” constantly. var tempIntCount = 0; trackTempInterval = setInterval(function() { tempIntCount++; var tv2 = sound2.getTime(); status.text = tempIntCount+'-'+sound2.time+'-'+tv2+'-'+sound2.progress; },1000); You’ll see that I’m also incrementing my own variable “tempIntCount” every second just to make sure it’s alive, and that works perfectly. Since the Titanium documentation says that the “time” variable requires Android 3.3, I’ve also added the following in the tiapp.xml file which doesn’t seem to help: http://schemas.android.com/apk/res/android">

Comments

  1. Ritu Agrawal 2014-03-18

    Moving this ticket to engineering as I can reproduce this issue with the following simple test case on Android.
       sound = Ti.Media.createAudioPlayer({
           url: 'http://www.televisiontunes.com/themesongs/The%20Gadget%20Show.mp3'
       });
       sound.play();
        
       var tempIntCount = 0;
       trackTempInterval = setInterval(function() {
           tempIntCount++;
           console.log('Current position:' + sound.time);
           console.log('Current position:' + sound.getTime());
           console.log('Current count: ' + tempIntCount);
       },1000);
       
  2. jithinpv 2014-09-04

    cannot reproduce in Titanium SDK version 3.4.0 master, 3.3.0.GA Issue reproduces in Titanium SDK version 3.2.2.GA, 3.2.3.GA Titanium Studio, build: 3.3.0.201407100905 Titanium Command-Line Interface CLI version 3.3.0, Android device : Motorola Moto G, Android version : 4.4.4
  3. Lokesh Choudhary 2014-09-12

    Verified the fix. Now we can determine audio playback position. Closing. Environment: Appc Studio : 3.4.0.201409112242 Ti SDK : 3.4.0.v20140912120914 Mac OSX : 10.9.4 Alloy : 1.5.0-rc CLI - 3.4.0-rc2 Code Processor: 1.1.1 Sony Experia - android 4.1.2 Nexus 5 - android 4.4.4

JSON Source