Esempio n. 1
0
        private void sendCommandToPlayout(PlayerCommand commandToSend, Playlist playlist = null)
        {
            try
            {
                PlayoutOutgoingCommand = commandToSend.TemplateData;

                if (playlist == null)
                {
                    _playlistCommands.Add(commandToSend.CommandID, 0);
                }
                else
                {
                    _playlistCommands.Add(commandToSend.CommandID, playlist.PlaylistID);
                }

                _lastCommandID = commandToSend.CommandID;

                _compTalker.Talk(commandToSend);
            }
            catch (Exception ex)
            { }
        }
Esempio n. 2
0
 private void playlistAdded(Playlist playlist, System.Timers.Timer timer)
 {
     if (_playlistTimerRunning)
     {
         timer.Interval = 100;
         timer.Start();
     }
 }
Esempio n. 3
0
        public static ObservableCollection<Playlist> GetPlaylists()
        {
            ObservableCollection<Playlist> playlists = new ObservableCollection<Playlist>();

            MySqlConnection cn = null;
            MySqlCommand cmd = null;
            MySqlDataReader rdr = null;
            DataTable tbl = null;

            try
            {
                cn = createConnectionMySql();

                String sql = "select * from playlists where playlisttype = '" + ConfigurationManager.AppSettings["DraftType"].ToString() + "' order by playlistname asc";

                cmd = new MySqlCommand(sql, cn);
                rdr = cmd.ExecuteReader();

                tbl = new DataTable();

                tbl.Load(rdr);

                rdr.Close();
                rdr.Dispose();

                Playlist playlist;

                foreach (DataRow row in tbl.Rows)
                {
                    playlist = new Playlist();

                    playlist.PlaylistID = Convert.ToInt16(row["playlistid"].ToString());
                    playlist.PlaylistName = row["playlistname"].ToString();

                    playlists.Add(playlist);
                }
            }
            finally
            {
                if (cmd != null) cmd.Dispose();
                if (tbl != null) tbl.Dispose();
                if (cn != null) cn.Close(); cn.Dispose();
            }

            return playlists;
        }
Esempio n. 4
0
        protected void OnSendCommand(PlayerCommand command, Playlist playlist)
        {
            SendCommandEventHandler handler = SendCommandEvent;

            if (handler != null)
            {
                handler(command, playlist);
            }
        }
        private void nextPlaylistItem(Playlist playlist, bool forceRestart = false)
        {
            PlaylistItem playlistItem = null;

            try
            {
                if (playlist.TimerRunning == true || forceRestart) //MJF
                {
                    if (playlist.CurrentPlaylistItem >= playlist.PlaylistItems.Count)
                    {
                        playlist.CurrentPlaylistItem = 0;
                    }

                    playlistItem = playlist.PlaylistItems[playlist.CurrentPlaylistItem];

                    playlistItem.OnAir = false;

                    if (playlistItem.Enabled == false)
                    {
                        playlist.CurrentPlaylistItem += 1;
                        nextPlaylistItem(playlist);
                    }
                    else
                    {
                        playlistItem.XmlDataRows = DbConnection.GetPlaylistItemData(playlistItem);

                        if (playlistItem.XmlDataRows != null)
                        {
                            if (playlistItem.XmlDataRows.Count > 0) //check to see if there are any rows in this playlist item to show
                            {
                                if (playlistItem.CurrentRow >= playlistItem.XmlDataRows.Count) //at the end of this playlist item's data, go to the next item
                                {
                                    playlistItem.CurrentRow = 0;
                                    playlist.CurrentPlaylistItem += 1;
                                    nextPlaylistItem(playlist);
                                }
                                else
                                {
                                    PlayerCommand commandToSend = new PlayerCommand();

                                    commandToSend.Command = (DraftAdmin.PlayoutCommands.CommandType)Enum.Parse(typeof(DraftAdmin.PlayoutCommands.CommandType), "ShowPage");
                                    commandToSend.CommandID = Guid.NewGuid().ToString();
                                    commandToSend.Parameters = new List<CommandParameter>();
                                    commandToSend.Parameters.Add(new CommandParameter("TemplateName", playlistItem.Template));

                                    commandToSend.TemplateData = playlistItem.XmlDataRows[playlistItem.CurrentRow].GetXMLString();

                                    playlist.Timer.Interval = Convert.ToDouble((playlistItem.Duration * 1000));

                                    if (playlistItem.MergeDataNoTransitions)
                                    {
                                        commandToSend.Parameters.Add(new CommandParameter("MergeDataWithoutTransitions", "true"));

                                        OnSendCommandNoTransitions(commandToSend);

                                        //Debug.Print("Clock sent to PageEngine: " + DateTime.Now);

                                        if (playlist.TimerRunning)
                                        {
                                            playlist.Timer.Start();
                                        }
                                    }
                                    else
                                    {
                                        //don't send data to the playout for the prompter if it hasn't changed.  too many graphics causes the clock to choke
                                        if (playlistItem.Template.ToUpper() == "PROMPTER")
                                        {
                                            if (_lastTemplateData != commandToSend.TemplateData)
                                            {
                                                _lastTemplateData = commandToSend.TemplateData;
                                                OnSendCommand(commandToSend, playlist);
                                            }
                                            else
                                            {
                                                if (playlist.TimerRunning)
                                                {
                                                    playlist.Timer.Start();
                                                }
                                            }
                                        }
                                        else
                                        {
                                            OnSendCommand(commandToSend, playlist);
                                        }

                                        //Debug.Print(playlistItem.Template.ToString() + " sent to PageEngine");
                                    }

                                    //SelectedPlaylist.PlaylistItems[SelectedPlaylist.CurrentPlaylistItem].OnAir = true;

                                    //OnPropertyChanged("SelectedPlaylist.PlaylistItems");
                                    playlistItem.OnAir = true;

                                    playlistItem.CurrentRow += 1;
                                }

                            }
                            else
                            {
                                if (playlist.PlaylistItems.Count > 1)
                                {
                                    playlistItem.CurrentRow = 0;
                                    playlist.CurrentPlaylistItem += 1;
                                    nextPlaylistItem(playlist, forceRestart);
                                }
                            }

                        } //playlistItem.XmlDataRows != null

                    } //playlistItem.Enabled == false

                } //playlist.TimerRunning
            }
            catch (Exception ex)
            {
                if (playlistItem != null)
                {
                    playlistItem.CurrentRow = 0;
                }

                if (playlist != null)
                {
                    playlist.CurrentPlaylistItem += 1;

                    nextPlaylistItem(playlist);
                }
            }

            //OnPropertyChanged("SelectedPlaylist");
        }