Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9705] TiAPI: Titanium.Media.Sound.time units should be consistent between platforms

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2017-06-09T17:02:10.000+0000
Affected Version/sRelease 2.1.0
Fix Version/sn/a
ComponentsTiAPI
Labelsanvil, api, parity
ReporterMax Stepanov
AssigneeEric Merriman
Created2012-06-21T14:17:01.000+0000
Updated2019-03-15T01:09:14.000+0000

Description

From Titanium.Media.Sound.time documentation:
Current playback position of the audio.
On iOS, playback time is reported in seconds.
On Android, time is reported in milliseconds.
Test case:
var testRun = {};
function valueOf(test, actual) {
	return {
		shouldBe : function(expected) {
			if (expected != actual) {
				Ti.API.info("expected: <"+expected+">, actual: <"+actual+">");
			}
		},
		shouldBeGreaterThan : function(expected) {
			if (actual <= expected) {
				Ti.API.info("expected greater than: <"+expected+">, actual: <"+actual+">");				
			}
		},
		shouldBeLessThan : function(expected) {
			if (actual >= expected) {
				Ti.API.info("expected less than: <"+expected+">, actual: <"+actual+">");				
			}
		}
	};
}

Ti.API.info("-- start --");
var sound = Ti.Media.createSound({ url : 'cricket.wav' });
Titanium.Media.audioSessionMode = Ti.Media.AUDIO_SESSION_MODE_PLAYBACK; 
var initial_pos = 3;
sound.time = initial_pos;
sound.setTime(initial_pos);
valueOf(testRun, sound.getTime()).shouldBe(initial_pos);
valueOf(testRun, sound.time).shouldBe(initial_pos);
sound.play();
setTimeout(function(e) {
	var time = sound.getTime();
	Ti.API.info("PROGRESS: " + time);
	valueOf(testRun, time).shouldBeGreaterThan(initial_pos);
	// assume we get an event in < 2 seconds.
	valueOf(testRun, time).shouldBeLessThan(initial_pos + 3000); 
	sound.stop();
	sound = null;
	Ti.API.info("-- end --");
}, 1000);
Anvil: media/media - audioTimeValidation

Comments

  1. Lee Morris 2017-06-09

    Closing ticket due to time passed, any problems please open a new ticket.

JSON Source