示例#1
0
        public PlayListItem Create(string filePath, PlayList playList)
        {
            var isStreamed = filePath.ToLower().Contains("http://") || 
                filePath.ToLower().Contains("https://") ||
                filePath.ToLower().Contains("ftp://");

            var plItem = new PlayListItem
            {
                Guid = Guid.NewGuid().ToString(),
                FileName = Path.GetFileName(filePath),
                FilePath = filePath,
                PlayListGuid = playList.Guid,
                Source = isStreamed ? PlayListItemSource.Streamed : PlayListItemSource.Disk,
            };

            plItem.ThumbnailPath = _thumbnailService.GenerateForFile(filePath, plItem.Source);
            if (PathHelper.FileIsLocked(filePath))
                return null;

            var tagFile = _fileTagService.GetTag(plItem.FilePath, plItem.Source);
            if (tagFile == null)
                return null;

            plItem.Type = tagFile.Type;
            plItem.TagName = tagFile.Tag.Title;
            plItem.FullScreen = plItem.Type != PlayListItemType.Audio;
            
            return plItem;
        }
示例#2
0
        public IEnumerable<PlayListItem> GetAllPlayListItemsInGroup(PlayListItem playListItem)
        {
            if (playListItem.Group == 0)
                return new[] {playListItem};

            var playList = GetByGuid(playListItem.PlayListGuid);
            return playList.Items.Where(p => p.Group == playListItem.Group);
        }
示例#3
0
        public void Delete(PlayListItem playListItem)
        {
            var playList = _playListService.GetByGuid(playListItem.PlayListGuid);
            if (playList == null)
                return;

            playList.Items.Remove(playListItem);
        }
示例#4
0
        public void MoveItem(PlayListItem playListItem, bool up)
        {
            var playList = GetByGuid(playListItem.PlayListGuid);
            var currentIndex = playList.Items.IndexOf(playListItem);
            var newIndex = up ? currentIndex - 1 : currentIndex + 1;
            if ((newIndex < 0) || (newIndex > playList.Items.Count))
                return;

            //If we are moving the last item down 1, then when the remove call is made on the list, the item count will be -1
            if (newIndex == playList.Items.Count)
                newIndex = newIndex - 1;

            playList.Items.Remove(playListItem);
            playList.Items.Insert(newIndex, playListItem);
        }
示例#5
0
        public FPlayer(PlayListItem playListItem)
        {
            _currentlyPlayListItem = playListItem;

            //Do the window movement before InitializeComponent so we can ensure the window is located in the correct screen (full screen mode only).
            if (_currentlyPlayListItem != null && _currentlyPlayListItem.FullScreen)
                WindowState = FormWindowState.Maximized;

            InitializeScreen();

            InitializeComponent();
            
            wmPlayer.settings.volume += 100;
            _currentPlayState = WMPPlayState.wmppsStopped;
            _axReaderCurrentScrollOffset = 0;
            _axReaderCurrentPage = 1;
            _axReaderTotalPages = 0;
            StopAndHidePlayer();
        }
示例#6
0
        private void LoadPlayListItemDetail(PlayListItem playListItem)
        {
            pbCurrentlySelected.Image = File.Exists(playListItem.ThumbnailPath)
                ? Image.FromFile(playListItem.ThumbnailPath)
                : pbCurrentlySelected.InitialImage;

            numGroup.Text = playListItem.Group.ToString();
            pScreenSelection.Visible = playListItem.SupportsMultiCast;
            numPdfPageNumber.Text = playListItem.PdfPageNumber.ToString();
            cbPdfView.SelectedIndex = playListItem.PdfView == "FitV" ? 1 : 0;

            if (playListItem.StartTime != null)
            {
                numStartMin.Text = playListItem.StartTime.Split(':').FirstOrDefault();
                numStartSec.Text = playListItem.StartTime.Split(':').LastOrDefault();
            }

            if (playListItem.StopTime != null)
            {
                numStopMin.Text = playListItem.StopTime.Split(':').FirstOrDefault();
                numStopSec.Text = playListItem.StopTime.Split(':').LastOrDefault();
            }

            pPdfOptions.Visible = playListItem.Type == PlayListItemType.Pdf;
            if (playListItem.SupportsMultiCast)
                LoadScreens(playListItem.Screen);
        }
示例#7
0
        private void LoadPlayListItems(PlayListItem selectedItem = null)
        {
            pnlProgress.Visible = false;

            var selectedPlayList = GetSelectedPlayList();
            if (selectedPlayList == null)
                return;

            lbPlayListItems.DataSource = selectedPlayList.Items.Where(f => f != null).ToList();
            lbPlayListItems.DisplayMember = "TagName";
            lbPlayListItems.ValueMember = "FileName";

            if (lbPlayListItems.Items.Count > 0)
            {
                if (selectedItem == null)
                    lbPlayListItems.SelectedIndex = 0;
                else
                    lbPlayListItems.SelectedItem = selectedItem;
            }
            else
                pbCurrentlySelected.Image = pbCurrentlySelected.InitialImage;

        }
示例#8
0
文件: FMain.cs 项目: webnoob/KHPlayer
        private FPlayer GetPlayListItemPlayer(PlayListItem playListItem)
        {
            if (playListItem == null)
                return null;

            return _fplayers.FirstOrDefault(player => player.PlayListItem.Screen == playListItem.Screen);
        }
示例#9
0
文件: FMain.cs 项目: webnoob/KHPlayer
 private void SelectAllPlayListItemsInGroup(PlayListItem playListItem)
 {
     foreach (
         var row in
             gvPlayListItems.Rows.Cast<DataGridViewRow>()
                 .Where(
                     r =>
                         (r.DataBoundItem as PlayListItem) == playListItem ||
                         ((r.DataBoundItem as PlayListItem).Group == playListItem.Group && playListItem.Group > 0))
         )
     {
         row.Selected = true;
     }
 }
示例#10
0
文件: FMain.cs 项目: webnoob/KHPlayer
        private void ClosePlayer(object sender, EventArgs e)
        {
            //TODO: Not happy with the ClosePlayer doing stuff like SetNextVideo().
            //This should be up to stop but I'm having issues with various references
            //so leaving for now.

            var fPlayer = sender as FPlayer;
            if (fPlayer != null)
            {
                if (fPlayer.CurrentPlayState == WMPPlayState.wmppsPlaying || fPlayer.CurrentPlayState == WMPPlayState.wmppsPaused)
                    bStop_Click(sender, e);

                _currentPlayListItems.RemoveAll(p => p == fPlayer.PlayListItem);
                _lastPlayedItem = fPlayer.PlayListItem; //Get so we know where to base the next selection off.)
                fPlayer.DoBeforeClose();
                fPlayer.Dispose();
                _fplayers.RemoveAll(p => p.PlayListItem == null || p.PlayListItem.Screen == fPlayer.PlayListItem.Screen);
                SetNextVideo();
            }

            SetButtonState();
        }
示例#11
0
文件: FMain.cs 项目: webnoob/KHPlayer
        private FPlayer LaunchPlayer(PlayListItem playListItem)
        {
            if (_fplayers.Any(p => p.PlayListItem.Screen == playListItem.Screen))
                return null;

            var player = new FPlayer(playListItem);
            player.Closing += ClosePlayer;
            player.OnPlayStateChanged += PlayStateChanged;
            player.Show(this);
            _fplayers.Add(player);
            SetButtonState();
            return player;
        }
示例#12
0
        public void PlayPlayListItem(PlayListItem playListItem)
        {
            if (playListItem == null)
                return;

            _currentlyPlayListItem = playListItem;
            ShowPlayer();

            if (_currentlyPlayListItem.Type == PlayListItemType.Video || 
                _currentlyPlayListItem.Type == PlayListItemType.Audio)
            {
                if (playListItem.SupportsMultiCast && playListItem.Screen == null)
                    throw new Exception("No Screen Setup");

                if (playListItem.StartMin > 0 || playListItem.StartSec > 0)
                {
                    wmPlayer.Ctlcontrols.currentPosition = (playListItem.StartMin*60) + playListItem.StartSec;
                }

                //Don't split the audio out if this is the default screen or it's not a compatable item.
                if (playListItem.SupportsMultiCast && !playListItem.Screen.DefaultScreen)
                {
                    //This code allows us to play the audio via any device we choose, we just need to know the device ID.
                    var waveReader = new MediaFoundationReader(playListItem.FilePath);
                    _waveOut = new WaveOut {DeviceNumber = PlayListItem.Screen.AudioDevice.Id};
                    _waveOut.Init(waveReader);
                    wmPlayer.settings.volume = 0;
                    wmPlayer.URL = playListItem.FilePath;
                    _waveOut.Play();
                }
                else
                {
                    wmPlayer.URL = playListItem.FilePath;
                }
            }
            else if (_currentlyPlayListItem.Type == PlayListItemType.Pdf)
            {
                //NOTE: See the comment in the InitializeComponent() method (where this code should actually be!)
                this.Controls.Add(this.axReader);

                axReader.LoadFile(playListItem.FilePath);
                axReader.setView(playListItem.PdfView);
                axReader.setShowScrollbars(false);
                axReader.setShowToolbar(false);
                axReader.setCurrentPage(playListItem.PdfPageNumber);
                _axReaderCurrentPage = playListItem.PdfPageNumber;

                //Get total number of pages for use in the navigation properties.
                var pdfReader = new PdfReader(playListItem.FilePath);
                _axReaderTotalPages = pdfReader.NumberOfPages;

                //This is madness. The PDF won't actually show unless the form is resized.
                //Tried a refresh but didn't help. This causes a slight flicker but it's the best I can do for now.
                var currentWindowState = WindowState;
                WindowState = FormWindowState.Minimized;
                WindowState = currentWindowState;
            }
            else if (_currentlyPlayListItem.Type == PlayListItemType.Image)
            {
                pbMain.Image = Image.FromFile(playListItem.FilePath);
                pbMain.Visible = true;
                pbMain.SizeMode = PictureBoxSizeMode.Zoom;
                //pbMain.SizeMode  
            }
        }
示例#13
0
 public void Insert(PlayListItem playListItem, PlayList playList)
 {
     if (!playList.Items.Contains(playListItem))
         playList.Items.Add(playListItem);
 }