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; }
public HTML5VideoImpl() { video = eu.ydp.empiria.player.client.media.Video.createIfSupported(); video.setPreload(MediaElement.PRELOAD_METADATA); video.setLoop(false); add(video); }
@Test public void canPlayTest_MediaObjectWasChange() { eventsBus.fireEventFromSource(new MediaEvent(MediaEventTypes.ON_DURATION_CHANGE, instance), instance); assertTrue(instance.canPlay()); when(video.getMedia().getReadyState()).thenReturn(MediaElement.HAVE_NOTHING); instance.setMediaObject(video.getMedia()); assertFalse(instance.canPlay()); }
public SoundManager() { for (String soundURL : soundURLs) { Audio newAudio = Audio.createIfSupported(); if (newAudio == null) { throw new AlertRuntimeException("Браузер не поддерживает звуки (HTML5 элемент <audio>)"); } newAudio.setPreload(MediaElement.PRELOAD_AUTO); newAudio.setSrc("audio/" + soundURL); newAudio.setAutoplay(false); audios.add(newAudio); } }
private void setMediaBaseAndPreload(MediaBase mediaBase) { this.mediaBase = mediaBase; this.ready = false; mediaBase.setPreload(MediaElement.PRELOAD_METADATA); }
@Override public boolean canPlay() { return ready || mediaBase.getReadyState() != MediaElement.HAVE_NOTHING; }
@Override protected String getMediaPreloadType() { return MediaElement.PRELOAD_AUTO; }
protected String getMediaPreloadType() { return MediaElement.PRELOAD_METADATA; }
@Test public void canPlayTest_MediaReadyStateHaveNothing() { when(video.getMedia().getReadyState()).thenReturn(MediaElement.HAVE_NOTHING); assertFalse(instance.canPlay()); }
@Test public void canPlayTest_MediaReadyStateHaveData() { when(video.getMedia().getReadyState()).thenReturn(MediaElement.HAVE_ENOUGH_DATA); assertTrue(instance.canPlay()); }
@Override public String getAssumedMediaPreloadType() { return MediaElement.PRELOAD_AUTO; }
protected String getAssumedMediaPreloadType() { return MediaElement.PRELOAD_METADATA; }
public native MediaElementAudioSourceNode createMediaElementSource(MediaElement mediaElement) /*-{ return this.createMediaElementSource(mediaElement); }-*/;