コード例 #1
0
        public SpotifireServer(string password = null)
        {
            if (Instance != null)
            {
                throw new InvalidOperationException("Can't have 2 servers!");
            }
            Instance = this;

            this.password = password;
            this.spotify  = Spotify.CreateSession(Program.applicationKey, Program.cacheLocation, Program.settingsLocation, Program.userAgent);
            this.spotify.SetPrefferedBitrate(sp_bitrate.BITRATE_320k);

            this.spotify.LoginComplete  += new SessionEventHandler(spotify_LoginComplete);
            this.spotify.LogoutComplete += new SessionEventHandler(spotify_LogoutComplete);
            this.spotify.MusicDeliver   += new MusicDeliveryEventHandler(spotify_MusicDeliver);
            this.spotify.EndOfTrack     += new SessionEventHandler(spotify_EndOfTrack);

            this.spotify.StartPlayback += new SessionEventHandler(spotify_StartPlayback);
            this.spotify.StopPlayback  += new SessionEventHandler(spotify_StopPlayback);

            this.playQueue = new LiveQueue <ITrack>();

            this.messageQueue  = new Queue <ClientAction>();
            this.messageLock   = new AutoResetEvent(false);
            this.messageThread = new Thread(new ThreadStart(MessageThread));
            this.messageThread.IsBackground = true;
            this.messageThread.Start();

            player = new BASSPlayer();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            cacheLocation = settingsLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SpotiFire", "libspotify");
            try
            {
                if (!Directory.Exists(cacheLocation))
                {
                    Directory.CreateDirectory(cacheLocation);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            string password;

            Console.Write("Password []: ");
            password = ReadPassword();
            SpotifireServer server = new SpotifireServer(password);


            Uri baseAddress         = new Uri("net.tcp://localhost:8080/spotifire");
            Uri baseMetadataAddress = new Uri("http://localhost:8081/spotifire/metadata");

            // Create service host
            using (ServiceHost host = new ServiceHost(server, new Uri[] { baseAddress, baseMetadataAddress }))
            {
                // Add Service Endpoint
                host.AddServiceEndpoint(typeof(ISpotifireServer), new NetTcpContextBinding(SecurityMode.Transport, true), baseAddress);

#if DEBUG
                // Enable metadata exchange
                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                smb.HttpGetUrl     = baseMetadataAddress;
                host.Description.Behaviors.Add(smb);
#endif



                // Open the ServiceHost to start listening for messages. Since
                // no endpoints are explicitly configured, the runtime will create
                // one endpoint per base address for each service contract implemented
                // by the service.
                host.Open();

                Console.WriteLine("The service is ready at {0}", baseAddress);
                server.Run();

                // Close the ServiceHost.
                host.Close();
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: thematlin/SpotiFire
        static void Main(string[] args)
        {
            cacheLocation = settingsLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SpotiFire", "libspotify");
            try
            {
                if (!Directory.Exists(cacheLocation))
                    Directory.CreateDirectory(cacheLocation);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            string password;
            Console.Write("Password []: ");
            password = ReadPassword();
            SpotifireServer server = new SpotifireServer(password);

            Uri baseAddress = new Uri("net.tcp://localhost:8080/spotifire");
            Uri baseMetadataAddress = new Uri("http://localhost:8081/spotifire/metadata");

            // Create service host
            using (ServiceHost host = new ServiceHost(server, new Uri[] { baseAddress, baseMetadataAddress }))
            {
                // Add Service Endpoint
                host.AddServiceEndpoint(typeof(ISpotifireServer), new NetTcpContextBinding(SecurityMode.Transport, true), baseAddress);

            #if DEBUG
                // Enable metadata exchange
                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                smb.HttpGetUrl = baseMetadataAddress;
                host.Description.Behaviors.Add(smb);
            #endif

                // Open the ServiceHost to start listening for messages. Since
                // no endpoints are explicitly configured, the runtime will create
                // one endpoint per base address for each service contract implemented
                // by the service.
                host.Open();

                Console.WriteLine("The service is ready at {0}", baseAddress);
                server.Run();

                // Close the ServiceHost.
                host.Close();
            }
        }
コード例 #4
0
 static SpotifireServer()
 {
     Instance = null;
 }