Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17331] iOS: AudioPlayer progress event stops firing when state changes to stopping

GitHub Issuen/a
TypeBug
PriorityNone
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
LabelsAudioPlayer, change, progress, stopped, stopping
ReporterOsian Evans
AssigneeUnknown
Created2014-07-10T20:05:56.000+0000
Updated2018-02-28T20:03:11.000+0000

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

Comments

  1. Osian Evans 2014-07-10

    *CODE SAMPLE* {noformat} var audioPlayer = Ti.Media.createAudioPlayer({ url: "https://ia600200.us.archive.org/1/items/testmp3testfile/mpthreetest.mp3" // THIS AUDIO IS 12 SECONDS LONG }); audioPlayer.addEventListener('progress', function(e) { // THIS ONLY GOES UP TO AROUND 9 SECONDS Ti.API.info('AUDIO : Time Played ('+e.progress+') : approx ' + Math.round(e.progress/1000) + ' seconds'); }); audioPlayer.addEventListener('change', function(e) { Ti.API.info('AUDIO : change : '+e.description+' ('+e.state+')'); }); audioPlayer.start(); {noformat} This produces the following output : {noformat} [INFO] AUDIO : change : starting (1) [INFO] AUDIO : change : waiting_for_data (2) [INFO] AUDIO : change : waiting_for_queue (3) [INFO] AUDIO : change : playing (4) [INFO] AUDIO : Time Played (574.5804988662132): 1 seconds [INFO] AUDIO : Time Played (1574.5351473922901): 2 seconds [INFO] AUDIO : Time Played (2574.603174603175): 3 seconds [INFO] AUDIO : Time Played (3574.5351473922906): 4 seconds [INFO] AUDIO : Time Played (4574.557823129251): 5 seconds [INFO] AUDIO : Time Played (5574.557823129251): 6 seconds [INFO] AUDIO : Time Played (6574.53514739229): 7 seconds [INFO] AUDIO : Time Played (7574.557823129251): 8 seconds [INFO] AUDIO : Time Played (8574.53514739229): 9 seconds [INFO] AUDIO : change : stopping (6) [INFO] AUDIO : change : stopped (7) [INFO] AUDIO : change : initialized (0) {noformat}
  2. Mauro Parra-Miranda 2014-07-15

    Thanks for you report! The priority will be set by the platform team.
  3. Shameer Jan 2014-08-14

    Issue reproduces Titanium Command-Line Interface, CLI version 3.3.0, Titanium SDK version 3.3.0.GA iOS SDK: 7.1 iOS iPhone Simulator: 7.1

JSON Source