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; }
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); }
public void Delete(PlayListItem playListItem) { var playList = _playListService.GetByGuid(playListItem.PlayListGuid); if (playList == null) return; playList.Items.Remove(playListItem); }
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); }
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(); }
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); }
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; }
private FPlayer GetPlayListItemPlayer(PlayListItem playListItem) { if (playListItem == null) return null; return _fplayers.FirstOrDefault(player => player.PlayListItem.Screen == playListItem.Screen); }
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; } }
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(); }
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; }
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 } }
public void Insert(PlayListItem playListItem, PlayList playList) { if (!playList.Items.Contains(playListItem)) playList.Items.Add(playListItem); }