Ejemplo n.º 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();
            }
Ejemplo n.º 2
0
        private void changeTrack()
        {
            var lastTrack = CurrentTrack;

            var queuedTrack = new DrawableTrack(current.LoadTrack());

            queuedTrack.Completed += () => onTrackCompleted(current);

            CurrentTrack = queuedTrack;

            // At this point we may potentially be in an async context from tests. This is extremely dangerous but we have to make do for now.
            // CurrentTrack is immediately updated above for situations where a immediate knowledge about the new track is required,
            // but the mutation of the hierarchy is scheduled to avoid exceptions.
            Schedule(() =>
            {
                lastTrack.VolumeTo(0, 500, Easing.Out).Expire();

                if (queuedTrack == CurrentTrack)
                {
                    AddInternal(queuedTrack);
                    queuedTrack.VolumeTo(0).Then().VolumeTo(1, 300, Easing.Out);
                }
                else
                {
                    // If the track has changed since the call to changeTrack, it is safe to dispose the
                    // queued track rather than consume it.
                    queuedTrack.Dispose();
                }
            });
        }
Ejemplo n.º 3
0
        private DrawableTrack getQueuedTrack()
        {
            // Important to keep this in its own method to avoid inadvertently capturing unnecessary variables in the callback.
            // Can lead to leaks.
            var queuedTrack = new DrawableTrack(current.LoadTrack());

            queuedTrack.Completed += () => onTrackCompleted(current);
            return(queuedTrack);
        }
Ejemplo n.º 4
0
        private void load(ITrackStore tracks)
        {
            bassTrack = (TrackBass)tracks.Get("sample-track.mp3");
            int length = bassTrack.CurrentAmplitudes.FrequencyAmplitudes.Length;

            Children = new Drawable[]
            {
                track = new DrawableTrack(bassTrack),
                new GridContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Content          = new[]
                    {
                        new Drawable[]
                        {
                            new Container
                            {
                                RelativeSizeAxes = Axes.Both,
                                Children         = new Drawable[]
                                {
                                    leftChannel = new Box
                                    {
                                        RelativeSizeAxes = Axes.Both,
                                        Anchor           = Anchor.Centre,
                                        Origin           = Anchor.CentreRight,
                                    },
                                    rightChannel = new Box
                                    {
                                        RelativeSizeAxes = Axes.Both,
                                        Anchor           = Anchor.Centre,
                                        Origin           = Anchor.CentreLeft,
                                    }
                                }
                            },
                        },
                        new Drawable[]
                        {
                            amplitudeBoxes = new Container
                            {
                                RelativeSizeAxes   = Axes.Both,
                                ChildrenEnumerable =
                                    Enumerable.Range(0, length)
                                    .Select(i => new Box
                                {
                                    RelativeSizeAxes     = Axes.Both,
                                    RelativePositionAxes = Axes.X,
                                    Anchor = Anchor.BottomLeft,
                                    Origin = Anchor.BottomLeft,
                                    Width  = 1f / length,
                                    X      = (float)i / length
                                })
                            },
                        }
                    }
                },
            };
        }
Ejemplo n.º 5
0
        private void loopTrack()
        {
            CurrentTrackNum += 1;

            if (CurrentTrackNum > trackList.Length - 1)
            {
                CurrentTrackNum = 0;
            }

            track        = new DrawableTrack(audio.Tracks.Get($"{trackList[CurrentTrackNum]}"));
            CurrentBPM   = trackBPMList[CurrentTrackNum];
            CurrentTrack = trackList[CurrentTrackNum];
        }
            private void load(ITrackStore tracks, ISampleStore samples)
            {
                track  = new DrawableTrack(tracks.Get("sample-track.mp3"));
                sample = new DrawableSample(samples.Get("long.mp3"));

                if (withMixer)
                {
                    InternalChild = new DrawableAudioMixer {
                        Children = new Drawable[] { track, sample }
                    }
                }
                ;
                else
                {
                    InternalChildren = new Drawable[] { track, sample }
                };
            }
Ejemplo n.º 7
0
        private void changeTrack()
        {
            var lastTrack = CurrentTrack;

            var queuedTrack = new DrawableTrack(current.LoadTrack());

            queuedTrack.Completed += () => onTrackCompleted(current);

            CurrentTrack = queuedTrack;

            Schedule(() =>
            {
                lastTrack.Expire();

                if (queuedTrack == CurrentTrack)
                {
                    AddInternal(queuedTrack);
                }
                else
                {
                    queuedTrack.Dispose();
                }
            });
        }
 public void Setup() => Schedule(() =>
 {
     Child = track = new DrawableTrack(trackStore.Get("sample-track"));
 });
Ejemplo n.º 9
0
 private void load()
 {
     track = new DrawableTrack(audio.Tracks.Get($"{CurrentTrack}"));
 }