31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
|
window["require_setup"](module);
|
||
|
// <reference types="../imports/import_shared.d.ts" />
|
||
|
/// <reference types="../../modules/renderer/imports/imports_shared.d.ts" />
|
||
|
|
||
|
import {audio as naudio} from "teaclient_connection";
|
||
|
import * as paths from "path";
|
||
|
|
||
|
namespace audio.sounds {
|
||
|
export async function play_sound(file: sound.SoundFile) : Promise<void> {
|
||
|
await new Promise((resolve, reject) => {
|
||
|
let pathname = paths.dirname(location.pathname);
|
||
|
if(pathname[0] === '/' && pathname[2] === ':') //e.g.: /C:/test...
|
||
|
pathname = pathname.substr(1);
|
||
|
const path = paths.join(pathname, file.path);
|
||
|
|
||
|
console.log(path);
|
||
|
naudio.sounds.playback_sound({
|
||
|
callback: (result, message) => {
|
||
|
if(result == naudio.sounds.PlaybackResult.SUCCEEDED)
|
||
|
resolve();
|
||
|
else
|
||
|
reject(naudio.sounds.PlaybackResult[result].toLowerCase() + ": " + message);
|
||
|
},
|
||
|
file: path,
|
||
|
volume: file.volume
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Object.assign(window["audio"] || (window["audio"] = {} as any), audio);
|