コード例 #1
0
        private static void NetworkWorker()
        {
            FacebookHelper.DeletePreviousPost(ref fbClient, post =>
            {
                var indicator = Properties.Settings.Default.FacebookFormat.IndexOf(" ");
                if (post.Message.Contains(Properties.Settings.Default.FacebookFormat.Substring(0, indicator)))
                {
                    fbClient.Delete(post.Id);
                }
            });
            dynamic param = new ExpandoObject();

            param.message = player.Music.PostFormat;
            param.link    = currentTrackUrl;
            fbClient.Post("me/feed", param);
        }
コード例 #2
0
 private static bool ConsoleEventCallback(int eventType)
 {
     if (eventType == 2 || eventType == 0) //2 is user perform exit, 0 is application interupt (^C)
     {
         MainEvent.Reset();
         Console.ForegroundColor = ConsoleColor.White;
         Console.BackgroundColor = ConsoleColor.Black;
         Console.Write("\n\n\nResources cleaning...");
         FacebookHelper.DeletePreviousPost(ref fbClient, post => { if (post.Message.Contains("Apple Music"))
                                                                   {
                                                                       fbClient.Delete(post.Id);
                                                                   }
                                           });
         Console.Clear();
         Environment.Exit(0);
     }
     return(false);
 }
コード例 #3
0
        public static void Main(string[] args)
        {
            var width = (100 + scale + 10) < 130 ? 100 + scale + 10 : 130;

            Console.SetWindowSize(width, 25);
            Console.ForegroundColor = ConsoleColor.Black;
            Console.BackgroundColor = ConsoleColor.White;
            player  = new PlayerInstance();
            handler = new EventHandler.ConsoleEventDelegate(ConsoleEventCallback);
            InitializeDiscod();
            try
            {
                FacebookHelper.RenewAccessToken();
            }
            catch
            {
                MessageBox.Show("Can't evaluate Facebook OAuth Token, please check your token in settings (S) or your network connection.", "iTunesListener", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            EventHandler.SetConsoleCtrlHandler(handler, true);
            Task.Run(delegate
            {
                while (true)
                {
                    ActiveDevice = new MMDeviceEnumerator().EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active).ToList().OrderByDescending(x => x.AudioMeterInformation.MasterPeakValue).FirstOrDefault();
                    Thread.Sleep(1000);
                }
            });
            Task.Run((Action)ActionListenerThread);
            Task.Run((Action)HeaderThread);
            if (Properties.Settings.Default.WebServiceListening)
            {
                Task.Run((Action)WebServiceListener);
            }
            if (Properties.Settings.Default.ChromaSDKEnable)
            {
                Task.Run((Action)ChromaUpdateAsync);
            }

            mainThread = new Thread(new ThreadStart(MainThread));
            mainThread.Start();
        }
コード例 #4
0
        private static void ActionListenerThread()
        {
            while (true)
            {
                var action = Console.ReadKey().Key;
                switch (action)
                {
                case ConsoleKey.LeftArrow:
                    player.PlayerEngine.PreviousTrack();
                    break;

                case ConsoleKey.RightArrow:
                    player.PlayerEngine.NextTrack();
                    break;

                case ConsoleKey.OemPlus:
                    player.PlayerEngine.SoundVolume += 10;
                    break;

                case ConsoleKey.OemMinus:
                    player.PlayerEngine.SoundVolume -= 10;
                    break;

                case ConsoleKey.Enter:
                case ConsoleKey.Spacebar:
                    player.PlayerEngine.PlayPause();
                    break;

                case ConsoleKey.UpArrow:
                    MainEvent.Reset();
                    ShowPlaylist();
                    break;

                case ConsoleKey.DownArrow:
                    if (!MainEvent.WaitOne(0))
                    {
                        Console.Clear();
                        Console.WriteLine(mainHeader);
                        for (var i = 0; i < playedList.Count - 1; i++)     //-2 to compensate index 0 and index n, as n track would always show on thread running
                        {
                            Console.WriteLine();
                            Console.Write(playedList.Get(i).ToString());
                        }
                        Console.WriteLine();
                        MainEvent.Set();
                    }
                    break;

                case ConsoleKey.H:
                    MainEvent.Reset();
                    ShowHelp();
                    break;

                case ConsoleKey.R:
                    //Process.Start("https://github.com/Desz01ate/iTunesListener");
                    var task = new Thread(NetworkWorker);
                    task.Start();
                    task.Join();
                    Process.Start(FacebookHelper.GetApplicationPost(ref fbClient).First().Permalink_url);
                    break;

                case ConsoleKey.O:
                    Process.Start(currentTrackUrl);
                    break;

                case ConsoleKey.S:
                    Application.EnableVisualStyles();
                    Application.Run(new Settings());
                    break;

                case ConsoleKey.Escape:
                    ConsoleEventCallback(2);
                    break;
                }
            }
        }