/// <summary>Gets all available addons.</summary> public async Task <AddonsResponse> GetAddonsAsync(AddonTypes addonType = AddonTypes.unknown, AddonContent addonContent = AddonContent.unknown, AddonEnabled addonEnabled = AddonEnabled.all, int start = 0, int end = int.MaxValue, params AddonFields[] fields) { string[] properties = fields.Select(p => p.ToString().ToLowerInvariant()).ToArray(); if (!properties.Any()) { properties = Enum.GetNames(typeof(AddonFields)); } var method = new ParameteredMethodMessage <GetAddonsParameters> { Method = "Addons.GetAddons", Parameters = new GetAddonsParameters { Properties = properties, Enabled = addonEnabled.ToString(), Type = addonType.ToString(), Content = addonContent.ToString().Replace("_", "."), Limits = new ListLimits { Start = start, End = end } } }; var result = await _request.SendRequestAsync <BasicResponseMessage <AddonsResponse> >(method); return(result.Result); }
/// <summary>Retrieve all genres.</summary> public async Task <GenresResponse> GetGenresAsync(bool ignorearticle = false, SortMethod sortMethod = SortMethod.none, SortOrder sortOrder = SortOrder.Ascending, int start = 0, int end = int.MaxValue, params LibraryFieldsGenre[] fields) { string[] properties = fields.Select(p => p.ToString().ToLowerInvariant()).ToArray(); if (!properties.Any()) { properties = Enum.GetNames(typeof(LibraryFieldsGenre)); } var method = new ParameteredMethodMessage <LimitsSortPropertiesParameters> { Method = "AudioLibrary.GetGenres", Parameters = new LimitsSortPropertiesParameters { Properties = properties, Limits = new ListLimits { Start = start, End = end }, Sort = new ListSort { IgnoreArticle = ignorearticle, Order = sortOrder.ToString().ToLowerInvariant(), Method = sortMethod.ToString().ToLowerInvariant() } } }; var result = await _request.SendRequestAsync <BasicResponseMessage <GenresResponse> >(method); return(result.Result); }
/// <summary>Seek through the playing item.</summary> private async Task SeekAsync <T>(T parameters) where T : PlayerPositionParameters { var method = new ParameteredMethodMessage <T> { Method = "Player.Seek", Parameters = parameters }; await _request.SendRequestAsync <BasicResponseMessage <string> >(method); }
/// <summary>Clear playlist.</summary> public async Task ClearAsync(int playlistId) { var method = new ParameteredMethodMessage <PlaylistIdParameters> { Method = "Playlist.Clear", Parameters = new PlaylistIdParameters { PlaylistId = playlistId } }; await _request.SendRequestAsync <BasicResponseMessage <string> >(method); }
/// <summary>Pauses or unpause playback and returns the new state.</summary> public async Task PlayPauseAsync(int playerId) { var method = new ParameteredMethodMessage <PlayerParameters> { Method = "Player.PlayPause", Parameters = new PlayerParameters { PlayerId = playerId } }; await _request.SendRequestAsync <BasicResponseMessage <PlayerSpeed> >(method); }
/// <summary>Activates the given window.</summary> public async Task ActivateWindowAsync(GuiWindow guiWindow) { var method = new ParameteredMethodMessage <GuiWindowParameters> { Method = "GUI.ActivateWindow", Parameters = new GuiWindowParameters { Window = guiWindow.ToString() } }; await _request.SendRequestAsync <BasicResponseMessage <string> >(method); }
/// <summary>Stops playback.</summary> public async Task StopAsync(int playerId) { var method = new ParameteredMethodMessage <PlayerParameters> { Method = "Player.Stop", Parameters = new PlayerParameters { PlayerId = playerId } }; await _request.SendRequestAsync <BasicResponseMessage <string> >(method); }
/// <summary>Execute a specific action.</summary> public async Task ExecuteActionAsync(InputActions inputAction) { var method = new ParameteredMethodMessage <InputActionParameters> { Method = "Input.ExecuteAction", Parameters = new InputActionParameters { Action = inputAction.ToString() } }; await _request.SendRequestAsync <BasicResponseMessage <string> >(method); }
/// <summary>Provides a way to download a given file (e.g. providing an URL to the real file location).</summary> public async Task <PrepareDownload> PrepareDownloadAsync(string path) { var method = new ParameteredMethodMessage <FilesDownloadParameters> { Method = "Files.PrepareDownload", Parameters = new FilesDownloadParameters { Path = path } }; var result = await _request.SendRequestAsync <SingleValueResponseMessage <PrepareDownload> >(method); return(result.Result); }
/// <summary>Downloads the given file.</summary> public async Task <string> DownloadAsync(string path) { var method = new ParameteredMethodMessage <FilesDownloadParameters> { Method = "Files.Download", Parameters = new FilesDownloadParameters { Path = path } }; var result = await _request.SendRequestAsync <BasicResponseMessage <string> >(method); return(result.Result); }
/// <summary>Scans the audio sources for new library items.</summary> public async Task <string> ScanAsync(string directory = null) { var method = new ParameteredMethodMessage <ScanParameters> { Method = "AudioLibrary.Scan", Parameters = new ScanParameters { Directory = directory } }; var result = await _request.SendRequestAsync <BasicResponseMessage <string> >(method); return(result.Result); }
// TODO: use Global.Toggle [ enum { toggle } ] /// <summary>Set the current volume.</summary> public async Task <int> SetVolumeAsync(int volume) { var method = new ParameteredMethodMessage <VolumeParameters> { Method = "Application.SetVolume", Parameters = new VolumeValueParameters { Volume = volume } }; var result = await _request.SendRequestAsync <BasicResponseMessage <int> >(method); return(result.Result); }
/// <summary>Send a generic (unicode) text.</summary> /// <param name="text">Text to send.</param> /// <param name="done">Whether this is the whole input or not (closes an open input dialog if true).</param> public async Task SendTextAsync(string text, bool done = true) { var method = new ParameteredMethodMessage <InputSendTextParameters> { Method = "Input.SendText", Parameters = new InputSendTextParameters { Text = text, Done = done } }; await _request.SendRequestAsync <BasicResponseMessage <string> >(method); }
private async Task <int> SetVolumeAsync(string where) { var method = new ParameteredMethodMessage <VolumeDirectionParameters> { Method = "Application.SetVolume", Parameters = new VolumeDirectionParameters { Volume = where } }; var result = await _request.SendRequestAsync <BasicResponseMessage <int> >(method); return(result.Result); }
public async Task <string> RemoveAsync(int playlistId, int position) { var method = new ParameteredMethodMessage <PlaylistRemove> { Method = "Playlist.Remove", Parameters = new PlaylistRemove { PlaylistId = playlistId, Position = position } }; var item = await _request.SendRequestAsync <BasicResponseMessage <string> >(method); return(item.Result); }
/// <summary>Downloads the given file.</summary> public async Task <bool> SetMuteAsync(bool mute) { var method = new ParameteredMethodMessage <MuteParameters> { Method = "Application.SetMute", Parameters = new MuteParameters { Mute = mute } }; var result = await _request.SendRequestAsync <BasicResponseMessage <bool> >(method); return(result.Result); }
/// <summary>Add item(s) to playlist.</summary> public async Task AddAsync(int playlistId, int?songId = null, int?albumId = null, int?movieId = null, int?episodeId = null) { var method = new ParameteredMethodMessage <PlaylistAdd> { Method = "Playlist.Add", Parameters = new PlaylistAdd { PlaylistId = playlistId, Item = new PlaylistItem { SongId = songId, AlbumId = albumId, MovieId = movieId, EpisodeId = episodeId } } }; await _request.SendRequestAsync <BasicResponseMessage <string> >(method); }
/// <summary>Go to previous/next/specific item in the playlist.</summary> public async Task <string> GoToAsync(int playerId, GoTos where) { var method = new ParameteredMethodMessage <GoToParameters> { Method = "Player.GoTo", Parameters = new GoToParameters { PlayerId = playerId, To = where.ToString().ToLowerInvariant() } }; var result = await _request.SendRequestAsync <BasicResponseMessage <string> >(method); return(result.Result); }
/// <summary>Enables/Disables a specific addon.</summary> public async Task <string> SetAddonEnabledAsync(string addonid, bool enabled) { var method = new ParameteredMethodMessage <SetAddonEnabledParameters> { Method = "Addons.SetAddonEnabled", Parameters = new SetAddonEnabledParameters { AddonId = addonid, Enabled = enabled, } }; var result = await _request.SendRequestAsync <BasicResponseMessage <string> >(method); return(result.Result); }
/// <summary>Go to previous/next/specific item in the playlist.</summary> public async Task <string> ShowNotification(string title, string message, string image = "", int displaytime = 5000) { var method = new ParameteredMethodMessage <ShowNotificationParameters> { Method = "GUI.ShowNotification", Parameters = new ShowNotificationParameters { DisplayTime = displaytime, Message = message, Title = title, Image = image } }; var result = await _request.SendRequestAsync <BasicResponseMessage <string> >(method); return(result.Result); }
/// <summary>Retrieve info labels about Kodi and the system.</summary> public async Task <Dictionary <string, string> > GetInfoLabelsAsync(string label, params string[] labels) { var lbls = new List <string>(labels); lbls.Insert(0, label); var method = new ParameteredMethodMessage <XbmcLabelsParameters> { Method = "XBMC.GetInfoLabels", Parameters = new XbmcLabelsParameters { Labels = lbls.ToArray() } }; var result = await _request.SendRequestAsync <BasicResponseMessage <Dictionary <string, string> > >(method); return(result.Result); }
/// <summary>Start playback of either the playlist with the given ID, a slideshow with the pictures from the given directory or a single file or an item from the database.</summary> public async Task <string> OpenAsync(PlaylistItem item) { var method = new ParameteredMethodMessage <OpenParameters <PlaylistItem> > { Method = "Player.Open", Parameters = new OpenParameters <PlaylistItem> { Item = item, Options = new OpenOptions { Repeat = PlayerRepeat.Off.ToString().ToLowerInvariant() } } }; var response = await _request.SendRequestAsync <BasicResponseMessage <string> >(method); return(response.Result); }
/// <summary>Start playback of either the playlist with the given ID, a slideshow with the pictures from the given directory or a single file or an item from the database.</summary> public async Task <string> OpenAsync(int?songId = null, int?albumId = null, int?movieId = null, int?episodeId = null) { var method = new ParameteredMethodMessage <OpenParameters <PlaylistItem> > { Method = "Player.Open", Parameters = new OpenParameters <PlaylistItem> { Item = new PlaylistItem { SongId = songId, AlbumId = albumId, MovieId = movieId, EpisodeId = episodeId }, Options = new OpenOptions { Repeat = PlayerRepeat.Off.ToString().ToLowerInvariant() } } }; var item = await _request.SendRequestAsync <BasicResponseMessage <string> >(method); return(item.Result); }
/// <summary>Retrieves the values of the given properties.</summary> public async Task <SystemPropertyValue> GetPropertiesAsync(params PropertyNames[] propertyName) { string[] items = propertyName.Select(p => p.ToString().ToLowerInvariant()).ToArray(); if (!items.Any()) { items = Enum.GetNames(typeof(PropertyNames)); } var method = new ParameteredMethodMessage <ItemsParameters> { Method = "System.GetProperties", Parameters = new ItemsParameters { Items = items } }; var result = await _request.SendRequestAsync <BasicResponseMessage <SystemPropertyValue> >(method); return(result.Result); }
/// <summary>Quit application.</summary> public async Task <ApplicationPropertiesResponseMessage> GetPropertiesAsync(params ApplicationPropertyName[] names) { string[] properties = names.Select(p => p.ToString().ToLowerInvariant()).ToArray(); if (!properties.Any()) { properties = Enum.GetNames(typeof(ApplicationPropertyName)); } var method = new ParameteredMethodMessage <PropertiesParameters> { Method = "Application.GetProperties", Parameters = new PropertiesParameters { Properties = properties } }; var item = await _request.SendRequestAsync <BasicResponseMessage <ApplicationPropertiesResponseMessage> >(method); return(item.Result); }
/// <summary>Retrieve details about a specific tv show.</summary> public async Task <VideoDetailsTvShowResponse> GetTvShowDetailsAsync(int tvShowId, params VideoFieldsTVShow[] fields) { string[] items = fields.Select(p => p.ToString().ToLowerInvariant()).ToArray(); if (!items.Any()) { items = Enum.GetNames(typeof(VideoFieldsTVShow)); } var method = new ParameteredMethodMessage <GetTVShowParameters> { Method = "VideoLibrary.GetTVShowDetails", Parameters = new GetTVShowParameters { TvShowId = tvShowId, Properties = items } }; var result = await _request.SendRequestAsync <BasicResponseMessage <VideoDetailsTvShowResponse> >(method); return(result.Result); }
/// <summary>Get all items from playlist.</summary> public async Task <PlaylistGetItems> GetItemsAsync(int playlistId, params ListFieldsAll[] fields) { string[] properties = fields.Select(p => p.ToString().ToLowerInvariant()).ToArray(); if (!properties.Any()) { properties = Enum.GetNames(typeof(ListFieldsAll)); } var method = new ParameteredMethodMessage <PlaylistParameters> { Method = "Playlist.GetItems", Parameters = new PlaylistParameters { PlayListId = playlistId, Properties = properties } }; var item = await _request.SendRequestAsync <BasicResponseMessage <PlaylistGetItems> >(method); return(item.Result); }
/// <summary>Retrieves the values of the given properties.</summary> public async Task <PlayerPropertyValue> GetPropertiesAsync(int playerId, params PlayerPropertyName[] fields) { string[] properties = fields.Select(p => p.ToString().ToLowerInvariant()).ToArray(); if (!properties.Any()) { properties = Enum.GetNames(typeof(PlayerPropertyName)); } var method = new ParameteredMethodMessage <PlayerGetItemParameters> { Method = "Player.GetProperties", Parameters = new PlayerGetItemParameters { PlayerId = playerId, Properties = properties } }; var item = await _request.SendRequestAsync <SingleValueResponseMessage <PlayerPropertyValue> >(method); return(item.Result); }
/// <summary>Retrieve details about a specific artist.</summary> public async Task <AudioDetailsArtist> GetArtistDetailsAsync(int artistId, params AudioFieldsArtist[] fields) { string[] items = fields.Select(p => p.ToString().ToLowerInvariant()).ToArray(); if (!items.Any()) { items = Enum.GetNames(typeof(AudioFieldsArtist)); } var method = new ParameteredMethodMessage <ArtistFieldsParameters> { Method = "AudioLibrary.GetArtistDetails", Parameters = new ArtistFieldsParameters { ArtistId = artistId, Properties = items } }; var result = await _request.SendRequestAsync <BasicResponseMessage <ArtistDetails> >(method); return(result.Result.Details); }
/// <summary>Gets the details of a specific addon.</summary> public async Task <AddonDetailsBase> GetAddonDetailsAsync(string addonid, params AddonFields[] fields) { string[] items = fields.Select(p => p.ToString().ToLowerInvariant()).ToArray(); if (!items.Any()) { items = Enum.GetNames(typeof(AddonFields)); } var method = new ParameteredMethodMessage <AddonDetailsParameters> { Method = "Addons.GetAddonDetails", Parameters = new AddonDetailsParameters { AddonId = addonid, Properties = items } }; var result = await _request.SendRequestAsync <BasicResponseMessage <AddonBase> >(method); return(result.Result.Addon); }