示例#1
0
        public AutoPlaylistSongsListView(AutoPlaylist playlist)
        {
            //BackgroundColor = NSColor.Blue;
            TableView.AddColumn(new NSTableColumn("Title")
            {
                Title = "Title"
            });
            TableView.AddColumn(new NSTableColumn("Artist")
            {
                Title = "Artist"
            });
            TableView.AddColumn(new NSTableColumn("Album")
            {
                Title = "Album"
            });
            TableView.DoubleClick += (object sender, EventArgs e) => {
                var item = Model.GetItem(TableView.SelectedRow);
                Model.PlayItem(item);
            };

            Model = new AutoPlaylistSongViewModel
            {
                Playlist = playlist,
                AutoPlay = false,
            };
        }
示例#2
0
        public async Task PlayAutoPlaylist(AutoPlaylist playlist, Song playlistSong, GroupInfo groupInfo = null)
        {
            if (groupInfo == null)
            {
                groupInfo = AutoPlaylistSongViewModel.CreateGroupInfo(playlist, Settings.ShowOfflineOnly);
            }
            LogManager.Shared.LogPlayback(playlist);
            SendEndNotification(ScrobbleManager.PlaybackEndedReason.Skipped);
            Settings.CurrentPlaybackContext = new PlaybackContext
            {
                IsContinuous = false,
                Type         = PlaybackContext.PlaybackType.Playlist,
                ParentId     = playlist.Id,
            };
            Pause();
            var song = playlistSong;
            var info = groupInfo.Clone();
            await Task.WhenAll(
                NativePlayer.PlaySong(song),
                Task.Run(async() =>
            {
                string query =
                    $"select Id from Song {info.FilterString(true)} {info.OrderByString(true)} {info.LimitString()}";
                var queryInfo = info.ConvertSqlFromNamed(query);
                await SetupCurrentPlaylist(queryInfo.Item1, song?.Id ?? "", queryInfo.Item2);
            }));

            if (song == null)
            {
                song = GetSong(CurrentSongIndex);
                await NativePlayer.PlaySong(song);
            }
            await PrepareNextTrack();
        }
 public AutoPlaylistSongsViewController(AutoPlaylist playlist)
 {
     model = new AutoPlaylistSongViewModel
     {
         Playlist = playlist,
     };
     Title = model.Title;
 }
示例#4
0
        private void PlaylistTab_VisibleChanged(object sender, EventArgs e)
        {
            if (!this.Visible)
            {
                this.treeView.Nodes["NodePlaylist"].Nodes.Clear();
                this.imageList.Images.Clear();
                this.lblStatus.Visible = false;
                return;
            }
            else
            {
                if (System.IO.Directory.Exists(Paths.PlaylistFolder))
                {
                    savedPlaylists = SimplePlaylist <Song> .LoadFromDirectory(Paths.PlaylistFolder).ToList();
                }

                int count = 0;

                if (savedPlaylists != null)
                {
                    this.imageList.Images.Add(Resources.MailArr);
                    this.imageList.Images.Add(Resources.SimplePl);
                    this.imageList.Images.Add(Resources.AutoPlaylist);

                    this.treeView.ImageList = this.imageList;
                    this.treeView.Nodes["NodePlaylist"].ImageIndex = 0;

                    foreach (var playlist in savedPlaylists)
                    {
                        var node = this.treeView.Nodes["NodePlaylist"].Nodes.Add(playlist.Name);
                        node.ImageIndex         = 1;
                        node.SelectedImageIndex = 1;
                    }
                    count = savedPlaylists.Count;
                }

                if (System.IO.Directory.Exists(Paths.AutomaticPlaylistFolder))
                {
                    savedPlaylists.AddRange(AutoPlaylist <Song> .LoadFromDirectory(Paths.AutomaticPlaylistFolder));
                }

                if (savedPlaylists != null)
                {
                    for (int i = count; i < savedPlaylists.Count; i++)
                    {
                        var node = this.treeView.Nodes["NodePlaylist"].Nodes.Add(savedPlaylists[i].Name);
                        node.ImageIndex         = 2;
                        node.SelectedImageIndex = 2;
                    }
                }

                this.treeView.SelectedNode = this.treeView.Nodes["NodePlaylist"];
                this.treeView.Select();
                this.treeView.ExpandAll();
            }
        }
示例#5
0
        public static GroupInfo CreateGroupInfo(AutoPlaylist playlist, bool offlineOnly = false)
        {
            var gi = new GroupInfo {
                Filter = playlist.WhereClause, OrderBy = playlist.OrderByClause, Limit = playlist.Limit
            };

            if (offlineOnly && Settings.ShowOfflineOnly)
            {
                gi.Filter = gi.Filter + (string.IsNullOrEmpty(gi.Filter) ? " " : " and ") + "OfflineCount > 0";
            }
            return(gi);
        }