<commit_before>import haxe.Timer;
import js.html.SourceElement;
import js.html.AudioElement;

@:keep class HTML5Sound extends BaseSound implements IWaudSound {

	var _snd:AudioElement;
	var _src:SourceElement;
	var _tmr:Timer;
	var _pauseTime:Float;

	public function new(url:String, ?options:WaudSoundOptions = null, ?src:SourceElement) {
		super(url, options);
		_snd = Waud.dom.createAudioElement();
		if (src == null) _addSource(url);
		else _snd.appendChild(src);
		if (_options.preload) load();
		if (_b64.match(url)) url = "";
	}

	public function load(?callback:IWaudSound -> Void):IWaudSound {
		if (!_isLoaded) {
			_snd.autoplay = _options.autoplay;
			_snd.loop = _options.loop;
			_snd.volume = _options.volume;

			if (callback != null) _options.onload = callback;

			if (_options.preload) _snd.preload = "auto";
			else _snd.preload = "metadata"; //none

			if (_options.onload != null) {
				_isLoaded = true;
				_snd.onloadeddata = function() {
					_options.onload(this);
				}
			}

			_snd.onplaying = function() {
				_isPlaying = true;
			}

			_snd.onended = function() {
				_isPlaying = false;
				if (_options.onend != null) _options.onend(this);
			}

			if (_options.onerror != null) {
				_snd.onerror = function() {
					_options.onerror(this);
				}
			}

			_snd.load();
		}

		return this;
	}

	override function get_duration():Float {
		if (!_isLoaded) return 0;
		return duration = _snd.duration;
	}

	function _addSource(url:String):SourceElement {
		_src = Waud.dom.createSourceElement();
		_src.src = url;

		if (Waud.audioManager.types.get(_getExt(url)) != null) _src.type = Waud.audioManager.types.get(_getExt(url));
		_snd.appendChild(_src);

		return _src;
	}

	function _getExt(filename:String):String {
		return filename.split(".").pop();
	}

	public function setVolume(val:Float, ?spriteName:String) {
		if (val >= 0 && val <= 1) _options.volume = val;
		if (!_isLoaded) return;
		_snd.volume = _options.volume;
	}

	public function getVolume(?spriteName:String):Float {
		return _options.volume;
	}

	public function mute(val:Bool, ?spriteName:String) {
		if (!_isLoaded) return;<commit_msg>removed inner assignment<commit_after>import haxe.Timer;
import js.html.SourceElement;
import js.html.AudioElement;

@:keep class HTML5Sound extends BaseSound implements IWaudSound {

	var _snd:AudioElement;
	var _src:SourceElement;
	var _tmr:Timer;
	var _pauseTime:Float;

	public function new(url:String, ?options:WaudSoundOptions = null, ?src:SourceElement) {
		super(url, options);
		_snd = Waud.dom.createAudioElement();
		if (src == null) _addSource(url);
		else _snd.appendChild(src);
		if (_options.preload) load();
		if (_b64.match(url)) url = "";
	}

	public function load(?callback:IWaudSound -> Void):IWaudSound {
		if (!_isLoaded) {
			_snd.autoplay = _options.autoplay;
			_snd.loop = _options.loop;
			_snd.volume = _options.volume;

			if (callback != null) _options.onload = callback;

			if (_options.preload) _snd.preload = "auto";
			else _snd.preload = "metadata"; //none

			if (_options.onload != null) {
				_isLoaded = true;
				_snd.onloadeddata = function() {
					_options.onload(this);
				}
			}

			_snd.onplaying = function() {
				_isPlaying = true;
			}

			_snd.onended = function() {
				_isPlaying = false;
				if (_options.onend != null) _options.onend(this);
			}

			if (_options.onerror != null) {
				_snd.onerror = function() {
					_options.onerror(this);
				}
			}

			_snd.load();
		}

		return this;
	}

	override function get_duration():Float {
		if (!_isLoaded) return 0;
		duration = _snd.duration;
		return duration;
	}

	function _addSource(url:String):SourceElement {
		_src = Waud.dom.createSourceElement();
		_src.src = url;

		if (Waud.audioManager.types.get(_getExt(url)) != null) _src.type = Waud.audioManager.types.get(_getExt(url));
		_snd.appendChild(_src);

		return _src;
	}

	function _getExt(filename:String):String {
		return filename.split(".").pop();
	}

	public function setVolume(val:Float, ?spriteName:String) {
		if (val >= 0 && val <= 1) _options.volume = val;
		if (!_isLoaded) return;
		_snd.volume = _options.volume;
	}

	public function getVolume(?spriteName:String):Float {
		return _options.volume;
	}

	public function mute(val:Bool, ?spriteName:String) {
		if (!_isLoaded) return;
{'fraction_non_alphanumeric': 0.13973494536154382, 'fraction_numerical': 0.0027900488258544524, 'mean_word_length': 3.877551020408163, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5350155', 'n_tokens_mistral': 1732, 'n_tokens_neox': 1498, 'n_words': 308}