本文整理汇总了Java中com.google.gwt.media.client.Audio类的典型用法代码示例。如果您正苦于以下问题:Java Audio类的具体用法?Java Audio怎么用?Java Audio使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Audio类属于com.google.gwt.media.client包,在下文中一共展示了Audio类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TankMovingAnimation
import com.google.gwt.media.client.Audio; //导入依赖的package包/类
public TankMovingAnimation(HTML mapContainer, int startX, int startY, int endX, int endY,
ImageResource resource, Audio sfx, int tankSize) {
piece = resource;
this.startX = startX;
this.startY = startY;
this.endX = endX;
this.endY = endY;
this.startWidth = tankSize;
this.startHeight = tankSize;
sound = sfx;
cancelled = false;
panel = new AbsolutePanel();
moving = new Image(resource);
moving.setPixelSize(startWidth, startHeight);
panel.add(moving, startX, startY);
panel.getElement().getStyle().setOverflow(Overflow.VISIBLE);
panel.getElement().getStyle().setPosition(Position.RELATIVE);
mapContainer.getElement().insertFirst(panel.getElement());
}
示例2: playAudio
import com.google.gwt.media.client.Audio; //导入依赖的package包/类
/**
* Play an audio.
*
* @param audio the audio to play, or null if not supported
*/
private void playAudio(Audio audio) {
if (audio == null) {
return;
}
// Pause current progress.
audio.pause();
// Reset the source.
// TODO(jlabanca): Is cache-control=private making the source unseekable?
audio.setSrc(audio.getCurrentSrc());
// Unmute because we muted in createAudioElement.
audio.play();
}
示例3: onModuleLoad
import com.google.gwt.media.client.Audio; //导入依赖的package包/类
public void onModuleLoad() {
canvas = Canvas.createIfSupported();
if (canvas == null) {
Window.alert("Canvas not supported");
return;
}
RootPanel.get("screen").add(canvas);
CanvasElement el = canvas.getCanvasElement();
el.setWidth(960);
el.setHeight(540);
Context2d ctx = canvas.getContext2d();
setupContext(ctx);
ctx.scale(3, 3);
RootPanel.get().addDomHandler(this, KeyDownEvent.getType());
font = new Image("images/font.png");
fontElement = ImageElement.as(font.getElement());
audio = Audio.createIfSupported();
game = new Game(this);
game.pushState(new WelcomeState(game));
new Timer() {
@Override
public void run() {
game.handleEvent();
game.update();
game.draw();
}
}.scheduleRepeating(50);
}
示例4: JsCallsProvider
import com.google.gwt.media.client.Audio; //导入依赖的package包/类
public JsCallsProvider() {
Audio callBeep = Audio.createIfSupported();
if (callBeep != null) {
if (!"".equals(callBeep.canPlayType("audio/ogg;"))) {
//callBeep.setSrc("assets/sound/tone.ogg");
} else if (!"".equals(callBeep.canPlayType("audio/mpeg;"))) {
//callBeep.setSrc("assets/sound/tone.mp3");
} else {
// Not Supported
return;
}
callBeep.setLoop(true);
this.callBeep = callBeep;
}
Audio callRingtone = Audio.createIfSupported();
if (callRingtone != null) {
if (!"".equals(callRingtone.canPlayType("audio/ogg;"))) {
//callRingtone.setSrc("assets/sound/ringtone.ogg");
} else if (!"".equals(callRingtone.canPlayType("audio/mpeg;"))) {
//callRingtone.setSrc("assets/sound/ringtone.mp3");
} else {
// Not Supported
return;
}
callRingtone.setLoop(true);
this.callRingtone = callRingtone;
}
}
示例5: JsCallsProvider
import com.google.gwt.media.client.Audio; //导入依赖的package包/类
public JsCallsProvider() {
Audio callBeep = Audio.createIfSupported();
if (callBeep != null) {
if (!"".equals(callBeep.canPlayType("audio/ogg;"))) {
callBeep.setSrc("assets/sound/tone.ogg");
} else if (!"".equals(callBeep.canPlayType("audio/mpeg;"))) {
callBeep.setSrc("assets/sound/tone.mp3");
} else {
// Not Supported
return;
}
callBeep.setLoop(true);
this.callBeep = callBeep;
}
Audio callRingtone = Audio.createIfSupported();
if (callRingtone != null) {
if (!"".equals(callRingtone.canPlayType("audio/ogg;"))) {
callRingtone.setSrc("assets/sound/ringtone.ogg");
} else if (!"".equals(callRingtone.canPlayType("audio/mpeg;"))) {
callRingtone.setSrc("assets/sound/ringtone.mp3");
} else {
// Not Supported
return;
}
callRingtone.setLoop(true);
this.callRingtone = callRingtone;
}
}
示例6: createAudio1
import com.google.gwt.media.client.Audio; //导入依赖的package包/类
private Widget createAudio1(String auxAud) {
Audio audio = Audio.createIfSupported();
if (audio == null) {
return null;
}
audio.load();
audio.addSource(auxAud);
audio.setControls(true);
return audio;
}
示例7: loadDiceAudio
import com.google.gwt.media.client.Audio; //导入依赖的package包/类
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();
}
}
示例8: loadDeployAudio
import com.google.gwt.media.client.Audio; //导入依赖的package包/类
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();
}
}
示例9: loadAttackAudio
import com.google.gwt.media.client.Audio; //导入依赖的package包/类
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();
}
}
示例10: loadCardAudio
import com.google.gwt.media.client.Audio; //导入依赖的package包/类
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();
}
}
示例11: loadAttackWonAudio
import com.google.gwt.media.client.Audio; //导入依赖的package包/类
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();
}
}
示例12: loadAttackLostAudio
import com.google.gwt.media.client.Audio; //导入依赖的package包/类
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();
}
}
示例13: loadGameWonAudio
import com.google.gwt.media.client.Audio; //导入依赖的package包/类
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();
}
}
示例14: loadAddUnitsAudio
import com.google.gwt.media.client.Audio; //导入依赖的package包/类
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();
}
}
示例15: SoundManager
import com.google.gwt.media.client.Audio; //导入依赖的package包/类
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);
}
}