Dasturiy injiniring” fakulteti Java fxda Eslatma dasturini yaratish



Download 4,45 Mb.
bet11/11
Sana18.07.2022
Hajmi4,45 Mb.
#822180
1   2   3   4   5   6   7   8   9   10   11
Bog'liq
Saidov Og\'abek

import java.net.URL;
import java.util.ResourceBundle;

public class Controller implements Initializable {
public Slider AudioSlider;
public Button btn_pause;
public Button btn_play;
public Slider AudioSider=new Slider();
public Slider slider = new Slider();
public Button chooseButton ;
public Button btn_Stop ;
public String audioFile = null;
private MediaPlayer player;

Boolean fileinuse = false;


Label musicLabel = new Label("Fayl hoziricha mavjud emas");

public void chooseFile() throws MalformedURLException {
FileChooser chooser = new FileChooser();
FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("o'zingizning(*.mp3) faylingizni tanlang", "*.mp3");
chooser.getExtensionFilters().add(filter);
File file = chooser.showOpenDialog(null);
if ( file !=null){
musicLabel.setText(file.getPath());
this.audioFile = file.toURI().toURL().toString();

}else{


musicLabel.setText("Noto'g'ri Fayl kiritildi");
this.audioFile = null;
}
slider.setValue(slider.getMax()/2);
fileinuse = false;
// player.stop();
player.play();

}


public void playFile(){
if(fileinuse){
player.play();
}else{
Media pick = new Media(this.audioFile);
player = new MediaPlayer(pick);
player.play();
}
// slider.setValue(player.getVolume()*100);
fileinuse = true;
AudioSlider.valueProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValueextends Number> observable, Number oldValue, Number newValue) {
player.seek(Duration.seconds(newValue.doubleValue()));
}
});

}

public void pauseFile(){


player.pause();

}

public void stopFile(){


player.stop();
}

@Override


public void initialize(URL location, ResourceBundle resources) {
slider.valueProperty().addListener(new InvalidationListener() {

@Override


public void invalidated(Observable observable) {

player.setVolume(slider.getValue() / 100);
} });
/*
try {
chooseFile();
AudioSlider.maxProperty().bind(Bindings.createDoubleBinding(
() -> player.getTotalDuration().toSeconds(),
player.totalDurationProperty()));
AudioSlider.setOnMouseClicked((MouseEvent event) -> {
player.seek(Duration.seconds(AudioSlider.getValue()));

});
player.currentTimeProperty().addListener(new ChangeListener() {


@Override
public void changed(ObservableValue observable, Duration oldValue, Duration newValue) {
AudioSider.setValue(newValue.toSeconds()*10);
}
});

} catch (MalformedURLException e) {


e.printStackTrace();
}
*/


}
private void AudioSlide(){

}
private void AudioSeek(){


}

public void volum(InputMethodEvent inputMethodEvent) {


}
}


Stillar
.root
{
-fx-background-image:url('../Images/bb.jpg');
}
.slider .track {
-fx-background-color:white;
-fx-background-insets:2;
}

.slider .thumb {


-fx-background-color:#2196f3;

}


FXML
xml version="1.0" encoding="UTF-8"?>

import javafx.scene.image.*?>
import java.net.*?>
import java.lang.*?>
import javafx.geometry.*?>
import javafx.scene.control.*?>
import javafx.scene.effect.*?>
import javafx.scene.layout.*?>
import javafx.scene.text.*?>
import javafx.geometry.Insets?>
import javafx.scene.control.Slider?>
import javafx.scene.effect.DropShadow?>
import javafx.scene.layout.AnchorPane?>
import javafx.scene.layout.ColumnConstraints?>
import javafx.scene.layout.GridPane?>
import javafx.scene.layout.HBox?>
import javafx.scene.layout.RowConstraints?>
import javafx.scene.layout.VBox?>
import javafx.scene.text.Text?>

<GridPane alignment="center" hgap="10" vgap="10" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller">
<columnConstraints>
<ColumnConstraints />
columnConstraints>
<rowConstraints>
<RowConstraints />
rowConstraints>
<children>
<AnchorPane prefHeight="525.0" prefWidth="732.0" style="-fx-background-color: transparent;">
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
padding>
<children>
<HBox layoutX="56.0" layoutY="55.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<VBox alignment="TOP_RIGHT" prefHeight="200.0" prefWidth="100.0" styleClass="left" stylesheets="@Style/ss.css" HBox.hgrow="ALWAYS">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" style="-fx-font-size: 3em; -fx-font-weight: bold; -fx-font-family: Quicksand; -fx-fill: white;" text="Music For TATU">
<effect>
<DropShadow />
effect>
Text>
<VBox alignment="BOTTOM_RIGHT" styleClass="root" stylesheets="@Style/ss.css" VBox.vgrow="SOMETIMES">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" style="-fx-font-family: Quicksand; -fx-font-weight: bold; -fx-font-size: 2.2em; -fx-fill: white;" text="Music Player By">
<effect>
<DropShadow />
effect>
Text>
<Text strokeType="OUTSIDE" strokeWidth="0.0" style="-fx-font-family: Quicksand; -fx-font-weight: bold; -fx-font-size: 2.2em; -fx-fill: white;" text="Husan C0d3r">
<effect>
<DropShadow />
effect>
Text>
children>
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
padding>
<VBox.margin>
<Insets />
VBox.margin>
VBox>
children>
VBox>
<VBox alignment="TOP_CENTER" prefHeight="200.0" prefWidth="100.0" HBox.hgrow="ALWAYS">
<children>
<Text strokeType="OUTSIDE" strokeWidth="0.0" style="-fx-font-size: 2em; -fx-font-family: Quicksand; -fx-font-weight: bold; -fx-fill: #4b4b4b;" text="Never Give Up" textAlignment="CENTER" wrappingWidth="195.13671875" />
<Text strokeType="OUTSIDE" strokeWidth="0.0" style="-fx-font-size: 2em; -fx-font-family: Quicksand; -fx-font-weight: bold; -fx-fill: #4b4b4b;" text="Justin Beiber" textAlignment="CENTER" wrappingWidth="200.13671875" />
<VBox alignment="TOP_CENTER" nodeOrientation="LEFT_TO_RIGHT" prefHeight="436.0" prefWidth="298.0" style="-fx-background-color: #e2e2e2;" stylesheets="@Style/ss.css" VBox.vgrow="ALWAYS">
<children>
<Slider fx:id="AudioSlider" />
<HBox>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
padding>
<children>
<HBox alignment="CENTER_RIGHT" HBox.hgrow="ALWAYS">
<children>
<ImageView fitHeight="23.0" fitWidth="45.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="NEVER">
<HBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="-3.0" />
HBox.margin>
<image>
<Image url="@Images/icons8-speaker-64.png" />
image>
ImageView>
children>HBox>
<Slider fx:id="slider" onInputMethodTextChanged="#volum" prefHeight="14.0" prefWidth="123.0" />
children>
HBox>
<Button fx:id="btn_pause" mnemonicParsing="false" onAction="#pauseFile" prefHeight="25.0" prefWidth="58.0" text="Pause" />
<Button fx:id="btn_play" mnemonicParsing="false" onAction="#playFile" prefHeight="25.0" prefWidth="57.0" text="Play" />
<Button fx:id="chooseButton" mnemonicParsing="false" onAction="#chooseFile" text="Choose" />
<Button fx:id="btn_Stop" mnemonicParsing="false" onAction="#stopFile" prefHeight="25.0" prefWidth="54.0" text="Stop" />
children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
padding>
<VBox.margin>
<Insets />
VBox.margin>
VBox>
children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
padding>
VBox>
children>
HBox>
children>
AnchorPane>
children>
GridPane>


Download 4,45 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   10   11




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish