// 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 OwlCore.AbstractUI.Models; using OwlCore.Events; using OwlCore.Provisos; using StrixMusic.Sdk.AppModels; using StrixMusic.Sdk.MediaPlayback; namespace StrixMusic.Sdk.CoreModels { /// /// An is a common API surface that can be implemented to allow interfacing with any arbitrary music provider. /// /// In a core's constructor, only do basic object initialization. For the rest, use . /// /// During , if the core state is changed to , this task will be canceled /// and the app will display your current to the user for configuration and setup. /// After the user has completed setup, change the core state back to using the AbstractUI elements. /// will fire again, at which point you can make sure you have the data you need to finish initialization. /// /// There is a 10 minute time limit for the user to complete setup. /// If it takes longer, the SDK will assume something has gone wrong and unload the core until the user manually initiates setup or restarts the app. /// /// public interface ICore : IAsyncInit, ICoreMember, IAsyncDisposable { /// /// The registered metadata for this core. Contains information to identify the core before creating an instance. /// public CoreMetadata Registration { get; } /// /// Identifies this instance of the core. This is given to each core via the constructor. /// public string InstanceId { get; } /// /// A string of text to display to the user to help identify which core instance this is, such as a username or the path to a file location. Longer strings will be truncated as needed. /// public string InstanceDescriptor { get; } /// /// Abstract UI elements that will be presented to the user for Settings, About, Legal notices, Donation links, etc. /// public AbstractUICollection AbstractConfigPanel { get; } /// /// The player type supported by this core. /// public MediaPlayerType PlaybackType { get; } /// /// The user that is authenticated with this core, if any. Only one user is supported per core. /// public ICoreUser? User { get; } /// /// The available devices. These should only be populated with remote devices, if supported by the core. /// Local playback is handled by the SDK by calling . /// public IReadOnlyList Devices { get; } /// /// Gets the library for the user on this core. This must never be null, but it may return 0 items if needed. /// public ICoreLibrary Library { get; } /// /// Pins act as "bookmarks" or "shortcuts", things that the user has chosen to "pin" somewhere for easy access. /// /// /// If this is left null, this will be managed by the app. If not, the core will be entirely responsible for managing this. /// public ICorePlayableCollectionGroup? Pins { get; } /// /// Contains various search-related data and activities. /// /// /// If this is left null, this will be managed by the app. If not, the core will be entirely responsible for managing this. /// public ICoreSearch? Search { get; } /// /// The items that the user has been recently played by the user. /// /// /// If this is left null, this will be managed by the app. If not, the core will be entirely responsible for managing this. /// public ICoreRecentlyPlayed? RecentlyPlayed { get; } /// /// Used to browse and discover new music. /// public ICoreDiscoverables? Discoverables { get; } /// /// The current state of the core. /// public CoreState CoreState { get; } /// /// Given the ID of an instance created by this core, return the fully constructed instance. /// /// The requested instance, cast down to . public Task GetContextByIdAsync(string id, CancellationToken cancellationToken = default); /// /// Converts a into a that can be used to play the track. /// /// The track to convert. /// A cancellation token that may be used to cancel the ongoing task. /// A representing the asynchronous operation. The value is an that can be used to play the track. public Task GetMediaSourceAsync(ICoreTrack track, CancellationToken cancellationToken = default); /// /// Raised when the has changed. /// public event EventHandler? CoreStateChanged; /// /// Raised when the contents of is changed. /// public event CollectionChangedEventHandler? DevicesChanged; /// /// Raised when is changed. /// public event EventHandler? AbstractConfigPanelChanged; /// /// Raised when is changed. /// public event EventHandler? InstanceDescriptorChanged; } }