Esempio n. 1
0
        private void bgwGetURI_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            string           uri    = e.Argument.ToString();

            if (worker.CancellationPending)
            {
                Logger.Info("Cancelling work.");
                return;
            }

            MediaKlikk mediaKlikk = new MediaKlikk();

            try
            {
                Uri url = new Uri(mediaKlikk.GetChannelURI(currentChannel));

                if (worker.CancellationPending)
                {
                    Logger.Info("Cancelling work.");
                    return;
                }
                Logger.Info(string.Format("URI={0}", url));

                e.Result = url;
            }
            catch (Exception ex)
            {
                Logger.Warning(String.Format("Unable to play stream, {0}. {1}", uri, ex.Message));
                Logger.Error(ex);
            }
        }
Esempio n. 2
0
        private void ScheduleRecordingForm_Load(object sender, EventArgs e)
        {
            MediaKlikk    mediaKlikk    = new MediaKlikk();
            BindingSource bindingSource = new BindingSource();

            bindingSource.DataSource  = mediaKlikk.GetChannelNames();;
            this.cbChannel.DataSource = bindingSource.DataSource;
        }
Esempio n. 3
0
        private void bgwTVGuide_DoWork(object sender, DoWorkEventArgs e)
        {
            MediaKlikk mediaKlikk = new MediaKlikk();
            Dictionary <string, Channel> channels = mediaKlikk.GetChannels();

            TVGuide tVGuide = new TVGuide();

            tVGuide.Initialize(channels);
        }
Esempio n. 4
0
        private void VideoPlayerForm_Load(object sender, EventArgs e)
        {
            // Center control buttons
            this.flowLayoutPanel1.Location = new System.Drawing.Point((this.mediaPlayer.Width / 2) - (this.flowLayoutPanel1.Width / 2) + 12, this.mediaPlayer.Bottom + 6);

            // Get channels
            MediaKlikk mediaKlikk = new MediaKlikk();

            channels             = mediaKlikk.GetChannels();
            currentChannel       = channels["M1"];
            currentChannelButton = btM1;
        }
Esempio n. 5
0
        private void bgwRecording_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker backgroundWorker = sender as BackgroundWorker;
            Channel          channel          = (Channel)e.Argument;
            VideoMetadata    videoMetadata    = new VideoMetadata();

            try
            {
                // Check if current channel is playing before trying to record
                if (currentChannel.IsPlaying)
                {
                    var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
                    var libDirectory     = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));
                    var destinationDir   = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyVideos), "MagyarTV");
                    if (!File.Exists(destinationDir))
                    {
                        try
                        {
                            Directory.CreateDirectory(destinationDir);
                        }
                        catch (Exception ex)
                        {
                            Logger.Error(ex);
                        }
                    }
                    var destination = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyVideos), "MagyarTV", channel.StreamInfo.Title + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".ts");
                    /// New definition of mediaPlayer
                    using (var mediaRecorder = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory))
                    {
                        var mediaOptions = new[]
                        {
                            ":sout=#file{dst=" + destination + "}",
                            ":sout-keep"
                        };
                        currentChannel.IsRecording = true;
                        MediaKlikk mediaKlikk = new MediaKlikk();
                        mediaRecorder.SetMedia(new Uri(mediaKlikk.GetChannelURI(currentChannel)), mediaOptions);
                        btRecord.ForeColor = Color.Red;
                        mediaRecorder.Play();
                        currentRecording.Channel = channel;
                        Logger.Info(String.Format("Recording channel {0} to {1}.", currentChannel.Name, destination));
                        if (backgroundWorker != null)
                        {
                            while (!backgroundWorker.CancellationPending)
                            {
                                // Update
                            }
                            if (backgroundWorker.CancellationPending)
                            {
                                Logger.Info(String.Format("Cancelled recording channel {0}.", currentChannel.Name));
                                btRecord.ForeColor = Color.Black;
                                e.Cancel           = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Failed to start recording");
                Logger.Error(ex);
                MessageBox.Show(String.Format("Failed to start recording. {0}", ex.Message));
            }
        }