Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Globals.Initialize();
            YoutubeHelper.Initialize();
            CommandManager.Initialize();
            syncHandler = new SyncHandler();
            PacketManager.Initialize(syncHandler);

            using (server = new WebSocketServer(Globals.MyLocation))
            {
                try
                {
                    server.Start(ServerConfig);
                }
                catch (SocketException ex)
                {
                    if (ex.ErrorCode == 10048)
                    {
                        Console.WriteLine("Something is already running on this port. Can't start server.");
                        Environment.Exit(1);
                    }
                }

                while (true)
                {
                    Thread.Sleep(100);
                }
            }
        }
Exemplo n.º 2
0
        public void SendRoomPlaylist()
        {
            var room = Socket.GetInfo().GetRoom();

            if (room == null)
            {
                return;
            }

            foreach (var videoInfo in room.Playlist)
            {
                SendAddVideo(videoInfo, YoutubeHelper.GetTitle(videoInfo.VideoID),
                             YoutubeHelper.GetDuration(videoInfo.VideoID).ToString(),
                             YoutubeHelper.GetAuthor(videoInfo.VideoID),
                             YoutubeHelper.GetChannelImage(videoInfo.VideoID));
            }
        }
Exemplo n.º 3
0
        public void SendSetVideo(VideoInfo videoInfo, PlayState state, double elapsed = 0)
        {
            var info = Socket.GetInfo();

            string   videoName     = YoutubeHelper.GetTitle(videoInfo.VideoID);
            TimeSpan videoDuration = YoutubeHelper.GetDuration(videoInfo.VideoID);

            var title       = YoutubeHelper.GetTitle(videoInfo.VideoID);
            var description = YoutubeHelper.GetDescription(videoInfo.VideoID);

            Helper.SendQuick(Socket, new Dictionary <string, object>
            {
                { "intent", "setVideo" },
                { "uniqueId", videoInfo.ID },
                { "videoId", videoInfo.VideoID },
                { "videoName", videoName },
                { "title", title },
                { "description", description },
                { "duration", (int)videoDuration.TotalSeconds },
                { "elapsed", elapsed },
                { "state", (int)state },
            });
        }