示例#1
0
            public TrackPlayer(Track track)
            {
                Anchor = Anchor.Centre;
                Origin = Anchor.Centre;

                DrawableTrack drawableTrack;

                Size = new Vector2(50);

                Masking      = true;
                CornerRadius = 10;

                InternalChildren = new Drawable[]
                {
                    new Box
                    {
                        Colour           = Color4.Yellow,
                        RelativeSizeAxes = Axes.Both,
                    },
                    new SpriteIcon
                    {
                        Anchor = Anchor.Centre,
                        Origin = Anchor.Centre,
                        Icon   = FontAwesome.Solid.VolumeUp,
                        Colour = Color4.Black,
                        Size   = new Vector2(40)
                    },
                    drawableTrack = new DrawableTrack(track)
                };

                drawableTrack.Looping = true;
                drawableTrack.Start();
            }
示例#2
0
        // 게임 상태를 따라 트랙을 관리하는것은 잘못 되었습니다. 트랙관리자는 트랙 로드, 트랙의 볼륨설정, 플레이와 정지만을 제공하기 떄문입니다.
        protected override void Update()
        {
            base.Update();

            if (track.HasCompleted && State == GameState.Playing)
            {
                loopTrack();
            }

            if (CurrentVolume != lastVolume)
            {
                Console.WriteLine($"Track Volume: {CurrentVolume}%");
                lastVolume = CurrentVolume;
            }

            if (track.TrackLoaded && State == GameState.Ready)
            {
                track.Stop();
            }

            if (track.TrackLoaded && State == GameState.Playing)
            {
                track.Start();
                track.VolumeTo(CurrentVolume / 100);
            }

            if (track.TrackLoaded && State == GameState.GameOver)
            {
                track.Stop();
                track.Reset();
            }
        }
示例#3
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            track.Looping = true;
            AddStep("start track", () => track.Start());
            AddStep("stop track", () => track.Stop());
        }
示例#4
0
        /// <summary>
        /// Start playing the current track (if not already playing).
        /// </summary>
        /// <returns>Whether the operation was successful.</returns>
        public bool Play(bool restart = false)
        {
            IsUserPaused = false;

            if (restart)
            {
                CurrentTrack.Restart();
            }
            else if (!IsPlaying)
            {
                CurrentTrack.Start();
            }

            return(true);
        }
示例#5
0
        /// <summary>
        /// Start playing the current track (if not already playing).
        /// </summary>
        /// <param name="restart">Whether to restart the track from the beginning.</param>
        /// <param name="requestedByUser">
        /// Whether the request to play was issued by the user rather than internally.
        /// Specifying <c>true</c> will ensure that other methods like <see cref="EnsurePlayingSomething"/>
        /// will resume music playback going forward.
        /// </param>
        /// <returns>Whether the operation was successful.</returns>
        public bool Play(bool restart = false, bool requestedByUser = false)
        {
            if (requestedByUser)
            {
                UserPauseRequested = false;
            }

            if (restart)
            {
                CurrentTrack.Restart();
            }
            else if (!IsPlaying)
            {
                CurrentTrack.Start();
            }

            return(true);
        }
示例#6
0
 public void PlayTrack() => Schedule(() => track.Start());