[TIMOB-16638] Android: Unable to determine audio playback position with createAudioPlayer
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-09-04T07:40:22.000+0000 |
Affected Version/s | Release 3.2.2 |
Fix Version/s | Release 3.3.0, Release 3.4.0 |
Components | Android |
Labels | n/a |
Reporter | Scott Blum |
Assignee | Ingo Muschenetz |
Created | 2014-03-17T21:55:58.000+0000 |
Updated | 2014-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">
Moving this ticket to engineering as I can reproduce this issue with the following simple test case on Android.
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
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