Titanium JIRA Archive
Appcelerator Community (AC)

[AC-5309] Android: Ti.Media.AudioPlayer/AudioRecorder

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionFixed
Resolution Date2017-10-25T20:02:58.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterMarian Kucharcik
AssigneeYordan Banev
Created2017-10-25T06:31:20.000+0000
Updated2017-10-25T20:02:58.000+0000

Description

Hi guys, I'm facing a problem. When user taps and holds button(touchstart event), audioRecorder starts recording, when user untap button(touchend event), recording stops and audioPlayer should play that recording. Problem is, that it's playing fine, but audioPlayer's complete event never fires and whole app will freeze and crash. It happens with Ti.Media.audioPlayer and Ti.Media.Sound on android Can you please look at it? Thanks

Comments

  1. Mostafizur Rahman 2017-10-25

    Hello [~max87], Thanks for sharing with us. Can you please share a sample test case to reproduce this on our end? Best
  2. Marian Kucharcik 2017-10-25

    Hi @Mostafizur, try this, basic code:
       var win = Ti.UI.createWindow();
       var recordButton = Ti.UI.createButton({
       	title:"Record",
       	left:10
       });
       win.add(recordButton);
       var playButton = Ti.UI.createButton({
       	title:"Play",
       	right:10
       });
       win.add(playButton);
       var audioRecorder = Ti.Media.createAudioRecorder();
       var record;
       var audioPlayer = Ti.Media.createAudioPlayer();
       var player = Ti.Media.createSound();
       recordButton.addEventListener("touchstart", function()
       {
       		if(!Ti.Media.hasAudioRecorderPermissions)
       		{
       			Ti.Media.requestAudioRecorderPermissions();
       		}
       		else
       		{
       			audioRecorder.start();
       		}
       });
       recordButton.addEventListener("touchend", function(e)
       {
       	record = audioRecorder.stop();
       	player.setUrl(record.getNativePath());
       	player.setVolume(1);
       });
       playButton.addEventListener("click", function()
       {
       	player.play();
       });
       player.addEventListener("change",function(e)
       	{
       		Ti.API.log(e.description);
       	});
       	player.addEventListener("error",function(e)
       	{
       		Ti.API.log(e.error);
       	});
       	player.addEventListener("complete",function(e)
       	{
       		Ti.API.log(e.success); //never fires, app crashes
       	});
       	player.addEventListener("progress",function(e)
       	{
       		var duration = Ti.App.Properties.getString("duration");
       		
       		Ti.API.log("progress: "+e.progress+" / "+duration);
       		if(e.progress == parseInt(duration)) //never get true to stop playing
       		{
       			player.stop();
       			Ti.API.log("player.stop()");
       		}
       	});
       
       
  3. Mostafizur Rahman 2017-10-25

    [~max87], Thanks for your feedback. We are investigating the issue. In the meantime can you please test the sample code from [here](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Media.AudioRecorder) and let us know how it goes.
  4. Marian Kucharcik 2017-10-25

    Hi @Mostafizur of course I tried to implement code from docs... I realized, that rebooting my phone helped and now it's playing correctly(damn you, android :) ). I had some minor problems with recorder too, but I figured it out... Anyway, thanks for your help and have a nice day

JSON Source