Example #1
0
 // While BRB playback is active, update all displays concerning the break or the currently playing BRB
 private void tmrUpdateBRBPlaybackData_Tick(object sender, EventArgs e)
 {
     if (Program.PlayerForm.PlayerState == BRBPlayerState.Playback)
     {
         TimeSpan playbackPosition = new TimeSpan((long)(Program.PlayerForm.VLCPlayer.Position * Program.PlayerForm.VLCPlayer.Length * TimeSpan.TicksPerMillisecond));
         dispRunningTime.Text = BRBManager.TimeSpanToMMSS(playbackPosition) + " / " + durationOfCurrentBRBFormatted;
         if (!Program.PlayerForm.Paused)
         {
             trkScrubber.Value = Math.Min(Math.Max((int)(playbackPosition.TotalSeconds * 30), trkScrubber.Minimum), trkScrubber.Maximum);
         }
     }
     if (Program.PlayerForm.PlayerState != BRBPlayerState.ErrorOccurred)
     {
         TimeSpan remainingBreakTime = Program.PlayerForm.GetRemainingBreakTime();
         dispRemainingBreakTime.Text = BRBManager.TimeSpanToMMSS(remainingBreakTime);
         if (remainingBreakTime.TotalSeconds < 120)
         {
             dispRemainingBreakTime.ForeColor = Color.Red;
         }
         else
         {
             dispRemainingBreakTime.ForeColor = SystemColors.ControlText;
         }
     }
 }
        // BRB Data means the information the user can change on the right hand side of the form
        private void UpdateBRBData()
        {
            if (selectedBRB == null)
            {
                btnOpenBRB.Enabled          = false;
                btnReplaceBRB.Enabled       = false;
                btnRenameBRB.Enabled        = false;
                btnEditAutoMuteData.Enabled = false;

                chkFavourite.Checked      = false;
                txtDuration.Text          = "";
                txtTitle.Text             = "";
                txtAuthors.Text           = "";
                txtDescription.Text       = "";
                numGuaranteedPlays.Value  = 0;
                numPriorityPlays.Value    = 0;
                txtPlaybackData.Text      = "";
                chkEnableAutoMute.Checked = false;
            }
            else
            {
                btnOpenBRB.Enabled          = BRBManager.AvailableBRBEpisodes.Contains(selectedBRB);
                btnReplaceBRB.Enabled       = true;
                btnRenameBRB.Enabled        = true;
                btnEditAutoMuteData.Enabled = true;

                chkFavourite.Checked      = selectedBRB.Favourite;
                txtDuration.Text          = BRBManager.TimeSpanToMMSS(selectedBRB.Duration);
                txtTitle.Text             = selectedBRB.Title;
                txtAuthors.Text           = selectedBRB.Credits;
                txtDescription.Text       = selectedBRB.Description;
                numGuaranteedPlays.Value  = selectedBRB.GuaranteedPlays;
                numPriorityPlays.Value    = selectedBRB.PriorityPlays;
                chkEnableAutoMute.Enabled = (selectedBRB.AutoMutes.Count > 0);
                chkEnableAutoMute.Checked = (selectedBRB.AutoMutes.Count > 0) && selectedBRB.AutoMuteEnabled;

                txtPlaybackData.Text = "Last played in " + selectedBRB.LatestPlaybackChapter + " – Played " + selectedBRB.RecentPlaybacks + " time" + (selectedBRB.RecentPlaybacks != 1 ? "s" : "") +
                                       " since " + (Config.Chapter - Config.ChapterHistoryConsidered) + " – Urgency score " + selectedBRB.GetUrgencyScore() + "\r\n";
                if (selectedBRB.PlaybackChapters.Count == 0)
                {
                    txtPlaybackData.Text += "No playbacks on file.";
                }
                else
                {
                    txtPlaybackData.Text += "All playbacks: [" + selectedBRB.PlaybackChapters[0];
                    for (int i = 1; i < selectedBRB.PlaybackChapters.Count; i++)
                    {
                        txtPlaybackData.Text += ", " + selectedBRB.PlaybackChapters[i];
                    }
                    txtPlaybackData.Text += "]";
                }
            }
        }
Example #3
0
        // Called every time the playlist is updated
        private void UpdateBRBPlaylistRunningTime()
        {
            TimeSpan runningTime = new TimeSpan(0);

            foreach (ListViewItem playlistItem in lstBRBPlaylist.Items)
            {
                BRBEpisode ep = BRBManager.GetEpisode(playlistItem.Text);
                if (ep != null)
                {
                    runningTime += new TimeSpan(Config.InterBRBCountdown * TimeSpan.TicksPerSecond);
                    runningTime += ep.Duration;
                }
            }
            // The end screen is not counted here, since it happens after the last actual "playback"

            dispTotalBRBRunningTime.Text = BRBManager.TimeSpanToMMSS(runningTime);
        }
Example #4
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            lstBRBPlaylist.Items.Clear();
            UpdateBRBPlaylistRunningTime();

            if (numMinutes.Value <= 0)
            {
                MessageBox.Show("The target running time should be positive.", "Cannot generate playlist", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            long     targetDurationTicks = (int)numMinutes.Value * TimeSpan.TicksPerMinute;
            TimeSpan targetDuration      = new TimeSpan(targetDurationTicks);
            TimeSpan minDuration         = new TimeSpan(targetDurationTicks / 100 * (100 - Config.PermittedUndertimePercent));
            TimeSpan maxDuration         = new TimeSpan(targetDurationTicks + Config.PermittedOvertimeMinutes * TimeSpan.TicksPerMinute + TimeSpan.TicksPerMinute / 2);

            List <string> addReason = new List <string>();

            List <BRBEpisode> playlist = BRBManager.GeneratePlaylist(minDuration, targetDuration, maxDuration, ref addReason);

            if (playlist == null)
            {
                MessageBox.Show("The playlist generator failed to compile a BRB playlist with the given restrictions.\r\n\r\n"
                                + "You can try the following steps:\r\n"
                                + "– Try generating a playlist again. If there are only few possible options, the generator can sometimes manoeuvre itself into a dead end.\r\n"
                                + "– Change the target running time of your break‌.\r\n"
                                + "– Configure permitted over- and undertime to be more lenient.\r\n"
                                + "– If you have many BRB episodes marked as \"Guaranteed\", unmark some of them.", "Not enough BRB episodes", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            BRBEpisode ep;

            for (int i = 0; i < playlist.Count; i++)
            {
                ep = playlist[i];
                ListViewItem item = new ListViewItem(new string[] { ep.Filename, BRBManager.TimeSpanToMMSS(ep.Duration), ep.GetWeight().ToString(), addReason[i] });
                lstBRBPlaylist.Items.Add(item);
            }

            UpdateBRBPlaylistRunningTime();
        }
Example #5
0
        public void OnBRBPlayerStateChanged()
        {
            // Update displays

            BRBEpisode episode;

            switch (Program.PlayerForm.PlayerState)
            {
            case BRBPlayerState.BeginningOfBreak:
            case BRBPlayerState.InBetweenBRBs:
            case BRBPlayerState.HobbVLC:
                for (int i = 0; i < Program.PlayerForm.NextOrCurrentBRBIndex; i++)
                {
                    lstBRBPlaylist.Items[i].ForeColor = Color.DarkGray;
                    lstBRBPlaylist.Items[i].Font      = new Font(lstBRBPlaylist.Items[i].Font, FontStyle‌.Regular);
                }
                lstBRBPlaylist.Items[Program.PlayerForm.NextOrCurrentBRBIndex].Font      = new Font(lstBRBPlaylist.Items[Program.PlayerForm.NextOrCurrentBRBIndex].Font, FontStyle‌.Bold);
                lstBRBPlaylist.Items[Program.PlayerForm.NextOrCurrentBRBIndex].ForeColor = SystemColors.ControlText;
                for (int i = Program.PlayerForm.NextOrCurrentBRBIndex + 1; i < lstBRBPlaylist.Items.Count; i++)
                {
                    lstBRBPlaylist.Items[i].ForeColor = SystemColors.ControlText;
                    lstBRBPlaylist.Items[i].Font      = new Font(lstBRBPlaylist.Items[i].Font, FontStyle‌.Regular);
                }

                episode = Program.PlayerForm.NextOrCurrentBRB;
                dispPlayerStatus.Text         = "Next up:";
                dispPlayingOrNextUp.Text      = episode.Filename;
                durationOfCurrentBRBFormatted = BRBManager.TimeSpanToMMSS(episode.Duration);
                dispRunningTime.Text          = "00:00 / " + durationOfCurrentBRBFormatted;
                trkScrubber.Maximum           = (int)(episode.Duration.TotalSeconds * 30); // The scrubber shall be based on 1/30 seconds internally
                trkScrubber.Value             = 0;
                trkScrubber.Enabled           = false;
                break;

            case BRBPlayerState.Playback:     // Always occurs after one of the above three states, so not much is to be done
                Program.PlayerForm.SetVolume(trkVolume.Value);
                Program.PlayerForm.SetMuted(chkMuted.Checked);

                dispPlayerStatus.Text = "Now playing:";
                trkScrubber.Enabled   = true;
                break;

            case BRBPlayerState.EndOfBreak:
                for (int i = 0; i < lstBRBPlaylist.Items.Count; i++)
                {
                    lstBRBPlaylist.Items[i].ForeColor = Color.DarkGray;
                    lstBRBPlaylist.Items[i].Font      = new Font(lstBRBPlaylist.Items[i].Font, FontStyle‌.Regular);
                }

                dispPlayerStatus.Text    = "Finished. Waiting for user...";
                dispPlayingOrNextUp.Text = "";
                dispRunningTime.Text     = "00:00 / 00:00";
                trkScrubber.Value        = 0;
                trkScrubber.Enabled      = false;
                break;

            case BRBPlayerState.ErrorOccurred:
                // Disable pretty much everything aside from "Abort BRB playback"; it is likely the occurring error requires fixing something, so continuing the playback wouldn't make sense
                btnPlayPause.Enabled   = false;
                btnReplayBRB.Enabled   = false;
                btnPreviousBRB.Enabled = false;
                btnNextBRB.Enabled     = false;
                trkVolume.Enabled      = false;
                chkMuted.Enabled       = false;
                txtVolume.Enabled      = false;
                trkScrubber.Enabled    = false;
                // Stop timers
                tmrEnsureCursorVisibility.Enabled = false;
                tmrUpdateBRBPlaybackData.Enabled  = false;
                break;
            }
        }
Example #6
0
        public bool AppendHobbVLCEpisode()
        {
            BRBEpisode episode = BRBManager.GetRandomBRBEpisode(Config.HobbVLCIgnoreMaxDurationAfterTries == -1 || Program.PlayerForm.HobbVLCsTriggered < Config.HobbVLCIgnoreMaxDurationAfterTries ?
                                                                new TimeSpan(Config.HobbVLCMaxDuration * TimeSpan.TicksPerMinute + TimeSpan.TicksPerMinute / 2) : (TimeSpan?)null,
                                                                true, Program.PlayerForm.BRBPlaylist);

            if (episode == null)
            {
                episode = BRBManager.GetRandomBRBEpisode(Config.HobbVLCIgnoreMaxDurationAfterTries == -1 || Program.PlayerForm.HobbVLCsTriggered < Config.HobbVLCIgnoreMaxDurationAfterTries ?
                                                         new TimeSpan(Config.HobbVLCMaxDuration * TimeSpan.TicksPerMinute + TimeSpan.TicksPerMinute / 2) : (TimeSpan?)null,
                                                         false, Program.PlayerForm.BRBPlaylist);
            }
            if (episode == null)
            {
                episode = BRBManager.GetRandomBRBEpisode(Config.HobbVLCIgnoreMaxDurationAfterTries == -1 || Program.PlayerForm.HobbVLCsTriggered < Config.HobbVLCIgnoreMaxDurationAfterTries ?
                                                         new TimeSpan(Config.HobbVLCMaxDuration * TimeSpan.TicksPerMinute + TimeSpan.TicksPerMinute / 2) : (TimeSpan?)null,
                                                         false);
            }

            if (episode != null)
            {
                ListViewItem item = new ListViewItem(new string[] { episode.Filename, BRBManager.TimeSpanToMMSS(episode.Duration),
                                                                    episode.GetWeight().ToString(), "hobbVLC" });
                lstBRBPlaylist.Items.Add(item);
                UpdateBRBPlaylistRunningTime();
                Program.PlayerForm.AppendBRB(episode);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #7
0
        public void UpdateBRBData()
        {
            lstAllBRBs.BeginUpdate();
            lstAllBRBs.Items.Clear();

            List <ListViewItem> newItems = new List <ListViewItem>(BRBManager.AvailableBRBEpisodes.Count);

            foreach (BRBEpisode episode in BRBManager.AvailableBRBEpisodes)
            {
                if (txtSearch.Text == "" || episode.ContainsTextAtField(txtSearch.Text, drpSearchWhere.SelectedIndex))
                {
                    int          weight = episode.GetWeight();
                    ListViewItem item   = new ListViewItem(new string[] { episode.Favourite ? "\u2605" : "", episode.Filename, BRBManager.TimeSpanToMMSS(episode.Duration), episode.Description,
                                                                          episode.LatestPlaybackChapter.ToString(), weight.ToString(), episode.PriorityChar.ToString() });
                    item.UseItemStyleForSubItems = false;
                    item.SubItems[0].Font        = new Font(item.SubItems[0].Font, FontStyle.Bold);
                    item.SubItems[0].ForeColor   = Color.Gold;
                    item.SubItems[5].Font        = new Font(item.SubItems[5].Font, FontStyle.Bold);
                    item.SubItems[5].ForeColor   = weight <= 4 ? Color.DarkGreen : (weight <= 9 ? Color.Orange : Color.Red);
                    if (item.SubItems[6].Text != "N")
                    {
                        item.SubItems[6].Font = new Font(item.SubItems[6].Font, FontStyle.Bold);
                    }
                    newItems.Add(item);
                }
            }

            lstAllBRBs.Items.AddRange(newItems.ToArray());

            // Clearing sorter every time is supposed to improve performance
            lstAllBRBs.ListViewItemSorter = new BRBListComparer(currentBRBListSortColumn, currentBRBListSortInverted);
            lstAllBRBs.Sort();
            lstAllBRBs.ListViewItemSorter = null;

            lstAllBRBs.EndUpdate();

            if (txtSearch.Text == "")
            {
                lblAvailableBRBs.Text = "Available BRBs (" + BRBManager.AvailableBRBEpisodes.Count + "):";
            }
            else
            {
                lblAvailableBRBs.Text = "Available BRBs (filtered, " + lstAllBRBs.Items.Count + " / " + BRBManager.AvailableBRBEpisodes.Count + "):";
            }
        }
Example #8
0
        public FormAutoMuteData(BRBEpisode episode)
        {
            InitializeComponent();

            this.episode = episode;
            this.Text    = "Displaying AutoMute Data of " + episode.Filename;

            if (episode.AutoMutes.Count == 0)
            {
                txtBegin.Text = "";
                txtEnd.Text   = "";
                txtInfo.Text  = "";
            }
            else
            {
                foreach (BRBEpisode.AutoMuteSpan span in episode.AutoMutes)
                {
                    drpAutoMuteTrigger.Items.Add((!span.Enabled ? "[Disabled] " : "") + BRBManager.TimeSpanToMMSS(span.Begin) + " \u2013 " + BRBManager.TimeSpanToMMSS(span.End) + " / " + span.Info);
                }

                drpAutoMuteTrigger.SelectedIndex = 0;

                UpdateAutoMuteData();
            }
        }