Пример #1
0
        /// <summary>
        /// Move the audio position to the provided time.
        /// </summary>
        /// <param name="time">The time to jump to in the audio.</param>
        public static void Seek(double time)
        {
            bool withinRange = time >= -1 && time <= song.Length;

            // If audio is active and the time was within range,
            // seek to that time
            if (active && withinRange)
            {
                song.Seek(time);
            }
            // Otherwise seek to the beginning or end.
            else if (active)
            {
                if (time < -1)
                {
                    song.Seek(-1);
                }
                else
                {
                    song.Seek(song.Length);
                }
            }
        }
Пример #2
0
        private void ensurePlayingSelected(bool preview = false)
        {
            AudioTrack track = Beatmap?.Track;

            if (track != null)
            {
                trackManager.SetExclusive(track);
                if (preview)
                {
                    track.Seek(Beatmap.Beatmap.Metadata.PreviewTime);
                }
                track.Start();
            }
        }
Пример #3
0
        public ControllerWindow(AudioTrack track, BeatmapPlayback playback)
        {
            beatmapPlayback = playback;
            audioTrack      = track;

            Size     = new Vector2(300, 400);
            Children = new Drawable[]
            {
                new Box
                {
                    Colour           = new Color4(30, 30, 30, 240),
                    RelativeSizeAxes = Axes.Both,
                    Depth            = 0
                },
                new FlowContainer
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Direction        = FlowDirection.VerticalOnly,
                    Children         = new Drawable[]
                    {
                        titleBar = new Box //title decoration
                        {
                            Colour           = Color4.DarkBlue,
                            RelativeSizeAxes = Axes.X,
                            Size             = new Vector2(1, 20),
                        },
                        new Container //toolbar
                        {
                            RelativeSizeAxes = Axes.X,
                            Size             = new Vector2(1, 40),
                            Children         = new Drawable[]
                            {
                                new Box {
                                    Colour           = new Color4(20, 20, 20, 255),
                                    RelativeSizeAxes = Axes.Both,
                                },
                                new FlowContainer
                                {
                                    RelativeSizeAxes = Axes.Both,
                                    Spacing          = new Vector2(1),
                                    Children         = new Drawable[]
                                    {
                                        new Button
                                        {
                                            Colour           = Color4.DarkGray,
                                            Size             = new Vector2(100, 1),
                                            RelativeSizeAxes = Axes.Y,
                                            Text             = @"Pause",
                                            Action           = TogglePause
                                        },
                                        new Button
                                        {
                                            Colour           = Color4.DarkGray,
                                            Size             = new Vector2(100, 1),
                                            RelativeSizeAxes = Axes.Y,
                                            Text             = @"Restart",
                                            Action           = Restart
                                        },
                                    },
                                },
                            },
                        },
                    },
                },
                new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Padding          = new MarginPadding {
                        Top = 65
                    },
                    Children = new[]
                    {
                        container = new FlowContainer
                        {
                            RelativeSizeAxes = Axes.Both,
                            Direction        = FlowDirection.VerticalOnly,
                        }
                    }
                },
            };

            // Add slider options
            container.Add(CreateSliderBinding("Position", 0, track.Length,
                                              x => audioTrack.Seek(x),
                                              () => audioTrack.CurrentTime));
            container.Add(CreateSliderBinding("View Duration", 0.1, 4.0,
                                              x => beatmapPlayback.ViewDuration = x,
                                              () => beatmapPlayback.ViewDuration));
        }
Пример #4
0
 private void Restart()
 {
     audioTrack.Seek(0); // Reset
     audioTrack.Start();
 }