當前位置: 首頁>>代碼示例>>Java>>正文


Java MediaPlayer.setVolume方法代碼示例

本文整理匯總了Java中javafx.scene.media.MediaPlayer.setVolume方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaPlayer.setVolume方法的具體用法?Java MediaPlayer.setVolume怎麽用?Java MediaPlayer.setVolume使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.media.MediaPlayer的用法示例。


在下文中一共展示了MediaPlayer.setVolume方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: playCrossfade

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
private void playCrossfade(final List<? extends Playable> items, final int index) {
	MediaPlayer oldPlayer = currentPlayer;
	final double currentVolume = oldPlayer.getVolume();
	oldPlayer.volumeProperty().unbind();
	playQueue = new ArrayList<>(items);
	currentIndex = index;

	MediaPlayer newPlayer = new MediaPlayer(new Media(playQueue.get(currentIndex).getUri().toString()));
	newPlayer.setVolume(0);
	newPlayer.play();
	Timeline crossfade = new Timeline(new KeyFrame(Duration.seconds(CROSSFADE_DURATION),
			new KeyValue(oldPlayer.volumeProperty(), 0),
			new KeyValue(newPlayer.volumeProperty(), currentVolume)));
	crossfade.setOnFinished(event -> {
		oldPlayer.stop();
		setCurrentPlayer(newPlayer);
	});
	crossfade.play();
}
 
開發者ID:jakemanning,項目名稱:boomer-tuner,代碼行數:20,代碼來源:Player.java

示例2: init

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
/**
 * Level initialisieren
 *
 * @param collector - Objektsammler
 */
@Override
protected void init(ObjectCollector collector) {

    rdm = new Random();

    // Init Hintergrundmusik
    menuTheme = new Media(getClass().getResource("/de/janroslan/verse/resources/sounds/menu.aiff").toExternalForm());
    mplayer = new MediaPlayer(menuTheme);
    mplayer.setVolume(0.7);
    mplayer.setAutoPlay(true);

    // Init Maus Hover Sound
    buttonHoverSound = new AudioClip(getClass().getResource("/de/janroslan/verse/resources/sounds/click.wav").toString());

    initPictures(collector);
    initObjs(collector);
    initTexts(collector);
    initButtons(collector);
    

}
 
開發者ID:Jackjan4,項目名稱:Verse,代碼行數:27,代碼來源:MainMenu.java

示例3: setup

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
public void setup(Scene scene)
{
    this.scene = scene;
    media = new Media(getClass().getResource("video_1.mp4").toExternalForm());
    player = new MediaPlayer(media);
    mediaView = new MediaView(player);
    player.setAutoPlay(true);
    player.setVolume(0);
    getChildren().add(mediaView);
    mediaView.fitWidthProperty().bind(scene.widthProperty());
    mediaView.fitHeightProperty().bind(scene.heightProperty());
    
}
 
開發者ID:mars-sim,項目名稱:mars-sim,代碼行數:14,代碼來源:Dash.java

示例4: playBGM

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
private void playBGM(String soundFileName) {
	Media sound = new Media(new File(soundFileName).toURI().toString());
	try {
		bgm = new MediaPlayer(sound);
		bgm.setVolume(bgmVolume);
		bgm.play();
	}catch (MediaException e) {
		new CustomAlert(AlertType.ERROR, "Sound Manager Error").show();
	}
}
 
開發者ID:LtubSalad,項目名稱:voogasalad-ltub,代碼行數:11,代碼來源:SoundManager.java

示例5: playSoundEffect

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
private void playSoundEffect(String soundFileName) {
	Media sound = new Media(new File(soundFileName).toURI().toString());
	try {
		MediaPlayer soundEffect = new MediaPlayer(sound);
		soundEffect.setVolume(soundEffectVolumn);
		soundEffect.play();
		soundPlayers.add(soundEffect);
	}catch (MediaException e) {
		new CustomAlert(AlertType.ERROR, "Sound Manager Error").show();
	}		
}
 
開發者ID:LtubSalad,項目名稱:voogasalad-ltub,代碼行數:12,代碼來源:SoundManager.java

示例6: init

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
/**
 * Initialisieren des Levels
 *
 * @param collector - Objektsammler für den LevelLoader
 */
@Override
protected void init(ObjectCollector collector) {

    // Initialisieren der Hintergrundmusik
    levelTheme = new Media(getClass().getResource("/de/janroslan/verse/resources/sounds/levelTheme.aiff").toExternalForm());
    mediaPlayer = new MediaPlayer(levelTheme);
    mediaPlayer.setVolume(0.4);
    mediaPlayer.setAutoPlay(true);

    // Initialisiere Hintergrund
    DrawImage bg = new DrawImage("bg", 0, 0, new Image("/de/janroslan/verse/resources/sky.png"), 1.7, 2, 0);
    collector.add(bg);

    // Init Wände
    initWalls(collector);

    // Init Türen
    ArrayList<BasicNode[]> doors = initDoors(collector);

    // Init Schalter
    initObjs(collector, doors);

    // Spieler initialisieren
    player = new Player(100, 210);
    collector.registerCollider(player, CollisionType.AABox2D, "wall");
    collector.add(player);

    // Zeilflagge initialisieren
    finish = new LevelFinish(Game.W_WIDTH - 70, Game.W_HEIGHT - 74);
    collector.registerCollider(finish, CollisionType.AABox2D, "player");
    collector.add(finish);
    
}
 
開發者ID:Jackjan4,項目名稱:Verse,代碼行數:39,代碼來源:LevelOne.java

示例7: backMusicStart

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
public static void backMusicStart(String path)
{
    mp = new MediaPlayer(new Media(ManagerAudio.class.getResource(path).toString())); //Задаём песенку
    mp.setCycleCount(MediaPlayer.INDEFINITE); //Цикличность
    mp.setVolume(0.5D); //Громкость
    mp.setAutoPlay(true); //Автозапуск
    mp.play(); //Играем
}
 
開發者ID:nuclearthinking,項目名稱:rpg,代碼行數:9,代碼來源:ManagerAudio.java

示例8: setVolumeForAllSounds

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
/**
 * Sets the volume for all sounds controlled by {@link SuperSoundManager}.
 *
 * @param volume
 *            The new volume to set immediately for all controlled sounds.
 */
public static void setVolumeForAllSounds(double volume) {
	MediaPlayer[] snapshotOfAllSounds = allControlledSounds.toArray(new MediaPlayer[0]);
	for (MediaPlayer sound : snapshotOfAllSounds) {
		if (sound.getStatus() != Status.DISPOSED)
			sound.setVolume(volume);
	}
}
 
開發者ID:ubershy,項目名稱:StreamSis,代碼行數:14,代碼來源:SuperSoundManager.java

示例9: loadSong

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
public void loadSong() {
    media = new Media(file.toURI().toString());
    mediaPlayer = new MediaPlayer(getMedia());
    mediaPlayer.setVolume(DEFAULT_VOLUME);
}
 
開發者ID:pashkobohdan,項目名稱:Music-Player,代碼行數:6,代碼來源:Song.java

示例10: Sound

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
/**
 *creates a Sound object using the file specified by u
 * @param u
 */
public Sound(URL u){
    mp = new MediaPlayer(new Media(u.toString()));
    mp.setVolume(1 * masterVolume);
    sl.add(this);
}
 
開發者ID:FloppidyDingo,項目名稱:Dingo-Engine,代碼行數:10,代碼來源:Sound.java

示例11: SoundEffectBuilder

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
private SoundEffectBuilder(String soundEffectFilename) {
    soundEffect = new MediaPlayer(new Media(soundEffectFilename));
    soundEffect.setCycleCount(1);
    soundEffect.setVolume(masterVolume);
    callback = () -> {};
}
 
開發者ID:AaronFriesen,項目名稱:Trydent,代碼行數:7,代碼來源:Audio.java

示例12: playGunSound

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
private void playGunSound(){

        MediaPlayer playSoundGun = new MediaPlayer(gunSound);

        playSoundGun.setVolume(0.3f);

        playSoundGun.play();
    }
 
開發者ID:TheRedSpy15,項目名稱:The-Trail,代碼行數:9,代碼來源:ShootOutController.java

示例13: playGrenadeSound

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
private void playGrenadeSound(){

        MediaPlayer playSoundGrenade = new MediaPlayer(grenadeSound);

        playSoundGrenade.setVolume(0.3f);

        playSoundGrenade.play();
    }
 
開發者ID:TheRedSpy15,項目名稱:The-Trail,代碼行數:9,代碼來源:ShootOutController.java

示例14: playVictorySound

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
private void playVictorySound(){

        MediaPlayer playSoundVictory = new MediaPlayer(victorySound);

        playSoundVictory.setVolume(0.3f);

        playSoundVictory.play();
    }
 
開發者ID:TheRedSpy15,項目名稱:The-Trail,代碼行數:9,代碼來源:ShootOutController.java


注:本文中的javafx.scene.media.MediaPlayer.setVolume方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。