public static boolean isSupported(FileFormat format) { if (tempAudioElement == null) tempAudioElement = Document.get().createAudioElement(); switch (format) { case MP3: return !tempAudioElement.canPlayType(AudioElement.TYPE_MP3).equals(MediaElement.CANNOT_PLAY); case WAV: return !tempAudioElement.canPlayType(AudioElement.TYPE_WAV).equals(MediaElement.CANNOT_PLAY); case OGG: return !tempAudioElement.canPlayType(AudioElement.TYPE_OGG).equals(MediaElement.CANNOT_PLAY); case WEBM: return !tempAudioElement.canPlayType("audio/webm").equals(MediaElement.CANNOT_PLAY); } return false; }
@Before public void setUp() throws Exception { util = new ReAttachAudioUtilMock(); audioMock = mock(Audio.class); when(audioMock.getAudioElement()).thenReturn(mock(AudioElement.class)); when(audioMock.getParent()).thenReturn(mock(FlowPanel.class)); }
private void loadDiceAudio() { diceAudio = Audio.createIfSupported(); if (diceAudio != null) { diceAudio.addSource(gameSounds.diceRollMp3().getSafeUri().asString(), AudioElement.TYPE_MP3); diceAudio.addSource(gameSounds.diceRollOgg().getSafeUri().asString(), AudioElement.TYPE_OGG); diceAudio.addSource(gameSounds.diceRollWav().getSafeUri().asString(), AudioElement.TYPE_WAV); diceAudio.load(); } }
private void loadDeployAudio() { deployAudio = Audio.createIfSupported(); if (deployAudio != null) { deployAudio.addSource(gameSounds.deployMp3().getSafeUri().asString(), AudioElement.TYPE_MP3); deployAudio.addSource(gameSounds.deployOgg().getSafeUri().asString(), AudioElement.TYPE_OGG); deployAudio.addSource(gameSounds.deployWav().getSafeUri().asString(), AudioElement.TYPE_WAV); deployAudio.load(); } }
private void loadAttackAudio() { attackAudio = Audio.createIfSupported(); if (attackAudio != null) { attackAudio.addSource(gameSounds.attackMp3().getSafeUri().asString(), AudioElement.TYPE_MP3); attackAudio.addSource(gameSounds.attackOgg().getSafeUri().asString(), AudioElement.TYPE_OGG); attackAudio.addSource(gameSounds.attackWav().getSafeUri().asString(), AudioElement.TYPE_WAV); attackAudio.load(); } }
private void loadCardAudio() { cardAudio = Audio.createIfSupported(); if (cardAudio != null) { cardAudio.addSource(gameSounds.cardMp3().getSafeUri().asString(), AudioElement.TYPE_MP3); cardAudio.addSource(gameSounds.cardOgg().getSafeUri().asString(), AudioElement.TYPE_OGG); cardAudio.addSource(gameSounds.cardWav().getSafeUri().asString(), AudioElement.TYPE_WAV); cardAudio.load(); } }
private void loadAttackWonAudio() { attackWonAudio = Audio.createIfSupported(); if (attackWonAudio != null) { attackWonAudio.addSource(gameSounds.attackWonMp3().getSafeUri().asString(), AudioElement.TYPE_MP3); attackWonAudio.addSource(gameSounds.attackWonOgg().getSafeUri().asString(), AudioElement.TYPE_OGG); attackWonAudio.addSource(gameSounds.attackWonWav().getSafeUri().asString(), AudioElement.TYPE_WAV); attackWonAudio.load(); } }
private void loadAttackLostAudio() { attackLostAudio = Audio.createIfSupported(); if (attackLostAudio != null) { attackLostAudio.addSource(gameSounds.attackLostMp3().getSafeUri().asString(), AudioElement.TYPE_MP3); attackLostAudio.addSource(gameSounds.attackLostOgg().getSafeUri().asString(), AudioElement.TYPE_OGG); attackLostAudio.addSource(gameSounds.attackLostWav().getSafeUri().asString(), AudioElement.TYPE_WAV); attackLostAudio.load(); } }
private void loadGameWonAudio() { gameWonAudio = Audio.createIfSupported(); if (gameWonAudio != null) { gameWonAudio.addSource(gameSounds.gameWonMp3().getSafeUri().asString(), AudioElement.TYPE_MP3); gameWonAudio.addSource(gameSounds.gameWonOgg().getSafeUri().asString(), AudioElement.TYPE_OGG); gameWonAudio.addSource(gameSounds.gameWonWav().getSafeUri().asString(), AudioElement.TYPE_WAV); gameWonAudio.load(); } }
private void loadAddUnitsAudio() { addUnitsAudio = Audio.createIfSupported(); if (addUnitsAudio != null) { addUnitsAudio.addSource(gameSounds.addUnitsMp3().getSafeUri().asString(), AudioElement.TYPE_MP3); addUnitsAudio.addSource(gameSounds.addUnitsOgg().getSafeUri().asString(), AudioElement.TYPE_OGG); addUnitsAudio.addSource(gameSounds.addUnitsWav().getSafeUri().asString(), AudioElement.TYPE_WAV); addUnitsAudio.load(); } }
private void createPlayer() throws AudioException { audioPlayer = Audio.createIfSupported(); if (audioPlayer == null) { throw new AudioException("audio not supportered"); } final AudioElement audioElement = audioPlayer.getAudioElement(); onEndedSetup(audioElement); }
/** * Prefetch the error sound. */ public void prefetchError() { if (isSupported && error == null) { error = Audio.createIfSupported(); error.addSource("audio/error.ogg", AudioElement.TYPE_OGG); error.addSource("audio/error.mp3", AudioElement.TYPE_MP3); error.addSource("audio/error.wav", AudioElement.TYPE_WAV); prefetchAudio(error); } }
private NodeList<Node> getSourceNodes(Audio audio) { AudioElement audioElement = audio.getAudioElement(); return audioElement.getChildNodes(); }
public native void bufferData(WebALBuffer buffer, AudioElement audio, boolean streaming) /*-{ this.bufferData(buffer, audio, streaming); }-*/;
public native void bufferData(WebALBuffer buffer, JsArray<AudioElement> audioArray, boolean streaming) /*-{ this.bufferData(buffer, audioArray, streaming); }-*/;