/// <summary> /// Gets the full path to the given playlist item. /// </summary> /// <param name="item">The item to get the path of.</param> /// <returns>The full path to the item.</returns> public static string GetFullPath(this IPlaylistItem item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } var path = item.Path; IPlaylistContainer parent = item.Parent; while (parent != null) { if (Path.IsPathRooted(path)) { break; } path = Path.Combine(parent.IncludesFilename ? Path.GetDirectoryName(parent.Path) : parent.Path, path); parent = parent.Parent; } // when used, the playlist items must be rooted *somewhere* // otherwise the files they correspond to cannot be located if (!Path.IsPathRooted(path)) { throw new InvalidOperationException("The full path couldn't be retrieved. The root playlist must always have a rooted path."); } return(Path.GetFullPath(path)); }
static void dumpPlayListItem(IPlaylistItem itm, string itdel) { string txtline = " "+ itdel + "{"; txtline = txtline + "'EndOffset': '" + itm.EndOffset + "'"; txtline = txtline + ", 'Length': '" + itm.Length + "'"; txtline = txtline + ", 'Position': '" + itm.Position + "'"; txtline = txtline + ", 'StartOffset': '" + itm.StartOffset + "'"; if (itm.GetType() == typeof(PatternPlaylistItem)) { PatternPlaylistItem pli = (PatternPlaylistItem)itm; txtline = txtline + ", 'pattern_id': '" + pli.Pattern.Id + "'"; txtline = txtline + ", 'channel_id': null"; txtline = txtline + ", 'muted': '" + pli.Muted + "'"; } else { if (itm.GetType() == typeof(ChannelPlaylistItem)) { ChannelPlaylistItem chpli = (ChannelPlaylistItem)itm; txtline = txtline + ", 'pattern_id': null"; txtline = txtline + ", 'channel_id': '" + chpli.Channel.Id + "'"; txtline = txtline + ", 'muted': '" + chpli.Muted + "'"; } else { txtline = txtline + ", 'pattern_id': null"; txtline = txtline + ", 'channel_id': null"; txtline = txtline + ", 'muted': null"; } } txtline = txtline + "}"; Console.WriteLine(txtline); }
// initializes a playlist item using a corresponding STON value private static void InitializeFromSton(IPlaylistItem item, IStonDocument document, IStonComplexEntity entity, IDictionary <IStonValuedEntity, object> builtObjects) { item.Name = FromSton <string>(document, GetValue(document, document.GetMember(entity, new StonBindingName("Name"))), builtObjects) ?? item.GetType().Name; // playlist never declares its path explicitly // in general, it should be based on the playlist location instead if (!(item is Playlist)) { item.Path = FromSton <string>(document, GetValue(document, document.GetMember(entity, new StonBindingName("Path"))), builtObjects) ?? ""; } // loading subitems of a container if (item is IPlaylistContainer) { var container = item as IPlaylistContainer; foreach (var subitemData in entity.CollectionInit.Elements) { var subitem = FromSton <IPlaylistItem>(document, GetValue(document, subitemData), builtObjects); container.Add(subitem); } } // loading the loop provider of a playlist if (item is Track) { (item as Track).StreamProvider = FromSton <IStreamProvider>(document, GetValue(document, document.GetMember(entity, new StonBindingName("Stream"))), builtObjects); } }
private void ScrollToCurrentCanExecute(object sender, CanExecuteRoutedEventArgs e) { IPlaylistItem currentPlaying = lstPlaylist.Items[(int)Math.Round(ScrollOffset)] as IPlaylistItem; e.CanExecute = iNowPlayingItem != null && currentPlaying != null && !(currentPlaying).IsPlaying; e.Handled = true; }
//public void InitializeItem() //{ // //Check if the file exists // if (!System.IO.File.Exists(Path)) // { // Content.Status = ContentStatus.UnsuccessfulPathResolution; // return; // } // //needs immeditate change // var contentResolver = new ContentInterpreter(Path); // if (contentResolver == null) // { // Content.Status = ContentStatus.UnsupportedFormat; // } // //Add content resolver so the audio can be played // Content.AddContentResolver(contentResolver); // //Update status // Content.Status = ContentStatus.Preloading; // //send caching request // SetProperties(); // PlaylistItem item = PlaylistItem.CreateFromContent(Content); // ItemSetup(item); //} /// <summary> /// Unfinished /// <para>Unfinished</para> /// <para>Unfinished</para> /// <para>Unfinished</para> /// <para>Unfinished</para> /// <para>Unfinished</para> /// <para>Unfinished</para> /// <para>Unfinished</para> /// <para>Unfinished</para> /// <para>Unfinished</para> /// <para>Unfinished</para> /// <para>Unfinished</para> /// /// </summary> protected void ItemSetup(IPlaylistItem item) { //item.Content.Beginning = TimeSpan.Zero; //item.Content.DurationType = 0; //item.TimeType = 0; //item.Content.VolumeCurve = VolumeCurve.CreateDefault(item.Content.Duration); //item.Settings = //item.History = //item.ItemType = }
public Playable SetActive(IPlaylistItem item) { if (_playing != null) { _playing.IsPlaying = false; } _playing = this.SingleOrDefault(p => IsEqual(p.Id, item.Id)); if (_playing != null) { _playing.IsPlaying = true; } return(_playing); }
void ListBox_MouseDoubleClick(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { IPlaylistItem selected = GetEventSourceItem(e); if (PlaylistSelectionChanged != null && selected != null) { if (selected is PlaylistGroupHeaderItem) { selected = (IPlaylistItem)lstPlaylist.Items[lstPlaylist.Items.IndexOf(selected) + 1]; } PlaylistSelectionChanged(this, new PlaylistSelectionEventArgs(selected)); } } }
static void dumpTrack(Track track, string dlmtr, int tt) { Console.WriteLine(" "+ dlmtr + "{"); Console.WriteLine(" 'Color':'"+ track.Color + "'"); Console.WriteLine(" ,'Items':["); string itdel = ""; for (int ii = 0; ii < track.Items.Count; ii++) { IPlaylistItem itm = track.Items[ii]; dumpPlayListItem(itm, itdel); itdel = ","; } Console.WriteLine(" ]"); Console.WriteLine(" ,'Name':'"+ track.Name + "'"); Console.WriteLine(" ,'order':'"+ tt + "'"); Console.WriteLine(" }"); }
private FrameworkElement GetDragVisual(MouseEventArgs args) { IPlaylistItem dragItem = GetEventSourceItem(args); if (dragItem != null) { Image img = new Image(); img.Height = DragHelper.kDefaultVisualHeight; img.SetValue(Image.SourceProperty, StaticImages.ImageSourceIconLoading); KinskyDesktop.Instance.ImageCache.Load(KinskyDesktop.Instance.IconResolver.Resolve(dragItem.WrappedItem), (s) => { this.Dispatcher.BeginInvoke((Action)(() => { img.SetValue(Image.SourceProperty, s); })); }); return(img); } return(null); }
// builds a STON entity from a playlist item private static IStonEntity ToSton(this IPlaylistItem item) { string typeName; var properties = new List <KeyValuePair <IStonBindingKey, IStonEntity> >(); IEnumerable <IStonEntity> subitems = null; properties.Add(MakeStonProperty("Name", MakeStonSimpleEntity(item.Name))); // the path of the playlist depends on its filesystem location // and thus is excluded from playlist item properties if (!(item is Playlist)) { properties.Add(MakeStonProperty("Path", MakeStonSimpleEntity(item.Path))); } // preparing subitems collection if the item is container if (item is IPlaylistContainer) { subitems = (item as IPlaylistContainer).Select(i => i.ToSton()); } // determining the type, and adding type specific variables switch (item) { case Playlist playlist: typeName = "Playlist"; break; case Track track: typeName = "Track"; properties.Add(MakeStonProperty("Stream", track.StreamProvider.ToSton())); break; default: throw new NotSupportedException(); } // building the result return(new StonComplexEntity(null, new StonMemberInit(properties), subitems != null ? new StonCollectionInit(subitems) : null, new StonNamedType(typeName))); }
void ListView_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { iDoubleClick = false; iLeftButtonDown = true; iMouseDragStartPoint = e.GetPosition(this); DateTime previousMouseDownTime = iMouseDownTime; iMouseDownTime = DateTime.Now; IPlaylistItem selected = GetEventSourceItem(e); if (selected != null) { if (iMouseDownTime.Subtract(previousMouseDownTime) < TimeSpan.FromMilliseconds(500)) { iDoubleClick = true; if (PlaylistSelectionChanged != null) { iLastUserIntervention = DateTime.MinValue; PlaylistSelectionChanged(this, new PlaylistSelectionEventArgs(selected)); } } else { DispatcherTimer t = new DispatcherTimer(); t.Interval = TimeSpan.FromSeconds(0.5); t.Tick += ((d, a) => { if (!iDoubleClick && !iLeftButtonDown) { iLastUserIntervention = DateTime.Now; AnimateToPosition(selected.Position, true, AnimationExtensions.kUIElementAnimationDuration.TimeSpan, 0.0); } t.Stop(); }); t.Start(); } } e.Handled = true; }
public void SetNowPlayingItem(IPlaylistItem aSelectedItem) { if (lstPlaylist.ItemsSource != null) { List <IPlaylistItem> items = lstPlaylist.ItemsSource as List <IPlaylistItem>; if (items != null) { for (int i = 0; i < items.Count; i++) { if (items[i] != null) { if (aSelectedItem != null && items[i].WrappedItem == aSelectedItem.WrappedItem) { items[i].IsPlaying = true; iNowPlayingItem = items[i]; if (iLastUserIntervention.AddSeconds(kLastUserInterventionTimeoutSeconds) < DateTime.Now) { AnimateToPosition(items[i].Position, true, AnimationExtensions.kUIElementAnimationDuration.TimeSpan, 0.0); } } else { if (items[i].IsPlaying) { var item = items[i]; DispatcherTimer t = new DispatcherTimer(); t.Interval = TimeSpan.FromSeconds(0.5); t.Tick += ((d, a) => { item.IsPlaying = false; t.Stop(); }); t.Start(); } } } } } } }
private void setDurationToolStripMenuItem_Click(object sender, EventArgs e) { TimeSpan duration = TimeSpan.Zero; if (lbxPlaylist.SelectedItems.Count == 1) { IPlaylistItem item = lbxPlaylist.SelectedItems[0] as IPlaylistItem; duration = item.CustomDuration; } using (DialogSetDuration dialog = new DialogSetDuration(duration)) { if (dialog.ShowDialog(this) == DialogResult.OK) { duration = dialog.Duration; foreach (IPlaylistItem item in lbxPlaylist.SelectedItems.Cast <IPlaylistItem>()) { item.CustomDuration = duration; } } } }
public void SetNowPlayingItem(IPlaylistItem aSelectedItem, bool aScrollToSelected) { if (lstPlaylist.ItemsSource != null) { List <IPlaylistItem> items = lstPlaylist.ItemsSource as List <IPlaylistItem>; if (items != null) { for (int i = 0; i < items.Count; i++) { if (items[i] != null) { if (aSelectedItem != null && items[i].WrappedItem == aSelectedItem.WrappedItem && !(items[i] is PlaylistGroupHeaderItem)) { if (aScrollToSelected) { lstPlaylist.UpdateLayout(); try { lstPlaylist.ScrollIntoView(items[i]); } catch (NullReferenceException) { } //bug in virtualizing stack panel, ignore } iNowPlayingItem = items[i]; items[i].IsPlaying = true; if (items[i] is SenderListItem && aSelectedItem is SenderListItem) { (items[i] as SenderListItem).HasRoom = (aSelectedItem as SenderListItem).HasRoom; } } else { items[i].IsPlaying = false; } } } } } }
/// <summary> /// Gets the relative path to the given playlist item, using its parent full path as a reference. /// </summary> /// <param name="item">The item to get the relative path of.</param> /// <returns>The path relative to the parent's full path.</returns> public static string GetRelativePath(this IPlaylistItem item) { if (item.Parent == null) { return(item.Path); } if (item.Path == "") { return(item.Path); } var parentPath = item.Parent.GetFullPath(); if (item.Parent.IncludesFilename) { parentPath = Path.GetDirectoryName(parentPath); } var ownPath = Path.GetFullPath(Path.Combine(parentPath, item.Path)); var parentSegments = parentPath.Split(Path.DirectorySeparatorChar).ToList(); var ownSegments = ownPath.Split(Path.DirectorySeparatorChar).ToList(); // if the playlist item and parent are rooted at different places // the only possible relative path is item's own path if (parentSegments.First() != ownSegments.First()) { return(ownPath); } // going through the common segments while (parentSegments.Any() && ownSegments.Any() && parentSegments.First() == ownSegments.First()) { parentSegments.RemoveAt(0); ownSegments.RemoveAt(0); } return(string.Join("", Enumerable.Repeat(".." + Path.DirectorySeparatorChar, parentSegments.Count)) + string.Join(Path.DirectorySeparatorChar.ToString(), ownSegments)); }
private void UpdateDetailsPanel() { SetScrollViewer(); IPlaylistItem item = lstPlaylist.Items.CurrentItem as IPlaylistItem; UIElement listItem = lstPlaylist.ItemContainerGenerator.ContainerFromItem(item) as UIElement; if (listItem != null) { Size size = listItem.RenderSize; Point topCenter = listItem.TransformToAncestor((Visual)this).Transform(new System.Windows.Point(size.Width / 2, 0)); double left = Math.Max(0, Math.Min(cnvDetails.ActualWidth - pnlDetails.ActualWidth, topCenter.X - pnlDetails.ActualWidth / 2)); pnlDetails.SetValue(Canvas.LeftProperty, left); pnlDetails.SetValue(Canvas.TopProperty, 0.0); pnlDetails.DataContext = item; } else { pnlDetails.DataContext = null; } }
private void btnPlayPause_Click(object sender, EventArgs e) { IPlaylistItem item = SelectedPlaylistItem; if (!CurrentPlayer.IsPlaying && item == null && lbxPlaylist.Items.Count > 0) { item = CurrentPlayer.Playlist.Items[0]; } if (CurrentPlayer.Media == null && item != null) // No media loaded. { CurrentPlayer.Play(item); } else if (!CurrentPlayer.IsEnded) { CurrentPlayer.Pause(); } else { CurrentPlayer.Play(); } }
void Scroller_ItemsDropped(object sender, DragScroller.EventArgsItemsDropped e) { ListBoxItem item = lstPlaylist.GetEventSourceElement <ListBoxItem>(e.DragEventArgs); int dropIndex = 0; if (item != null) { Point p = e.DragEventArgs.GetPosition(item); bool top = p.Y < item.ActualHeight / 2; IPlaylistItem containedItem = GetEventSourceItem(e.DragEventArgs); dropIndex = top ? containedItem.Position : containedItem.Position + 1; } else if (lstPlaylist.Items.Count > 0) { Point p = e.DragEventArgs.GetPosition(lstPlaylist); bool top = p.Y < 10; dropIndex = top ? 0 : (lstPlaylist.Items[lstPlaylist.Items.Count - 1] as PlaylistListItem).Position + 1; } MediaProviderDraggable draggable = iDropConverter.Convert(e.DragEventArgs.Data); PlaylistDropEventArgs eventArgs = new PlaylistDropEventArgs(); eventArgs.Data = draggable; eventArgs.DropIndex = dropIndex; if (draggable != null && draggable.DragSource == this && PlaylistItemsMoved != null) { PlaylistItemsMoved(this, eventArgs); } else { if (draggable != null && PlaylistItemsAdded != null) { PlaylistItemsAdded(this, eventArgs); } } }
public IPlaylistItem Create(string filePath) { IPlaylistItem playlistItem = null; if (string.IsNullOrWhiteSpace(filePath)) { return(playlistItem); } var extension = Path.GetExtension(filePath); switch (extension) { case ".mp3": playlistItem = new Mp3Item(filePath); break; default: playlistItem = null; break; } return(playlistItem); }
public void PlayingClipChanged(IPlaylistItem NewClip) { }
/// <summary> /// Removes the first occurrence of an item in the container. /// </summary> /// <param name="item">The item to remove.</param> /// <returns>true if the item has been removed, false otherwise</returns> public bool Remove(IPlaylistItem item) { UnregisterItem(item); return(Items.Remove(item)); }
/// <summary> /// Adds an item to the container. /// </summary> /// <param name="item">The item to add.</param> public void Add(IPlaylistItem item) { RegisterItem(item); Items.Add(item); }
/// <summary> /// Determines whether the container contains a specific item. /// </summary> /// <param name="item">The item to find in the container.</param> /// <returns>true if the container contains the item, false otherwise</returns> public bool Contains(IPlaylistItem item) => Items.Contains(item);
/// <summary> /// Adds a <see cref="IPlaylistItem"/> instance to <see cref="IPlayerSettings.Playlist"/> collection of caller <see cref="IPlayerSettings"/> instance. /// </summary> /// <param name="playerSettings">Caller <see cref="IPlayerSettings"/> instance.</param> /// <param name="playlistItem"><see cref="IPlaylistItem"/> instance to add.</param> /// <returns>The caller <see cref="IPlayerSettings"/> instance with <see cref="IPlaylistItem"/> instance added to <see cref="IPlayerSettings.Playlist"/> collection.</returns> public static IPlayerSettings WithPlaylistItem(this IPlayerSettings playerSettings, IPlaylistItem playlistItem) { playerSettings.Playlist.Add(playlistItem); return playerSettings; }
public static bool IsTruncated(this IPlaylistItem playlistItem) { // Note: 定时播和定时插播应该总是返回false。 return(playlistItem.PlaybillItem.IsTruncated()); }
public WplItem(IPlaylistItem item) : base(item) { }
public void PlayingClipChanged(IPlaylistItem NewClip) { FireJwEvent("jwplayerPlaylistItem", "{index:"+NewClip.PlaylistIndex+"}"); }
public PlaylistItemViewModel(IMetadataController controller, IPlaylistItem playlistItem) : base(controller, playlistItem, "PLAYLIST ITEM", "pack://application:,,,/Images/play-simple.png") { }
public static bool IsLastSegment(this IPlaylistItem playlistItem) { // Note: 定时播和定时插播总是抛出异常。 return(playlistItem.PlaybillItem.IsLastSegment); }
protected abstract T CreateItem(IPlaylistItem item);
private void UnlinkLoadedTextItem() { _loadedTextItem = new NullPlaylistItem(); }
public PlaylistMoveEventArgs(IPlaylistItem aSelectedItem) : base() { SelectedItem = aSelectedItem; }
public void PlayingClipChanged(IPlaylistItem NewClip) { BindActiveStates(); }
void ListBox_PreviewRightMouseButtonDown(object sender, MouseButtonEventArgs args) { iRightMouseSelectedItem = GetEventSourceItem(args); }