Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9852] iOS: Titanium.Media.AudioPlayer should fire a 'complete' event, when the audio play is over

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2012-07-23T21:06:20.000+0000
Affected Version/sRelease 2.0.2
Fix Version/sn/a
ComponentsTiAPI
Labelsapi
ReporterDavide Cassenti
AssigneeNeeraj Gupta
Created2012-07-02T04:14:02.000+0000
Updated2017-03-14T05:22:59.000+0000

Description

Feature description

When the playback of an audio file with Ti.Media.AudioPlayer object terminates, the object should fire a 'complete' event, similarly to what Ti.Media.Sound does.

Comments

  1. Vishal Duggal 2012-07-10

    Couldn't this be accomplished by just listening for the change event and checking e.state = Ti.Media.AudioPlayer.STATE_STOPPED ?
  2. Blain Hamon 2012-07-19

    Stopped fires whenever the player stops playing, which is likely due to user action or server error, but also when the stream ends. AudioPlayer is often meant for streams that have no end, thus a lack of explicit complete event. To avoid confusing the stream ending than the user manually stopping, try something like this:
       var shouldBePlaying;
       startButton.addEventListener('click',function(){
           shouldBePlaying=true;stream.start();
       });
       startButton.addEventListener('click',function(){
           shouldBePlaying=false;stream.stop();
       });
       stream.addEventListener('change',function(e){
           if(e.description=='stopped'){
               if(shouldBePlaying){
                    alert('Stream complete!');
               }
               shouldBePlaying=false;
           }
       });
       
  3. Blain Hamon 2012-07-23

    Streams are not meant for completion, typically, and worse yet there's little to tell the difference between a finished stream and the server cutting out, in which case 'complete' would be a misnomer.
  4. Lee Morris 2017-03-14

    Closing ticket as invalid.

JSON Source