Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4992] iOS:AudioPlayer only plays part of an mp3

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionCannot Reproduce
Resolution Date2020-01-09T19:18:15.000+0000
Affected Version/sRelease 1.7.2, Release 6.0.1, Release 5.5.1, Release 6.0.2
Fix Version/sn/a
ComponentsiOS
Labelsapi, engSchedule, regression, supportTeam
ReporterJon Alter
AssigneeUnknown
Created2011-08-12T15:54:08.000+0000
Updated2020-01-09T19:18:15.000+0000

Description

Playing certain mp3s causes a problem for AudioPlayer and it only plays about half a second at the beginning of the file. Step 1: put the attached audio files on a server that you can access Step 2: change the url in the code so that you can access the files that you are serving Step 3: run the code below Step 4: click the play button Step 5: notice that the file named bad.mp3 does not play the entire file Step 6: test that file by playing it with another audio player
var win = Ti.UI.createWindow({
	backgroundColor: "blue"
});

var button = Ti.UI.createButton({
	title: "play",
	height: 40,
	width: 200,
	top: 20
});

button.addEventListener('click', function(e){
	var player = Titanium.Media.createAudioPlayer({
		url:'http://example.com/bad.mp3'
	});
	player.start();
});
win.add(button);
win.open();

Associated Helpdesk Ticket

http://appc.me/c/APP-667978

Attachments

FileDateSize
bad.mp32011-08-12T15:54:08.000+000023795
good.mp32011-08-12T15:54:08.000+000045998

Comments

  1. Junaid Younus 2012-07-12

    Tested on the iOS simulator with 2.1GA, issue still exists.
  2. Sharif AbuDarda 2016-10-25

    Hello, The issue seems to be happening for remote audio. Audio player stops in somewhere for a large audio file> 30+min. The below code can regenerate the issue for iOS and Android
       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: 'http://www.revelbeats.com/assets/audio/Salsa/Dj_Norty_Cotto%20_Salsa_Throwback.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();
       
       Operating System
         Name                        = Mac OS X
         Version                     = 10.11.6
         Architecture                = 64bit
         # CPUs                      = 4
         Memory                      = 8589934592
       Node.js
         Node.js Version             = 4.2.2
         npm Version                 = 2.14.7
       Titanium CLI
         CLI Version                 = 5.0.9
       Titanium SDK
         SDK Version                 = 5.5.1.GA
       
    Any workaround for playing such big files in audio player smoothly?
  3. Alan Hutton 2019-08-13

    Closing. Unable to reproduce. mp3 files are playing fully. I have also not been able to reproduce the remote audio file issue.

JSON Source