Exemple #1
0
        // On change video state by client
        private void playerStateChanged(object sender, MPCControllerEventArgs e)
        {
            Info info = e.info;

            if (e.chnagedByUser)
            {
                Console.WriteLine("Changed by user, sending to server...");
                client.Set(Settings.Token, Settings.UUID, info.FileName, info.Position, info.Duration, info.State);
            }

            Application.Current.Dispatcher.Invoke(() =>
            {
                nameLabel.Content     = info.FileName.Length > 0 ? info.FileName : "Ready...";
                positionLabel.Content = $"{info.Position:hh\\:mm\\:ss}/{info.Duration:hh\\:mm\\:ss}";
                statusLabel.Content   = info.State;
            });
        }
Exemple #2
0
        private async Task RunUpdateTask(TimeSpan interval, CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested)
            {
                Console.WriteLine("[MPC] RunUpdateTask GetInfo()");
                var task = await player.GetInfo();

                // Send event
                if (!IsInfoEqual(previousInfo, task))
                {
                    EventHandler <MPCControllerEventArgs> handler = stateChanged;
                    if (handler != null)
                    {
                        MPCControllerEventArgs args = new MPCControllerEventArgs();
                        args.info          = task;
                        args.chnagedByUser = IsChangedByUser(previousInfo, task, updateInterval);
                        handler(this, args);
                    }
                }
                previousInfo = task;
                await Task.Delay(interval, cancellationToken);
            }
        }