<commit_before>class _Audio {
  static const List<String> _audioNames =
      const ['Pop0', 'Pop1', 'Pop2', 'Pop3', 'Pop4', 'Pop5', 'Pop6', 'Pop7', 'Pop8',
             'Bomb0', 'Bomb1', 'Bomb2', 'Bomb3', 'Bomb4',
             GameAudio.THROW_DART, GameAudio.FLAG, GameAudio.UNFLAG, GameAudio.CLICK, GameAudio.WIN];

  final AudioLoader _audioLoader;
  final Map<String, AudioBuffer> _buffers = new Map();
  static final _audioFormat = _getAudioFormat();

  factory _Audio() {
    if(_audioFormat != null) {
      final audioContext = new AudioContext();
      final loader = new AudioLoader(audioContext, _getAudioPaths(_audioNames));
      return new _Audio._internal(loader);
    } else {
      return new _Audio._disabled();
    }
  }

  _Audio._disabled() : this._audioLoader = null;

  _Audio._internal(this._audioLoader) {
    // TODO: less than ideal. Binding to event handlers defined in game.dart
    // re-expose events? Take in handlers in ctor? Hmm...
    _audioLoader.progress.add(_onProgress);
    _audioLoader.loaded.add(_onLoaded);
    _audioLoader.loaded.add(_onLoad);
    GameAudio.audioEvent.add(_playAudio);
    _audioLoader.load();
  }

  int get completedBytes {
    if(_audioLoader == null) {
      return 0;
    } else {
      return _audioLoader.completedBytes;
    }
  }
<commit_msg>Catch errors creating AudioContext<commit_after>class _Audio {
  static const List<String> _audioNames =
      const ['Pop0', 'Pop1', 'Pop2', 'Pop3', 'Pop4', 'Pop5', 'Pop6', 'Pop7', 'Pop8',
             'Bomb0', 'Bomb1', 'Bomb2', 'Bomb3', 'Bomb4',
             GameAudio.THROW_DART, GameAudio.FLAG, GameAudio.UNFLAG, GameAudio.CLICK, GameAudio.WIN];

  final AudioLoader _audioLoader;
  final Map<String, AudioBuffer> _buffers = new Map();
  static final _audioFormat = _getAudioFormat();

  factory _Audio() {
    if(_audioFormat != null) {
      try {
        final audioContext = new AudioContext();
        final loader = new AudioLoader(audioContext, _getAudioPaths(_audioNames));
        return new _Audio._internal(loader);
      } catch (e) {
        print("Error creating AudioContext: ${e}");
      }
    }
    return new _Audio._disabled();
  }

  _Audio._disabled() : this._audioLoader = null;

  _Audio._internal(this._audioLoader) {
    // TODO: less than ideal. Binding to event handlers defined in game.dart
    // re-expose events? Take in handlers in ctor? Hmm...
    _audioLoader.progress.add(_onProgress);
    _audioLoader.loaded.add(_onLoaded);
    _audioLoader.loaded.add(_onLoad);
    GameAudio.audioEvent.add(_playAudio);
    _audioLoader.load();
  }

  int get completedBytes {
    if(_audioLoader == null) {
      return 0;
    } else {
      return _audioLoader.completedBytes;
    }
  }

{'fraction_non_alphanumeric': 0.1272927366104182, 'fraction_numerical': 0.011005135730007337, 'mean_word_length': 3.2609375, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3898548', 'n_tokens_mistral': 875, 'n_tokens_neox': 852, 'n_words': 203}