[TIMOB-9705] TiAPI: Titanium.Media.Sound.time units should be consistent between platforms
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2017-06-09T17:02:10.000+0000 |
Affected Version/s | Release 2.1.0 |
Fix Version/s | n/a |
Components | TiAPI |
Labels | anvil, api, parity |
Reporter | Max Stepanov |
Assignee | Eric Merriman |
Created | 2012-06-21T14:17:01.000+0000 |
Updated | 2019-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
Closing ticket due to time passed, any problems please open a new ticket.