/// // http://docs.phonegap.com/en/edge/cordova_media_media.md.html interface Media { new (url: string): Media; play(): void; getDuration(): number; seekTo(millis: number): void; } module TDev.RT.Cordova { // provides a bridge between HTMLAudioElement and Cordova Media class MediaShim { media: Media; public duration = -1; public volume = 1; public playbackRate = 1; constructor(url: string) { this.media = new (window).Media(url); this.duration = this.media.getDuration(); } public play() { this.runMedia(m => m.play()); } private runMedia(f: (m: any) => {}) { if (this.media) { try { f(this.media); } catch (e) { Util.reportError("cordova sound", e, false); } } } } export function SoundInit() { Util.log('wab: boosting PLAY_SOUND'); Sound.prototype.initAsync = function () { var sound: Sound = this; return sound.createUrlAsync() .then(url => { (sound)._audio = new MediaShim(url); }); } Sound.prototype.resetAsync = function () { var sound: Sound = this; var media : Media = (sound)._audio; if (media) media.seekTo(0); return Promise.as(); } } }