// Copyright (c) Arlo Godfrey. All Rights Reserved. // Licensed under the GNU Lesser General Public License, Version 3.0 with additional terms. // See the LICENSE, LICENSE.LESSER and LICENSE.ADDITIONAL files in the project root for more information. using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json; using OwlCore.Events; using OwlCore.Remoting; using StrixMusic.Sdk.CoreModels; using StrixMusic.Sdk.MediaPlayback; namespace StrixMusic.Sdk.Plugins.CoreRemote { /// /// Wraps around an instance of an to enable controlling it remotely, or takes a remotingId to control another instance remotely. /// public sealed class RemoteCoreArtist : ICoreArtist { private readonly MemberRemote _memberRemote; private readonly ICoreArtist? _artist; private string _name; /// /// Creates a new instance of . /// /// The instance ID of the core that created this object. /// A unique identifier for this instance. /// The name of the data. [JsonConstructor] public RemoteCoreArtist(string sourceCoreInstanceId, string name, string id) { _name = name; Id = id; SourceCoreInstanceId = sourceCoreInstanceId; // Properties assigned before MemberRemote is created won't be set remotely. SourceCore = RemoteCore.GetInstance(sourceCoreInstanceId, RemotingMode.Client); // should be set remotely by the ctor. _memberRemote = new MemberRemote(this, $"{sourceCoreInstanceId}.{nameof(RemoteCoreAlbum)}.{id}", RemoteCoreMessageHandler.SingletonClient); } /// /// Wraps around and remotely relays events, property changes and method calls (with return data) from an artist instance. /// /// The artist to wrap around for controlling remotely. internal RemoteCoreArtist(ICoreArtist coreArtist) { _artist = coreArtist; _name = coreArtist.Name; Id = coreArtist.Id; SourceCoreInstanceId = coreArtist.SourceCore.InstanceId; SourceCore = RemoteCore.GetInstance(SourceCoreInstanceId, RemotingMode.Host); _memberRemote = new MemberRemote(this, $"{coreArtist.SourceCore.InstanceId}.{nameof(RemoteCoreAlbum)}.{coreArtist.Id}", RemoteCoreMessageHandler.SingletonHost); } /// public ICore SourceCore { get; set; } /// /// The instance ID of the /// public string SourceCoreInstanceId { get; set; } /// public string Id { get; set; } /// public string Name { get => _name; set => _name = value; } /// public string? Description { get; set; } /// public DateTime? AddedAt { get; set; } /// public DateTime? LastPlayed { get; set; } /// public PlaybackState PlaybackState { get; set; } /// public TimeSpan Duration { get; set; } /// public bool IsChangeNameAsyncAvailable { get; set; } /// public bool IsChangeDescriptionAsyncAvailable { get; set; } /// public bool IsChangeDurationAsyncAvailable { get; set; } /// public int TotalImageCount { get; set; } /// public int TotalUrlCount { get; set; } /// public int TotalGenreCount { get; set; } /// public ICorePlayableCollectionGroup? RelatedItems { get; set; } /// public int TotalAlbumItemsCount { get; set; } /// public bool IsPlayAlbumCollectionAsyncAvailable { get; set; } /// public bool IsPauseAlbumCollectionAsyncAvailable { get; set; } /// public int TotalTrackCount { get; set; } /// public bool IsPlayTrackCollectionAsyncAvailable { get; set; } /// public bool IsPauseTrackCollectionAsyncAvailable { get; set; } /// public event CollectionChangedEventHandler? AlbumItemsChanged; /// public event EventHandler? IsPlayAlbumCollectionAsyncAvailableChanged; /// public event EventHandler? IsPauseAlbumCollectionAsyncAvailableChanged; /// public event EventHandler? AlbumItemsCountChanged; /// public event CollectionChangedEventHandler? TracksChanged; /// public event EventHandler? IsPlayTrackCollectionAsyncAvailableChanged; /// public event EventHandler? IsPauseTrackCollectionAsyncAvailableChanged; /// public event EventHandler? TracksCountChanged; /// public event EventHandler? PlaybackStateChanged; /// public event EventHandler? NameChanged; /// public event EventHandler? DescriptionChanged; /// public event EventHandler? DurationChanged; /// public event EventHandler? LastPlayedChanged; /// public event EventHandler? IsChangeNameAsyncAvailableChanged; /// public event EventHandler? IsChangeDescriptionAsyncAvailableChanged; /// public event EventHandler? IsChangeDurationAsyncAvailableChanged; /// public event CollectionChangedEventHandler? ImagesChanged; /// public event EventHandler? ImagesCountChanged; /// public event CollectionChangedEventHandler? UrlsChanged; /// public event EventHandler? UrlsCountChanged; /// public event CollectionChangedEventHandler? GenresChanged; /// public event EventHandler? GenresCountChanged; /// public Task AddAlbumItemAsync(ICoreAlbumCollectionItem album, int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task AddGenreAsync(ICoreGenre genre, int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task AddImageAsync(ICoreImage image, int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task AddTrackAsync(ICoreTrack track, int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task AddUrlAsync(ICoreUrl url, int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task ChangeDescriptionAsync(string? description, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task ChangeDurationAsync(TimeSpan duration, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task ChangeNameAsync(string name, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public IAsyncEnumerable GetAlbumItemsAsync(int limit, int offset, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public IAsyncEnumerable GetGenresAsync(int limit, int offset, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public IAsyncEnumerable GetImagesAsync(int limit, int offset, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public IAsyncEnumerable GetTracksAsync(int limit, int offset, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public IAsyncEnumerable GetUrlsAsync(int limit, int offset, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task IsAddAlbumItemAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task IsAddGenreAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task IsAddImageAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task IsAddTrackAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task IsAddUrlAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task IsRemoveAlbumItemAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task IsRemoveGenreAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task IsRemoveImageAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task IsRemoveTrackAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task IsRemoveUrlAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// A cancellation token that may be used to cancel the ongoing task. /// public Task PauseAlbumCollectionAsync(CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// A cancellation token that may be used to cancel the ongoing task. /// public Task PauseTrackCollectionAsync(CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task PlayAlbumCollectionAsync(ICoreAlbumCollectionItem albumItem, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// A cancellation token that may be used to cancel the ongoing task. /// public Task PlayAlbumCollectionAsync(CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task PlayTrackCollectionAsync(ICoreTrack track, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// A cancellation token that may be used to cancel the ongoing task. /// public Task PlayTrackCollectionAsync(CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task RemoveAlbumItemAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task RemoveGenreAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task RemoveImageAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task RemoveTrackAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task RemoveUrlAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public ValueTask DisposeAsync() => default; } }