Пример #1
0
        private void btnPrev_Click(object sender, RoutedEventArgs e)
        {
            //TODO: When these buttons are clicked update playlist to show what's playing
            KodiMoveRequest R = new KodiMoveRequest(MyInfo.CurrentPlayerId, "left");

            Task.Factory.StartNew(() => KodiCommand.SendKodiCommandAsync(MyInfo.KodiServer, HelperMethods.SerializeObject(R)));
        }
Пример #2
0
 private void btnPlaylistDeleteEntry_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         MusicFolderEntry item = (MusicFolderEntry)(sender as FrameworkElement).DataContext;
         int index             = lvPlaylist.Items.IndexOf(item);
         KodiCommand.SendKodiCommandAsync(MyInfo.KodiServer, HelperMethods.SerializeObject(new KodiRemoveItemFromPlaylist(MyInfo.CurrentPlaylistId, index)));
         foreach (MusicFolderEntry listitem in MyInfo.PlaylistEntries)
         {
             if (listitem.file == item.file)
             {
                 MyInfo.PlaylistEntries.Remove(listitem);
                 break;
             }
         }
         lvPlaylist.ItemsSource = null;
         BindingOperations.SetBinding(lvPlaylist, ListView.ItemsSourceProperty, new Binding()
         {
             Source = MyInfo.PlaylistEntries, Mode = BindingMode.OneWay
         });
         lvPlaylist.ScrollIntoView(item);
     }
     catch (Exception ex)
     {
         LogMessage("Error " + ex.ToString());
     }
 }
Пример #3
0
        private async void btnRandom_Click(object sender, RoutedEventArgs e)
        {
            KodiSetShuffle R = new KodiSetShuffle(MyInfo.CurrentPlayerId);
            await Task.Factory.StartNew(() => KodiCommand.SendKodiCommandAsync(MyInfo.KodiServer, HelperMethods.SerializeObject(R)));

            await SyncPlaylistWithKodi(MyInfo.CurrentPlaylistId);

            DisplayFadeMessage("Shuffle Toggled");
        }
Пример #4
0
        private async Task ProcessFirstRunAsync(MusicFolderEntry Entry)
        {
            try
            {
                List <String> Commands;

                Boolean PlaylistExists = await SyncPlaylistWithKodi(MyInfo.CurrentPlaylistId); //Does a playlist with entries exist in Kodi?

                KodiAddFileToPlayList AddRequest = new KodiAddFileToPlayList(MyInfo.CurrentPlaylistId, Entry.file);
                if ((!PlaylistExists || MyInfo.PlaylistEntries.Count == 0))
                {
                    //If playlist id does not exist or has no entries, then create it.
                    Commands = new List <string>();
                    Commands.Add(HelperMethods.SerializeObject(new KodiClearPlayList(MyInfo.CurrentPlaylistId)));
                    Commands.Add(HelperMethods.SerializeObject(AddRequest));
                    Commands.Add(HelperMethods.SerializeObject(new KodiOpenPlayList(MyInfo.CurrentPlaylistId, 0)));
                    await KodiCommand.SendKodiCommandsInOrderAsync(MyInfo.KodiServer, Commands);

                    this.MyInfo.PlaylistEntries.Add(Entry);
                }
                else
                {
                    //Playlist exists and may have entries, add file to end and resync
                    await KodiCommand.SendKodiCommandAsync(MyInfo.KodiServer, HelperMethods.SerializeObject(AddRequest));
                    await SyncPlaylistWithKodi(MyInfo.CurrentPlaylistId);

                    //If something is not already playing then start playlist at currently added file
                    KodiActivePlayersResponse Resp = await KodiCommand.GetActivePlayers(MyInfo.KodiServer);

                    if (Resp.result == null || Resp.result.Length == 0)
                    {
                        await KodiCommand.SendKodiCommandAsync(MyInfo.KodiServer, HelperMethods.SerializeObject(new KodiOpenPlayList(MyInfo.CurrentPlaylistId, this.MyInfo.PlaylistEntries.Count())));
                    }
                }

                //Set repeat mode to true
                await Task.Factory.StartNew(() => KodiCommand.SendKodiCommandAsync(MyInfo.KodiServer, HelperMethods.SerializeObject(new KodiSetRepeat(MyInfo.CurrentPlayerId, "all"))));
            }
            catch (Exception ex)
            {
                ShowErrorMessageAsync(ex);
            }
            this.FirstRun = false;
        }
Пример #5
0
        private async void btnListViewEntry_ClickAsync(object sender, RoutedEventArgs e)
        {
            MusicFolderEntry Entry = ((HomeScreen.MusicFolderEntry)((Windows.UI.Xaml.FrameworkElement)sender).DataContext);

            if (Entry.filetype.ToLower() == "directory")
            {
                MyInfo.MediaFolders.NextFolder(Entry.file);
                LoadFileEntries();
            }

            if (Entry.filetype.ToLower() == "file")
            {
                //Update the screen - This provides visual feedback but is not kept in sync during folder browsing
                Windows.UI.Xaml.Controls.Button TheButton   = ((Windows.UI.Xaml.Controls.Button)sender);
                Windows.UI.Xaml.Controls.Image  ButtonImage = ((Windows.UI.Xaml.Controls.Image)TheButton.Content);
                ButtonImage.Source = new BitmapImage(new Uri(this.BaseUri, "/Assets/musiccheck.png"));
                if (this.FirstRun)
                {
                    //First song you clicked on since the app started
                    ProcessFirstRunAsync(Entry);
                }
                else
                {
                    //Is something playing?
                    KodiActivePlayersResponse Response = await KodiCommand.GetActivePlayers(MyInfo.KodiServer);

                    if (Response.result.Length == 0)
                    {
                        ProcessFirstRunAsync(Entry);
                    }
                    else
                    {
                        //Add file to end of playing list...
                        KodiAddFileToPlayList AddRequest = new KodiAddFileToPlayList(MyInfo.CurrentPlaylistId, Entry.file);
                        Task.Factory.StartNew(() => KodiCommand.SendKodiCommandAsync(MyInfo.KodiServer, HelperMethods.SerializeObject(AddRequest)));
                        this.MyInfo.PlaylistEntries.Add(Entry);
                    }
                }
            }
        }
Пример #6
0
        private void btnPlayPause_Click(object sender, RoutedEventArgs e)
        {
            KodiPlayPauseRequest R = new KodiPlayPauseRequest(MyInfo.CurrentPlayerId);

            Task.Factory.StartNew(() => KodiCommand.SendKodiCommandAsync(MyInfo.KodiServer, HelperMethods.SerializeObject(R)));
        }