Search in sources :

Example 1 with TrackMarker

use of com.sedmelluq.discord.lavaplayer.track.TrackMarker in project FredBoat by Frederikam.

the class AbstractPlayer method playTrack.

/**
 * Plays the provided track.
 * <p>
 * Silently playing a track will not trigger the onPlayHook (which announces the track usually)
 */
private void playTrack(AudioTrackContext trackContext, boolean... silent) {
    log.trace("playTrack({})", trackContext.getEffectiveTitle());
    context = trackContext;
    player.playTrack(trackContext.getTrack());
    trackContext.getTrack().setPosition(trackContext.getStartPosition());
    if (trackContext instanceof SplitAudioTrackContext) {
        // Ensure we don't step over our bounds
        log.info("Start: " + trackContext.getStartPosition() + " End: " + (trackContext.getStartPosition() + trackContext.getEffectiveDuration()));
        trackContext.getTrack().setMarker(new TrackMarker(trackContext.getStartPosition() + trackContext.getEffectiveDuration(), new TrackEndMarkerHandler(this, trackContext)));
    }
    if (silent.length < 1 || !silent[0]) {
        if (onPlayHook != null)
            onPlayHook.accept(trackContext);
    }
}
Also used : TrackEndMarkerHandler(fredboat.audio.queue.TrackEndMarkerHandler) TrackMarker(com.sedmelluq.discord.lavaplayer.track.TrackMarker) SplitAudioTrackContext(fredboat.audio.queue.SplitAudioTrackContext)

Aggregations

TrackMarker (com.sedmelluq.discord.lavaplayer.track.TrackMarker)1 SplitAudioTrackContext (fredboat.audio.queue.SplitAudioTrackContext)1 TrackEndMarkerHandler (fredboat.audio.queue.TrackEndMarkerHandler)1