// 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.Globalization; using System.Threading; using System.Threading.Tasks; using OwlCore.Events; using OwlCore.Remoting; using StrixMusic.Sdk.AppModels; 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 RemoteCoreTrack : ICoreTrack { private readonly MemberRemote _memberRemote; private readonly ICoreTrack? _track; /// /// 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. internal RemoteCoreTrack(string sourceCoreInstanceId, string name, string id) { Name = name; Id = id; // 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(RemoteCoreTrack)}.{id}", RemoteCoreMessageHandler.SingletonClient); } /// /// Wraps around and remotely relays events, property changes and method calls (with return data) from an track instance. /// /// internal RemoteCoreTrack(ICoreTrack coreTrack) { _track = coreTrack; Name = coreTrack.Name; Id = coreTrack.Id; SourceCore = RemoteCore.GetInstance(coreTrack.SourceCore.InstanceId, RemotingMode.Host); _memberRemote = new MemberRemote(this, $"{coreTrack.SourceCore.InstanceId}.{nameof(RemoteCoreTrack)}.{coreTrack.Id}", RemoteCoreMessageHandler.SingletonHost); } /// public event EventHandler? AlbumChanged; /// public event EventHandler? LyricsChanged; /// public event EventHandler? TrackNumberChanged; /// public event EventHandler? LanguageChanged; /// public event EventHandler? IsExplicitChanged; /// public event CollectionChangedEventHandler? ArtistItemsChanged; /// public event EventHandler? IsPlayArtistCollectionAsyncAvailableChanged; /// public event EventHandler? IsPauseArtistCollectionAsyncAvailableChanged; /// public event EventHandler? ArtistItemsCountChanged; /// public event CollectionChangedEventHandler? ImagesChanged; /// public event CollectionChangedEventHandler? UrlsChanged; /// 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 EventHandler? ImagesCountChanged; /// public event EventHandler? UrlsCountChanged; /// public event CollectionChangedEventHandler? GenresChanged; /// public event EventHandler? GenresCountChanged; /// public ICore SourceCore { get; set; } /// public string Id { get; set; } /// public string Name { get; set; } /// public string? Description { get; set; } /// public DateTime? LastPlayed { get; set; } /// public PlaybackState PlaybackState { get; set; } /// public TimeSpan Duration { get; set; } /// public ICoreAlbum? Album { get; set; } /// public ICoreLyrics? Lyrics { get; set; } /// public ICorePlayableCollectionGroup? RelatedItems { get; set; } /// public TrackType Type { get; set; } /// public int? TrackNumber { get; set; } /// public int? DiscNumber { get; set; } /// public CultureInfo? Language { get; set; } /// public bool IsExplicit { get; set; } /// public bool IsChangeAlbumAsyncAvailable { get; set; } /// public bool IsChangeTrackNumberAsyncAvailable { get; set; } /// public bool IsChangeLanguageAsyncAvailable { get; set; } /// public bool IsChangeLyricsAsyncAvailable { get; set; } /// public bool IsChangeIsExplicitAsyncAvailable { get; set; } /// public int TotalArtistItemsCount { get; set; } /// public bool IsPlayArtistCollectionAsyncAvailable { get; set; } /// public bool IsPauseArtistCollectionAsyncAvailable { get; set; } /// public DateTime? AddedAt { 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 Task ChangeLyricsAsync(ICoreLyrics? lyrics, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task ChangeAlbumAsync(ICoreAlbum? albums, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task ChangeTrackNumberAsync(int? trackNumber, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task ChangeLanguageAsync(CultureInfo language, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task ChangeIsExplicitAsync(bool isExplicit, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task PlayArtistCollectionAsync(ICoreArtistCollectionItem artistItem, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public IAsyncEnumerable GetArtistItemsAsync(int limit, int offset, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task AddArtistItemAsync(ICoreArtistCollectionItem artist, int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// A cancellation token that may be used to cancel the ongoing task. /// public Task PlayArtistCollectionAsync(CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// A cancellation token that may be used to cancel the ongoing task. /// public Task PauseArtistCollectionAsync(CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task RemoveArtistItemAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task IsAddArtistItemAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task IsRemoveArtistItemAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public IAsyncEnumerable GetImagesAsync(int limit, int offset, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task AddImageAsync(ICoreImage image, int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public IAsyncEnumerable GetUrlsAsync(int limit, int offset, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task AddUrlAsync(ICoreUrl url, int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task ChangeNameAsync(string name, 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 IsAddImageAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task IsRemoveImageAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task RemoveImageAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task RemoveUrlAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task IsAddUrlAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task IsRemoveUrlAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public IAsyncEnumerable GetGenresAsync(int limit, int offset, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task AddGenreAsync(ICoreGenre genre, int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task RemoveGenreAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task IsAddGenreAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public Task IsRemoveGenreAvailableAsync(int index, CancellationToken cancellationToken = default) { throw new NotImplementedException(); } /// public ValueTask DisposeAsync() => default; } }