Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27105] Android:Ti.Media.Sound is triggering error event handler

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionInvalid
Resolution Date2019-08-20T17:13:58.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterRakhi Mitro
AssigneeJoshua Quick
Created2019-05-28T14:47:57.000+0000
Updated2019-08-20T17:13:58.000+0000

Description

In project, the customer is trying to download an audio file from server and playing it in Android application. In Android, with Titanium.Media.Sound API they are observing “error” event handler is being fired, even though the Audio is playing correctly. And this behaviour is being observed only in *Samsung S4 with OS version 4.4.2, Samsung G6 with OS version 8.0.0 and Samsung J7 with Os version 7.1.0*.  And it is working fine with out firing error event handler in Nexus with OS version 6.0.1, Google pixel with OS version 9.0.  *Note:* The customer's app is currently running with 7.5.2.GA . The issue is tested on our end with SDK 7.5.2.GA and 8.0.1.GA. The “error” event handler is being fired on *Samsung J7 Prime2 v8.0.0 device.* Test code:
var accessToken;
var win = Ti.UI.createWindow({
	title : "Main window",
	backgroundColor : "white" 
});
var button = Ti.UI.createButton({
	title : "Audio"
});
button.addEventListener('click', function(e) {
	var sound = Titanium.Media.createSound({
		url: "SampleAudio.mp3",  
		allowBackground : true,
		volume : 1.0
	});
	sound.play();
	sound.addEventListener('complete', function(evt1) {
		sound.release();
	});
	sound.addEventListener('error', function(evt2){
		Ti.API.info('Error in sound::'+JSON.stringify(evt2));
		if (evt2.error.toLowerCase().trim() === 'unknown media issue.') {
			return;
		} else {
			dialog = Ti.UI.createAlertDialog({
				message : "Audio failed",
				buttonNames : ['OK']
			});
			dialog.show();
			sound.release();
		}
	});
});
win.add(button);
win.open();

*Test steps:* 1.Create a classic app and replace app.js with the attached app.js file.  2. Download the sample audio file and place in Resources/android folder.  3.Run the app , "Click Audio" and you will observe the issue. 
[INFO]  Error in sound::{"type":"error","source":{"volume":1,"url":"file:///android_asset/Resources/SampleAudio.mp3","time":0,"playing":true,"audioType":0,"looping":false,"paused":fals
e,"duration":27745,"apiName":"Ti.Media.Sound","bubbleParent":true,"allowBackground":true,"state":3,"stateDescription":"playing","_events":{"complete":{},"error":{}}},"bubbles":false,"success
":false,"code":-1,"error":"Unknown media issue.","cancelBubble":false}

Attachments

FileDateSize
audioplayer_fulllog_8.0sdk.rtf2019-05-28T14:43:48.000+000077330
audioplayer_fulllog.rtf2019-05-28T14:43:48.000+000090416
consoleLog_Samsung J7 Prime2 v8.0.0_7.5.2GA.txt2019-05-28T14:42:51.000+000030743
SampleAudio.mp32019-05-28T14:45:44.000+0000443926

Comments

  1. Joshua Quick 2019-06-15

    I'm able to reproduce this issue on a Samsung Galaxy Tab 3. This device is natively reporting integer code 973 when this happens, which is not a documented constant. Apparently, this is a common issue as can be seen below. https://stackoverflow.com/questions/22202745/what-is-mediaplayer-oninfolistener-code-973 https://stackoverflow.com/questions/27912581/what-does-mediaplayer-info-warning-973-0-mean https://github.com/google/ExoPlayer/issues/6029 I don't think there is anything we can do about it. Some devices just don't following Google's documented rules. The good news is that the audio still plays. So, checking the error message like you're doing and ignoring it is really the only option. I do recommend that you check if the event's "code" property is set to -1 instead of looking at the string. A value of -1 is more of a warning where the audio is still playable but the system is saying there is something it doesn't like about the audio file. https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Media.Sound-event-error

JSON Source