Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16787] iOS: AudioPlayer crashes with local mp3 files

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionCannot Reproduce
Resolution Date2016-10-19T12:06:00.000+0000
Affected Version/sRelease 3.2.2
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterKrish
AssigneeEric Merriman
Created2014-03-28T07:16:45.000+0000
Updated2017-03-24T21:57:15.000+0000

Description

Whenever I tried to play music on iOS Simulator, the app crashes. (The application close itself).
 
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();
audioPlayer.url = '/dn2.mp3';
    
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();

Comments

  1. Krish 2014-03-28

    Found that it crashes when source (music file is stored in local) is local.
  2. Ritu Agrawal 2014-03-28

    Moving this ticket to engineering for further evaluation as I can reproduce the crash with the provided test case. It is related but not duplicate of TIMOB-9409 because that is about inability to play mp3 files and this one just crashes the application.
  3. Shameer Jan 2014-08-28

    Issue still exists with SDK Version 3.2.2 and 3.4.0 Titanium Command-Line Interface, CLI version 3.3.0, Titanium SDK version 3.2.2.GA Titanium SDK version 3.4.0.GA Appcelerator Studio, build: 3.3.0.201407111535 iOS SDK: 7.0.3
  4. Hans Knöchel 2016-10-19

    Cannot reproduce with Titanium SDK 5.5.1.GA and iOS 10 anymore.
  5. Lee Morris 2017-03-24

    Closing ticket as the issue cannot be reproduced and with reference to the previous comments.

JSON Source