Search in sources :

Example 1 with PlaylistsScreen

use of mathax.client.gui.screens.music.PlaylistsScreen in project Client by MatHax.

the class WPlaybackControls method add.

@Override
public void add(WTable parent, MusicTab.MusicScreen screen, GuiTheme theme) {
    WHorizontalList list = parent.add(theme.horizontalList()).widget();
    WButton pauseButton = list.add(theme.button(Music.player.isPaused() ? "Resume" : "Pause")).widget();
    pauseButton.action = () -> {
        if (Music.player.isPaused()) {
            Music.trackScheduler.setPaused(false);
            pauseButton.set("Pause");
        } else {
            Music.trackScheduler.setPaused(true);
            pauseButton.set("Resume");
        }
    };
    if (Music.trackScheduler.hasNext()) {
        list.add(theme.button("Shuffle")).widget().action = () -> {
            Collections.shuffle(Music.trackScheduler.tracks);
            screen.construct();
        };
        list.add(theme.button("Clear")).widget().action = () -> {
            Music.trackScheduler.tracks.clear();
            screen.construct();
        };
    }
    list.add(theme.button("Playlists")).widget().action = () -> {
        mc.setScreen(new PlaylistsScreen(theme, screen));
    };
    String duration;
    AudioTrack current = Music.player.getPlayingTrack();
    if (current == null)
        duration = "Not playing";
    else
        duration = Music.getTime();
    list.add(theme.label("Duration: " + duration)).right();
    parent.row();
    super.add(parent, screen, theme);
}
Also used : PlaylistsScreen(mathax.client.gui.screens.music.PlaylistsScreen) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) WButton(mathax.client.gui.widgets.pressable.WButton) WHorizontalList(mathax.client.gui.widgets.containers.WHorizontalList)

Aggregations

AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)1 PlaylistsScreen (mathax.client.gui.screens.music.PlaylistsScreen)1 WHorizontalList (mathax.client.gui.widgets.containers.WHorizontalList)1 WButton (mathax.client.gui.widgets.pressable.WButton)1