/
/
/
1"""
2DEMO/TEST/DUMMY/TEMPLATE Player Provider for Music Assistant.
3
4This is an empty player provider with a test/demo implementation.
5Its meant to get started developing a new player provider for Music Assistant.
6
7Use it as a reference to discover what methods exists and what they should return.
8Also it is good to look at existing player providers to get a better understanding,
9due to the fact that providers may be flexible and support different features and/or
10ways to discover players on the network.
11
12In general, the actual device communication should reside in a separate library.
13You can then reference your library in the manifest in the requirements section,
14which is a list of (versioned!) python modules (pip syntax) that should be installed
15when the provider is selected by the user.
16
17To add a new player provider to Music Assistant, you need to create a new folder
18in the providers folder with the name of your provider (e.g. 'my_player_provider').
19In that folder you should create (at least) a __init__.py file and a manifest.json file.
20
21Optional is an icon.svg file that will be used as the icon for the provider in the UI,
22but we also support that you specify a material design icon in the manifest.json file.
23
24IMPORTANT NOTE:
25We strongly recommend developing on either macOS or Linux and start your development
26environment by running the setup.sh scripts in the scripts folder of the repository.
27This will create a virtual environment and install all dependencies needed for development.
28
29For all development instructions, please refer to the developer documentation:
30https://developers.music-assistant.io
31"""
32
33from __future__ import annotations
34
35from typing import TYPE_CHECKING
36
37from music_assistant_models.enums import ProviderFeature
38
39from .provider import DemoPlayerprovider
40
41if TYPE_CHECKING:
42 from music_assistant_models.config_entries import ProviderConfig
43 from music_assistant_models.provider import ProviderManifest
44
45 from music_assistant.mass import MusicAssistant
46 from music_assistant.models import ProviderInstanceType
47
48SUPPORTED_FEATURES = {
49 # MANDATORY
50 # this constant should contain a set of provider-level features
51 # that your provider supports or an empty set if none.
52 # see the ProviderFeature enum for all available features
53 ProviderFeature.SYNC_PLAYERS,
54}
55
56
57async def setup(
58 mass: MusicAssistant, manifest: ProviderManifest, config: ProviderConfig
59) -> ProviderInstanceType:
60 """Initialize provider(instance) with given configuration."""
61 # setup is called when the user wants to setup a new provider instance.
62 # you are free to do any preflight checks here and but you must return
63 # an instance of your provider.
64 return DemoPlayerprovider(mass, manifest, config, SUPPORTED_FEATURES)
65