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


Java MediaPlayer.setAutoPlay方法代碼示例

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


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

示例1: 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

示例2: start

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
public void start(Stage primaryStage) {
    primaryStage.setTitle("Embedded Media Player");
    Group root = new Group();
    Scene scene = new Scene(root, 540, 241);
    
    // create media player
    Media media = new Media("D:\\Pradeep\\Funny Mails\\Magic Sand.wmv");
    MediaPlayer mediaPlayer = new MediaPlayer(media);
    mediaPlayer.setAutoPlay(true);
    StackPane stack = new StackPane();
    
    Text t = new Text("Subtitle..");
 // t.textProperty().addChangeListener(..);
//    MediaControl mediaControl = new MediaControl(mediaPlayer);
    MediaView m =new MediaView(mediaPlayer);
    
    stack.getChildren().addAll(m, t);
    scene.setRoot(stack);
 
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
開發者ID:SaiPradeepDandem,項目名稱:javafx-demos,代碼行數:23,代碼來源:MediaPlayerDemo.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: start

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("java-buddy.blogspot.com/");
     
    Group root = new Group();
    Scene scene = new Scene(root, 540, 210);
 
    // create media player
    Media media = new Media((arg1 != null) ? arg1 : MEDIA_URL);
    MediaPlayer mediaPlayer = new MediaPlayer(media);
    mediaPlayer.setAutoPlay(true);
     
    // create mediaView and add media player to the viewer
    MediaView mediaView = new MediaView(mediaPlayer);
    ((Group)scene.getRoot()).getChildren().add(mediaView);
     
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
開發者ID:SaiPradeepDandem,項目名稱:javafx-demos,代碼行數:20,代碼來源:JavaFX_VideoPlayer.java

示例5: init

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
private void init(Stage primaryStage) {
    Group root = new Group();
    primaryStage.setScene(new Scene(root));
    mediaPlayer = new MediaPlayer(new Media(MEDIA_URL));
    mediaPlayer.setAutoPlay(true);
    MediaControl mediaControl = new MediaControl(mediaPlayer);
    mediaControl.setMinSize(480,280);
    mediaControl.setPrefSize(480,280);
    mediaControl.setMaxSize(480,280);
    root.getChildren().add(mediaControl);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:AdvancedMedia.java

示例6: StreamingMediaPlayer

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
public StreamingMediaPlayer() {
    mediaPlayer = new MediaPlayer(new Media(MEDIA_URL));
    mediaPlayer.setAutoPlay(true);
    PlayerPane playerPane = new PlayerPane(mediaPlayer);
    playerPane.setMinSize(480, 360);  
    playerPane.setPrefSize(480, 360);
    playerPane.setMaxSize(480, 360);
    getStylesheets().add("ensemble/samples/media/OverlayMediaPlayer.css");
    getChildren().add(playerPane);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:11,代碼來源:StreamingMediaPlayer.java

示例7: OverlayMediaPlayer

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
public OverlayMediaPlayer() {
    mediaPlayer = new MediaPlayer(new Media(MEDIA_URL));
    mediaPlayer.setAutoPlay(true);
    PlayerPane playerPane = new PlayerPane(mediaPlayer);
    playerPane.setMinSize(mediaWidth, mediaHeight);  
    playerPane.setPrefSize(mediaWidth, mediaHeight);
    playerPane.setMaxSize(mediaWidth, mediaHeight);
    getStylesheets().add("ensemble/samples/media/OverlayMediaPlayer.css");
    getChildren().add(playerPane);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:11,代碼來源:OverlayMediaPlayer.java

示例8: AdvancedMedia

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
public AdvancedMedia() {
    
    
    mediaPlayer = new MediaPlayer(new Media(MEDIA_URL));
    mediaPlayer.setAutoPlay(true);
    mediaControl = new AdvancedMedia.MediaControl(mediaPlayer);
    mediaControl.setMinSize(480,280);
    mediaControl.setPrefSize(480,280);
    mediaControl.setMaxSize(480,280);
    getChildren().add(mediaControl);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:12,代碼來源:AdvancedMedia.java

示例9: start

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
@Override
public void start(final Stage primaryStage) throws Exception {
    MediaView mediaView = new MediaView();
    Media media = new Media(new File("credits/end_scene.mp4").toURI().toString());
    MediaPlayer mediaPlayer = new MediaPlayer(media);
    mediaView.setMediaPlayer(mediaPlayer);
    mediaPlayer.setAutoPlay(true);
    mediaView.setPreserveRatio(false);

    List<String> params = getParameters().getRaw();
    if(params.size() == 2) {
        mediaView.setFitWidth(Integer.parseInt(params.get(0)));
        mediaView.setFitHeight(Integer.parseInt(params.get(1)));
    } else {
        mediaView.setFitWidth(1280);
        mediaView.setFitHeight(720);
    }

    mediaPlayer.setOnEndOfMedia(new Runnable() {
        @Override
        public void run() {
            primaryStage.close();
        }
    });

    primaryStage.setScene(new Scene(new FlowPane(mediaView)));
    primaryStage.show();
}
 
開發者ID:camilne,項目名稱:bad-wolf,代碼行數:29,代碼來源:Credits.java

示例10: MediaView

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
public MediaView(String url) {
    if (url == null) {
        if (Platform.isFxApplicationThread()) body = new javafx.scene.media.MediaView();
        else Platform.runLater(() -> body = new javafx.scene.media.MediaView());
    } else {
        MediaPlayer mediaPlayer = new MediaPlayer(new Media(url));
        mediaPlayer.setAutoPlay(true);
        if (Platform.isFxApplicationThread())
            body = new javafx.scene.media.MediaView(mediaPlayer);
        else Platform.runLater(()-> body = new javafx.scene.media.MediaView(mediaPlayer));
    }
}
 
開發者ID:whitewoodcity,項目名稱:xbrowser,代碼行數:13,代碼來源:MediaView.java

示例11: PlayMovie

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
private void PlayMovie(Media movie){
    MediaPlayer player = new MediaPlayer(movie);
    playstop = player;
    player.setOnEndOfMedia(onMovieEnd);
    player.setAutoPlay(true);
    player.setCycleCount(1);
    player.setMute(true);
    StackedMediaView.setMediaPlayer(player);
    StackedMediaView.setFitWidth(ViewStackPane.getWidth());

    SwapDisplayMovie();
}
 
開發者ID:chrootRISCassembler,項目名稱:CapsLock,代碼行數:13,代碼來源:MainFormController.java

示例12: initMediaPlayer

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
private void initMediaPlayer(final MediaView mediaView) {
    counter++;
    if (!manager.isEmpty()) {

        //Print the queue for test
        System.out.println(manager.getQueue());
        //Get the next item from the manager and move the current item to the end
        String filename = manager.getNext();
        final File f = new File("videos/" + filename + ".mp4");
        //Setting up the media to autoplay
        MediaPlayer mediaPlayer = new MediaPlayer(new Media(f.toURI().toString()));
        mediaPlayer.setAutoPlay(true);
        //When the media ends, make a recursive call with the updated queue
        mediaPlayer.setOnEndOfMedia(()->{
            mediaPlayer.dispose();
            initMediaPlayer(mediaView);
        });
        System.out.println("Reproduction #"+counter);
        mediaView.setMediaPlayer(mediaPlayer);
    }else{
        System.out.println("Empty queue");
        //There is no videos in the manager, try again in 10 seconds.
        try {
            Thread.sleep(15000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        initMediaPlayer(mediaView);
    }
}
 
開發者ID:kevuno,項目名稱:Offline-Streamer,代碼行數:31,代碼來源:player.java

示例13: play

import javafx.scene.media.MediaPlayer; //導入方法依賴的package包/類
public static void play(String key) {
      if (!audio.containsKey(key)) {
          throw new AssertionError("audio does not exist");
      }
      
MediaPlayer player = new MediaPlayer(audio.get(key));
player.setAutoPlay(true);
  }
 
開發者ID:GlassWispInteractive,項目名稱:fictional-spoon,代碼行數:9,代碼來源:Audio.java

示例14: 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

示例15: 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


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