public PlaybackBar(CGRect rect) : base(rect) { BackgroundColor = NSColor.FromRgba(249, 249, 249, 255); AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable; AddSubview(AlbumArt = new NSImageView(new CGRect(0, 0, 67, 67))); videoView = new VideoView { WantsLayer = true, Hidden = true }; videoView.MakeBackingLayer(); AddSubview(previous = CreateButton("SVG/previous.svg", PlaybackManager.Shared.Previous)); AddSubview(play = CreateButton("SVG/playButtonBordered.svg", () => { if (playing) { PlaybackManager.Shared.Pause(); } else { PlaybackManager.Shared.Play(); } })); AddSubview(next = CreateButton("SVG/next.svg", () => PlaybackManager.Shared.NextTrack())); AddSubview(textView = new TwoLabelView()); AddSubview(progress = new ProgressView()); AddSubview(shuffle = CreateButton("SVG/shuffle.svg", 25, PlaybackManager.Shared.ToggleRandom)); AddSubview(repeat = CreateButton("SVG/repeat.svg", 25, PlaybackManager.Shared.ToggleRepeat)); AddSubview(time = new NSTextField { StringValue = "0000:00" }.StyleAsSubText()); time.SizeToFit(); AddSubview(remaining = new NSTextField { StringValue = "0000:00", Alignment = NSTextAlignment.Right }.StyleAsSubText()); remaining.SizeToFit(); AddSubview(volumeSlider = new NSSlider { DoubleValue = Settings.CurrentVolume, MinValue = 0, MaxValue = 1 }); volumeSlider.Activated += (object sender, EventArgs e) => { Settings.CurrentVolume = (float)volumeSlider.DoubleValue; }; volumeSlider.SizeToFit(); AddSubview(thumbsDown = CreateButton("SVG/thumbsDown.svg", 30, async() => { var song = MusicManager.Shared.GetCurrentSong(); if (song.Rating != 1) { await MusicManager.Shared.ThumbsDown(song); } else { await MusicManager.Shared.Unrate(song); } SetThumbsState(song); })); AddSubview(thumbsUp = CreateButton("SVG/thumbsUp.svg", 30, async() => { var song = MusicManager.Shared.GetCurrentSong(); if (song.Rating != 5) { await MusicManager.Shared.ThumbsUp(song); } else { await MusicManager.Shared.Unrate(song); } SetThumbsState(song); })); Update(PlaybackManager.Shared.NativePlayer.CurrentSong); var dropShadow = new NSShadow { ShadowColor = NSColor.Black, }; this.WantsLayer = true; this.Shadow = dropShadow; NotificationManager.Shared.CurrentSongChanged += (sender, e) => Update(e.Data); NotificationManager.Shared.PlaybackStateChanged += (sender, e) => SetState(e.Data); NotificationManager.Shared.CurrentTrackPositionChanged += (object sender, SimpleTables.EventArgs <TrackPosition> e) => { var data = e.Data; //timeLabel.Text = data.CurrentTimeString; //remainingTimeLabel.Text = data.RemainingTimeString; progress.Progress = data.Percent; time.StringValue = data.CurrentTimeString; remaining.StringValue = data.RemainingTimeString; }; NotificationManager.Shared.ShuffleChanged += (sender, args) => SetShuffleState(args.Data); NotificationManager.Shared.RepeatChanged += (sender, args) => SetRepeatState(args.Data); NotificationManager.Shared.SongDownloadPulsed += (object sender, NotificationManager.SongDowloadEventArgs e) => { if (e.SongId != Settings.CurrentSong) { return; } progress.DownloadProgress = e.Percent; }; // NotificationManager.Shared.ToggleFullScreenVideo += (s, a) => ToggleFullScreenVideo(); SetState(PlaybackState.Stopped); SetShuffleState(Settings.ShuffleSongs); SetRepeatState(Settings.RepeatMode); }