Пример #1
0
        private async void Sample_GetImageToCurrentPlayingItem(Client xbmc)
        {
            var wellKnownPlayerIdVideo = 1; //or use xbmc.Player.GetActivePlayers()
            var getCurrentItemResponse = await xbmc.Player.GetItem(wellKnownPlayerIdVideo, All.AllFields());

            var currentPlayingVideo = getCurrentItemResponse.item.AsMediaDetailsBase;
            //use AllMedia for audio player or the shared base class for both: XBMCRPC.Media.Details.Base
            var imageStream = await xbmc.GetImageStream(currentPlayingVideo.thumbnail);

            //display in image control:
            var bitmapImage = new BitmapImage();

            bitmapImage.BeginInit();
            bitmapImage.StreamSource = imageStream;
            bitmapImage.EndInit();
            ThumbImage.Source = bitmapImage;
        }
Пример #2
0
        private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            System.Collections.Generic.List <string> s;
            IPlatformServices platformServices = new PlatformServices();
            var xbmc = new Client(platformServices, "localhost", 85);
            var m    = await xbmc.VideoLibrary.GetMovies(new XBMCRPC.List.Filter.Rule.Movies()
            {
                field = Movies.playcount, Operator = Operators.Is, value = "0"
            }, Movie.AllFields(), new Limits()
            {
                start = 1, end = 10
            });

            xbmc.Playlist.OnClear += Playlist_OnClear;

            //await xbmc.StartNotificationListener();

            var p = await xbmc.Application.GetProperties(GetProperties_properties.AllFields());

            var wellKnownPlayerIdVideo         = 1; //or use xbmc.Player.GetActivePlayers()
            var playerPropertiesPercentageOnly = await xbmc.Player.GetProperties(1, new XBMCRPC.Player.GetProperties_properties()
            {
                XBMCRPC.Player.Property.Name.percentage
            });

            var playerPropertiesAll = await xbmc.Player.GetProperties(1, XBMCRPC.Player.GetProperties_properties.AllFields());

            var ret0 = await xbmc.JSONRPC.Introspect();

            var ret1 = await xbmc.Application.GetProperties(GetProperties_properties.AllFields());

            var ret2 = await xbmc.VideoLibrary.GetTVShows(TVShow.AllFields());

            var ret3 = await xbmc.VideoLibrary.SetMovieDetails(3, playcount : 10);

            var ret4 = await xbmc.VideoLibrary.GetMovies(Movie.AllFields(), new Limits()
            {
                start = 1, end = 10
            });

            var ret4a = await xbmc.Files.PrepareDownload(ret4.movies[0].thumbnail);

            var unlistedFiles = await GetUnlistedFiles(xbmc);


            var ret5 = await xbmc.Files.GetSources();

            var ret5a = await xbmc.Files.GetDirectory(ret5.sources[5].file);

            var ret5b = await xbmc.Files.GetDirectory(ret5a.files[0].file);

            var ret5c = await xbmc.Files.GetDirectory(ret5b.files[0].file, Media.files, Files.AllFields());

            var ret5d = await xbmc.Files.GetDirectory("C:\\Archiv\\Serien1\\How I met your Mother\\Staffel 3", Media.video);

            var ret5e = await xbmc.Files.GetDirectory("C:\\Archiv\\HD2", Media.video, Files.AllFields());

            var ret6 = await xbmc.Files.GetDirectory(@"C:\Users\steve_000\Music\Amazon MP3\die ärzte\auch", Media.music, Files.AllFields());

            var ret7 = await xbmc.Playlist.GetItems(0, properties : All.AllFields());

            var ret7a = await xbmc.Playlist.GetItems(1, properties : All.AllFields());

            var ret8 = await xbmc.Playlist.GetPlaylists();

            var ret9 = await xbmc.Player.GetActivePlayers();

            Sample_GetImageToCurrentPlayingItem(xbmc);
        }
Пример #3
0
        private async Task GetCurrentPlayingItem(CancellationToken delayCancel)
        {
            var activePlayers = await _appContext.XBMC.Player.GetActivePlayers();

            if (activePlayers.Count == 0)
            {
                bool anyUpnp = false;
                try
                {
                    foreach (var renderer in _appContext.Upnp.AvailableRenderDevices)
                    {
                        var curPlayback = await renderer.AVTransport.GetCurrentPlaybackItem();

                        Uri curUri;
                        if (Uri.TryCreate(curPlayback.PosTrackuri, UriKind.Absolute, out curUri))
                        {
                            if (curPlayback.TranspState != "STOPPED")
                            {
                                if (await _appContext.Upnp.IsXbmcHost(curUri))
                                {
                                    anyUpnp   = true;
                                    IsPlaying = true;
                                    if (CurrentItem == null || CurrentItem.Id != curPlayback.PosTrackuri)
                                    {
                                        CurrentItem = CurrentItemFactory(curPlayback);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    if (Debugger.IsAttached)
                    {
                        throw;
                    }
                }
                if (!anyUpnp)
                {
                    IsPlaying   = false;
                    CurrentItem = null;
                }
                await Task.Delay(TimeSpan.FromSeconds(10), delayCancel);
            }
            else
            {
                var activePlayer = activePlayers[0];
                //switch (activePlayer.type)
                //{
                //    case Type.audio:
                //        break;
                //    case Type.video:
                //        break;
                //    case Type.picture:
                //        break;
                //}

                IsPlaying = true;
                var getCurrentItemResponse =
                    await _appContext.XBMC.Player.GetItem(activePlayer.playerid);

                if (CurrentItem == null || CurrentItem.Id != getCurrentItemResponse.item.id.ToString())
                {
                    getCurrentItemResponse = await _appContext.XBMC.Player.GetItem(activePlayer.playerid, All.AllFields());

                    var currentPlayingVideo = getCurrentItemResponse.item;
                    CurrentItem = CurrentItemFactory(currentPlayingVideo, activePlayer.playerid);
                    await GetPlaylist(activePlayer.playerid);
                }
            }
            if (CurrentItem != null)
            {
                await CurrentItem.Refresh();

                await Task.Delay(OneSecond);
            }
            if (CurrentItem != null)
            {
                CurrentItem.RefreshTime();
                await Task.Delay(OneSecond);
            }
        }