private async void SliderManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e) { _sliderManipulationStarted = false; KodiRemote.Core.Model.Player player = await LoadPlayerAsync(); if (player == null) { return; } // Disable temporarily the slider Slider slider = e.OriginalSource as Slider; if (slider != null) { slider.IsEnabled = false; } try { TimeSpan time = TimeSpan.FromMilliseconds(CurrentPosition); await App.Context.Connection.Kodi.Player.SeekAsync(player.PlayerId, time.Milliseconds, time.Seconds, time.Minutes, time.Hours); } catch { } // Re-enable the slider if (slider != null) { slider.IsEnabled = true; } }
//private void SetOrientation(PageOrientation orientation) //{ // if ((orientation & PageOrientation.Portrait) == (PageOrientation.Portrait)) // { // RemoteV.Visibility = Visibility.Visible; // RemoteH.Visibility = Visibility.Collapsed; // } // else // { // RemoteV.Visibility = Visibility.Collapsed; // RemoteH.Visibility = Visibility.Visible; // } //} #region Timer private async void TimerTick(object sender, object e) { _timer.Stop(); await GetVolumeAsync(); KodiRemote.Core.Model.Player player = await LoadPlayerAsync(); SliderGridH.Visibility = SliderGridV.Visibility = player == null ? Visibility.Collapsed : Visibility.Visible; ImageKodiV.Visibility = ImageKodiH.Visibility = player != null ? Visibility.Collapsed : Visibility.Visible; if (player != null) { await LoadCurrentPlayAsync(player); } else { ImageUrl = null; CurrentPlayingTitle = string.Empty; } if (!App.Context.Connection.Kodi.IsMocked) { _timer.Start(); } }
private async Task LoadCurrentPlayAsync(KodiRemote.Core.Model.Player player) { if (player == null) { return; } try { var item = await App.Context.Connection.Kodi.Player.GetItemAsync(player.PlayerId, ListFieldsAll.album, ListFieldsAll.title, ListFieldsAll.artist, ListFieldsAll.thumbnail); var properties = await App.Context.Connection.Kodi.Player.GetPropertiesAsync(player.PlayerId, PlayerPropertyName.time, PlayerPropertyName.totaltime); if (!_sliderManipulationStarted) { CurrentPosition = properties.Time.TotalMilliseconds(); } Lenght = properties.TotalTime.TotalMilliseconds(); if (item.Thumbnail.Contains("DefaultAlbumCover")) { ImageUrl = "/Assets/Default/DefaultAlbumCover.png"; } else if (item.Thumbnail.Contains("DefaultVideo")) { ImageUrl = "/Assets/Default/DefaultVideo.png"; } else if (string.IsNullOrWhiteSpace(item.Thumbnail) && item.Type == "song") { ImageUrl = "/Assets/Default/DefaultAlbumCover.png"; } else if (string.IsNullOrWhiteSpace(item.Thumbnail)) { ImageUrl = ""; } else { var download = await App.Context.Connection.Kodi.Files.PrepareDownloadAsync(item.Thumbnail); string url = App.Context.Connection.Kodi.GetFileUrl(download.Details.Path); if (url != null && ImageUrl != url) { ImageUrl = url; } } CurrentPlayingTitle = string.IsNullOrWhiteSpace(item.Title) ? item.Label : item.Title; var artist = item.Artist.FirstOrDefault(); if (!string.IsNullOrWhiteSpace(item.Album) && artist != null) { CurrentPlayingTitle += string.Concat("\r", artist, " - ", item.Album); } } catch { } }