예제 #1
0
파일: Program.cs 프로젝트: kelsos/plugin
        /// <summary>
        /// The main function of the the tester program.
        /// </summary>
        public static void Main()
        {
            var playerState = new MockPlayerState();
            var nowPlaying  = new MockNowPlaying();
            var player      = new MockPlayer(playerState, nowPlaying);
            var library     = new MockLibrary();

            var libraryApiAdapter    = new LibraryApiAdapter(library);
            var nowPlayingApiAdapter = new NowPlayingApiAdapter(nowPlaying, player);
            var outputApiAdapter     = new MockOutputApiAdapter();
            var playerApiAdapter     = new MockPlayerApiAdapter(playerState, player);
            var queueAdapter         = new QueueAdapter();
            var trackApiAdapter      = new TrackApiAdapter(player);
            var baseStoragePath      = Path.GetTempPath();

            var dependencies = new MusicBeeDependencies(
                libraryApiAdapter,
                nowPlayingApiAdapter,
                outputApiAdapter,
                playerApiAdapter,
                queueAdapter,
                trackApiAdapter,
                null,
                baseStoragePath,
                "1.0.0");

            var remoteBootstrap      = new RemoteBootstrap();
            var musicBeeRemotePlugin = remoteBootstrap.BootStrap(dependencies);

            musicBeeRemotePlugin.Start();

            while (true)
            {
                Console.WriteLine(Resources.Input);
                var line = Console.ReadLine();
                if (line != "q!")
                {
                    continue;
                }

                musicBeeRemotePlugin.Terminate();
                remoteBootstrap.Dispose();
                Console.WriteLine(Resources.Quitting);
                break;
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes the MusicBee Remote plugin.
        /// </summary>
        /// <param name="apiInterfacePtr">The API interface of MusicBee.</param>
        /// <returns>The plugin info.</returns>
        public PluginInfo Initialise(IntPtr apiInterfacePtr)
        {
            _api = default;
            _api.Initialise(apiInterfacePtr);

            _about.PluginInfoVersion = PluginInfoVersion;
            _about.Name              = "MusicBee Remote: Plugin";
            _about.Description       = "Remote Control for server to be used with android application.";
            _about.Author            = "Konstantinos Paparas (aka Kelsos)";
            _about.TargetApplication = "MusicBee Remote";

            var version        = Assembly.GetExecutingAssembly().GetName().Version;
            var currentVersion = version.ToString();

            // current only applies to artwork, lyrics or instant messenger name that appears in the provider drop down selector or target Instant Messenger
            _about.Type                 = PluginType.General;
            _about.VersionMajor         = Convert.ToInt16(version.Major);
            _about.VersionMinor         = Convert.ToInt16(version.Minor);
            _about.Revision             = Convert.ToInt16(version.Build);
            _about.MinInterfaceVersion  = MinInterfaceVersion;
            _about.MinApiRevision       = MinApiRevision;
            _about.ReceiveNotifications = ReceiveNotificationFlags.PlayerEvents;

            if (_api.ApiRevision < MinApiRevision)
            {
                return(_about);
            }

            // Initialize the required adapters for the plugin to operate.
            var libraryApiAdapter    = new LibraryApiAdapter(_api);
            var nowPlayingApiAdapter = new NowPlayingApiAdapter(_api);
            var outputApiAdapter     = new OutputApiAdapter(_api);
            var playerApiAdapter     = new PlayerApiAdapter(_api);
            var queueAdapter         = new QueueAdapter(_api);
            var trackApiAdapter      = new TrackApiAdapter(_api);
            var invokeHandler        = new InvokeHandler(_api);
            var baseStoragePath      = _api.Setting_GetPersistentStoragePath();

            var dependencies = new MusicBeeDependencies(
                libraryApiAdapter,
                nowPlayingApiAdapter,
                outputApiAdapter,
                playerApiAdapter,
                queueAdapter,
                trackApiAdapter,
                invokeHandler,
                baseStoragePath,
                currentVersion);

            _bootstrap            = new RemoteBootstrap();
            _musicBeeRemotePlugin = _bootstrap.BootStrap(dependencies);

            const string menuItemDescription = "Information Panel of the MusicBee Remote";

            _api.MB_AddMenuItem("mnuTools/MusicBee Remote: Settings", menuItemDescription, MenuItemClicked);

#if DEBUG
            // Experimental feature only supported on debug
            AddPartyMode();
#endif

            _musicBeeRemotePlugin.Start();

            return(_about);
        }