public PlaylistData[] GetPlaylists()
 {
     try
     {
         List <PlaylistData> playlistsList = new List <PlaylistData>();
         string[]            playlistFiles = System.IO.Directory.GetFiles(PikoDataServiceApp.PikoPlaylistPath);
         foreach (string FileName in playlistFiles)
         {
             System.IO.FileInfo fileInfo = new System.IO.FileInfo(FileName);
             if (!string.IsNullOrEmpty(fileInfo.Extension) && fileInfo.Extension == ".xml")
             {
                 PlaylistData APlaylist = Piko.XML.PikoXML.LoadXML(FileName);
                 if (APlaylist != null)
                 {
                     playlistsList.Add(APlaylist);
                 }
             }
         }
         return(playlistsList.ToArray());
     }
     catch
     {
         return(new PlaylistData[0]);
     }
 }
示例#2
0
        /// <summary>
        /// Creates a new playlist
        /// </summary>
        /// <param name="name">The name of the new playlist (this will be appended with a number if neccessary)</param>
        /// <param name="id">The ID of the playlist in the cloud</param>
        /// <param name="owner">The ID of the user who owns the playlist</param>
        /// <param name="interactive">Whether the action was performed by the user directly</param>
        /// <returns>The newly created PlaylistData for the playlist</returns>
        public static PlaylistData CreatePlaylist(String name, uint id = 0, uint owner = 0, bool interactive = false)
        {
            name = U.CleanXMLString(name);

            if (FindPlaylist(name) != null)
            {
                int pExt = 1;
                while (FindPlaylist(name + pExt) != null)
                {
                    pExt++;
                }
                name = name + pExt;
            }

            PlaylistData playlist = new PlaylistData();

            playlist.Name   = name;
            playlist.ID     = id;
            playlist.Owner  = owner;
            playlist.Time   = 0;
            playlist.Tracks = new ObservableCollection <TrackData>();
            playlist.Tracks.CollectionChanged += TracksChanged;
            SettingsManager.Playlists.Add(playlist);

            DispatchPlaylistModified(playlist, ModifyType.Created, interactive);

            return(playlist);
        }
示例#3
0
    //public void SetStreaming() {
    //    questionID = 0;
    //    if (source == SOURCE.streaming)
    //        return;
    //    StartCoroutine(LoadFromJWPlayer(streamingURL));
    //    source = SOURCE.streaming;
    //}

    IEnumerator LoadFromJWPlayer(string playlistID, bool isTodayTrivia)
    {
        string url = "https://cdn.jwplayer.com/v2/playlists/" + playlistID;
        WWW    www = new WWW(url);

        Debug.Log("LoadFromJWPlayer " + playlistID + "url: " + url + " isTodayTrivia : " + isTodayTrivia);

        yield return(www);

        if (!isTodayTrivia)
        {
            Debug.Log("old: playlist" + playlistID + "  oldData.Count: " + oldData.Count);
            PlaylistData d = JsonUtility.FromJson <PlaylistData>(www.text);
            oldData.Add(d);
            Data.Instance.trainingData.AddOldTriviaToTrainingList(d.playlist);
        }
        else
        {
            data   = JsonUtility.FromJson <PlaylistData>(www.text);
            loaded = true;

            if (OnLoaded != null)
            {
                OnLoaded();
                OnLoaded = null;
            }
        }
    }
示例#4
0
        /// <summary>
        /// Add tracks to a playlist
        /// </summary>
        /// <param name="tracks">The list of tracks to be added</param>
        /// <param name="playlistName">The name of the playlist to add the tracks to</param>
        /// <param name="pos">The position to insert the track at (-1 means at the end)</param>
        public static void AddToPlaylist(ObservableCollection <TrackData> tracks, String playlistName, int pos = -1)
        {
            PlaylistData playlist = FindPlaylist(playlistName);

            if (playlist == null)
            {
                return;
            }
            if (IsSomeoneElses(playlist))
            {
                return;
            }
            foreach (TrackData track in tracks)
            {
                if (!playlist.Tracks.Contains(track))
                {
                    if (pos < 0 || pos >= playlist.Tracks.Count)
                    {
                        playlist.Tracks.Add(track);
                    }
                    else
                    {
                        playlist.Tracks.Insert(pos, track);
                    }
                    track.Source = "Playlist:" + playlist.Name;
                }
            }
        }
示例#5
0
        public async Task <IActionResult> ShareCreate(string id)
        {
            var playlist = new PlaylistData()
            {
                SpotifyUri = id
            };
            //Get cookie
            var token = Request.Cookies["spottoke"];

            //Get userid from spotify with cookie

            //Get the actual user id
            playlist.UserId = await GetUserId(token);

            playlist.Id = Guid.NewGuid().ToString();

            await _dataService.AddData <PlaylistData>("playlistdata", playlist, playlist.Id);

            var link = _linkService.GetLink(playlist);

            //Returns a view with a shareable link
            return(PartialView("CreateShareResult", new Link()
            {
                Url = link
            }));
        }
示例#6
0
 /// <summary>
 /// Invoked when the user clicks "Save" in playlist context menu
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="e">The event data</param>
 public void SavePlaylist_Clicked(object sender, RoutedEventArgs e)
 {
     foreach (TreeViewItem tvi in GetCurrentItems())
     {
         PlaylistData pld = Tvi2Pl(tvi);
         try
         {
             Microsoft.Win32.SaveFileDialog dialog = new Microsoft.Win32.SaveFileDialog();
             dialog.Title      = "Save Playlist";
             dialog.DefaultExt = ".pls";
             dialog.Filter     = "Playlist (*.pls)|*.pls|Playlist (*.m3u)|*.m3u";
             dialog.FileName   = pld.Name;
             bool result = (bool)dialog.ShowDialog();
             if (result == true)
             {
                 PlaylistManager.SavePlaylist(dialog.FileName, pld.Name);
             }
         }
         catch (Exception exc)
         {
             MessageBox.Show(U.T("MessageSavingPlaylist", "Message") + ":\n" + exc.Message,
                             U.T("MessageSavingPlaylist", "Title"),
                             MessageBoxButton.OK,
                             MessageBoxImage.Error);
         }
     }
 }
        public async Task When_getting_playlistItems_from_YouTube_api_Then_they_are_saved_to_the_database(
            [Frozen] IYouTubeCleanupToolDbContext youTubeCleanupToolDbContext,
            [Frozen] IYouTubeCleanupToolDbContextFactory youTubeCleanupToolDbContextFactory,
            [Frozen] IYouTubeApi youTubeApi,
            PlaylistData playlist,
            List <PlaylistItemData> playlistItemData,
            GetAndCacheYouTubeData getAndCacheYouTubeData)
        {
            youTubeCleanupToolDbContextFactory.Create().Returns(youTubeCleanupToolDbContext);
            youTubeCleanupToolDbContext.GetPlaylists().Returns(new List <PlaylistData> {
                playlist
            });
            youTubeApi.GetPlaylistItems(Arg.Any <string>(), Arg.Any <Func <string, Task> >()).Returns(TestExtensions.ToAsyncEnumerable(playlistItemData));

            youTubeCleanupToolDbContext.GetPlaylistItems(Arg.Any <string>()).Returns(new List <PlaylistItemData>());

            var callback = new Action <PlaylistItemData, InsertStatus>((data, insertStatus) => _testOutputHelper.WriteLine($"{data.Title} - {insertStatus}"));

            // Act
            await getAndCacheYouTubeData.GetPlaylistItems(callback);

            // Assert
            await foreach (var _ in youTubeApi.Received(1).GetPlaylistItems(Arg.Any <string>(), Arg.Any <Func <string, Task> >()))
            {
            }
            await youTubeCleanupToolDbContext.Received(3).UpsertPlaylistItem(Arg.Any <PlaylistItemData>());

            await youTubeCleanupToolDbContext.Received(1).SaveChangesAsync();
        }
示例#8
0
        public static IPlaylistData GeneratePlaylist(XDocument xmlDocument)
        {
            var completeState = new PlaylistData();
            var rootElement = xmlDocument.Element("CompleteState");

            if(rootElement == null)
            { throw new Exception("Error parsing Xml, there is no root node"); }

            var soundStateNodes = rootElement.Elements("Players");
            foreach (var ambientStateNode in soundStateNodes.Elements("SoundState"))
            {
                var soundTypeAttribute = ambientStateNode.Attribute("PlayerTypeIdentifier");
                var soundState = PlayerTypeFactory.GetEntityForType(soundTypeAttribute.Value);
                soundState.PopulateFromXml(ambientStateNode);
                completeState.SoundStates.Add(soundState);
            }

            var quickSoundStateNodes = rootElement.Elements("QuickSoundStates");
            foreach (var quickSoundStateNode in quickSoundStateNodes.Elements("SoundState"))
            {
                var soundTypeAttribute = quickSoundStateNode.Attribute("PlayerTypeIdentifier");
                var soundState = PlayerTypeFactory.GetEntityForType(soundTypeAttribute.Value);
                soundState.PopulateFromXml(quickSoundStateNode);
                completeState.QuickSoundStates.Add(soundState);
            }

            return completeState;
        }
示例#9
0
 /// <summary>
 /// The dispatcher of the <see cref="PlaylistModified"/> event
 /// </summary>
 /// <param name="playlist">The playlist that was modified</param>
 /// <param name="type">The type of modification that occured</param>
 /// <param name="interactive">Whether the action was performed by the user directly</param>
 private static void DispatchPlaylistModified(PlaylistData playlist, ModifyType type, bool interactive = false)
 {
     if (PlaylistModified != null)
     {
         PlaylistModified(playlist, new ModifiedEventArgs(type, null, interactive));
     }
 }
示例#10
0
        /// <summary>
        /// Renames a playlist. If a playlist with the new name already exist or the new name is either "Create new" or "" it will do nothing.
        /// </summary>
        /// <param name="oldName">The current name of the playlist to be renamed</param>
        /// <param name="newName">The new name of the playlist</param>
        public static void RenamePlaylist(String oldName, String newName)
        {
            newName = U.CleanXMLString(newName);
            PlaylistData pl = FindPlaylist(oldName);

            RenamePlaylist(pl, newName);
        }
        public async Task When_getting_playlistItems_from_YouTube_api_Then_they_are_saved_to_the_database(
            [Frozen] IYouTubeCleanupToolDbContext youTubeCleanupToolDbContext,
            [Frozen] IYouTubeCleanupToolDbContextFactory youTubeCleanupToolDbContextFactory,
            [Frozen] IYouTubeApi youTubeApi,
            PlaylistData playlist,
            List <PlaylistItemData> playlistItemData,
            GetAndCacheYouTubeData getAndCacheYouTubeData)
        {
            youTubeCleanupToolDbContextFactory.Create().Returns(youTubeCleanupToolDbContext);
            youTubeCleanupToolDbContext.GetPlaylists().Returns(new List <PlaylistData> {
                playlist
            });
            youTubeApi.GetPlaylistItems(Arg.Any <string>(), Arg.Any <Func <string, Task> >()).Returns(TestExtensions.ToAsyncEnumerable(playlistItemData));

            youTubeCleanupToolDbContext.GetPlaylistItems(Arg.Any <string>()).Returns(new List <PlaylistItemData>());

            // Act
            await getAndCacheYouTubeData.GetPlaylistItems(Callback, CancellationToken.None);

            // Assert
            await foreach (var _ in youTubeApi.Received(1).GetPlaylistItems(Arg.Any <string>(), Arg.Any <Func <string, Task> >()))
            {
            }
            await youTubeCleanupToolDbContext.Received(3).UpsertPlaylistItem(Arg.Any <PlaylistItemData>());

            await youTubeCleanupToolDbContext.Received(1).SaveChangesAsync();
        }
示例#12
0
 /// <summary>
 /// The dispatcher of the <see cref="PlaylistRenamed"/> event
 /// </summary>
 /// <param name="playlist">The playlist that was renamed</param>
 /// <param name="oldName">The name of the playlist before the change</param>
 /// <param name="newName">The name of the playlist after the change</param>
 private static void DispatchPlaylistRenamed(PlaylistData playlist, string oldName, string newName)
 {
     if (PlaylistRenamed != null)
     {
         PlaylistRenamed(playlist, new RenamedEventArgs(WatcherChangeTypes.Renamed, "playlist", newName, oldName));
     }
 }
示例#13
0
        /// <summary>
        /// Updates the total time of all tracks of a playlist.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        private static void TracksChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            ObservableCollection <TrackData> tracks = sender as ObservableCollection <TrackData>;

            // find the playlist containing the track that sent the event
            PlaylistData pl = null;

            foreach (PlaylistData p in SettingsManager.Playlists)
            {
                if (p.Tracks == tracks)
                {
                    pl = p;
                    break;
                }
            }

            // no playlist found (weird!)
            if (pl == null)
            {
                return;
            }

            pl.Time = 0;
            foreach (TrackData t in pl.Tracks)
            {
                pl.Time += t.Length;
            }

            if (pl.Time < 0)
            {
                pl.Time = 0;
            }
        }
示例#14
0
        /// <summary>
        /// Invoked when the user clicks "Generate".
        /// </summary>
        /// <remarks>
        /// Will verify the name and generate a playlist.
        /// </remarks>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        private void Generate_Click(object sender, RoutedEventArgs e)
        {
            Regex alphaNumPattern = new Regex("[^a-zA-Z0-9 ]");

            if (alphaNumPattern.IsMatch(ListName.Text))
            {
                ErrorMessage.Text       = U.T("DialogNameInvalidError");
                ErrorMessage.Visibility = System.Windows.Visibility.Visible;
            }
            else if (ListName.Text == "")
            {
                ErrorMessage.Text       = U.T("DialogNameEmptyError");
                ErrorMessage.Visibility = System.Windows.Visibility.Visible;
            }
            else if (PlaylistManager.FindPlaylist(ListName.Text) != null)
            {
                ErrorMessage.Text       = U.T("DialogNameExistsError");
                ErrorMessage.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                // copy tracks to temporary list
                List <TrackData> tracks = new List <TrackData>();
                string           filter = GetFilter();
                foreach (TrackData t in GetTracks())
                {
                    if (!(bool)DoFilter.IsChecked || filterMatches(t, filter))
                    {
                        tracks.Add(t);
                    }
                }

                int n = GetNumber();
                if (n < 0)
                {
                    return;
                }

                if (tracks.Count > 0)
                {
                    // create empty playlist
                    PlaylistData p = PlaylistManager.CreatePlaylist(ListName.Text);
                    if (p != null)
                    {
                        // move tracks from temporary list into playlist
                        for (int i = 0; i < n && tracks.Count > 0; i++)
                        {
                            Random    r = new Random();
                            int       x = r.Next(tracks.Count - 1);
                            TrackData t = tracks[x];
                            p.Tracks.Add(t);
                            tracks.RemoveAt(x);
                        }
                    }
                }

                Close();
            }
        }
示例#15
0
        public async Task <List <PlaylistData> > GetPlaylists()
        {
            var result = new List <PlaylistData>();


            var channelsListRequest = youtubeService.Channels.List("snippet");

            channelsListRequest.Mine = true;

            var channelsListResponse = await channelsListRequest.ExecuteAsync();


            foreach (var channel in channelsListResponse.Items)
            {
                System.Diagnostics.Debug.WriteLine($"channel {channel.Snippet.Title}");

                var playlistRequest = youtubeService.Playlists.List("snippet");
                playlistRequest.ChannelId = channel.Id;

                var playlistResponse = await playlistRequest.ExecuteAsync();


                foreach (var playlist in playlistResponse.Items)
                {
                    System.Diagnostics.Debug.WriteLine($"{playlist.Id}: {playlist.Snippet.Title}");

                    var playlistData = new PlaylistData {
                        Playlist = playlist
                    };

                    string nextPageToken = string.Empty;
                    while (nextPageToken != null)
                    {
                        var playlistItemsRequest = youtubeService.PlaylistItems.List("snippet");
                        playlistItemsRequest.PlaylistId = playlist.Id;
                        playlistItemsRequest.MaxResults = 50;
                        playlistItemsRequest.PageToken  = nextPageToken;

                        var playlistItemsResponse = await playlistItemsRequest.ExecuteAsync();

                        foreach (var items in playlistItemsResponse.Items)
                        {
                            System.Diagnostics.Debug.WriteLine($"  {items.Snippet.ResourceId?.VideoId} : {items.Snippet.Title}");
                        }

                        // skip "private video"
                        playlistData.PlaylistItems.AddRange(playlistItemsResponse.Items.Where(item => item.Snippet.Thumbnails.Standard != null));

                        nextPageToken = playlistItemsResponse.NextPageToken;
                    }

                    result.Add(playlistData);
                }
            }


            return(result);
        }
        internal static PlaylistViewModel CreateNew(string name, NavigateToMediaCommand navigationCommand, IDialogService dialogService)
        {
            var newModelData = new PlaylistData()
            {
                ID = null, Name = name, IsEditable = true, PlaylistItems = new List <MediaLink>()
            };

            return(Create(newModelData, navigationCommand, dialogService));
        }
示例#17
0
 public Playlist(PlaylistData Data)
 {
     this.Data = Data;
     this.Data.PlaylistTitle = Data.PlaylistTitle;
     foreach (PlaylistElementData dataElement in this.Data.Elements)
     {
         this.AddElement(new PlaylistElement(dataElement));
     }
 }
示例#18
0
        /// <summary>
        /// Invoked when a playlist item is selected.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event data</param>
        public void Playlist_Selected(object sender, RoutedEventArgs e)
        {
            PlaylistData playlist = Tvi2Pl(sender as TreeViewItem);

            if (playlist == null)
            {
                return;
            }
            ToggleNavigation("Playlist:" + playlist.Name, sender as TreeViewItem);
        }
示例#19
0
        /// <summary>
        /// Checks if a playlist belongs to someone else.
        /// </summary>
        /// <param name="playlist">The playlist to check</param>
        /// <returns>true if someone else is the owner of the playlist, otherwise false</returns>
        public static bool IsSomeoneElses(PlaylistData playlist)
        {
            if (playlist == null)
            {
                return(false);
            }
            var id = ServiceManager.Identity;

            return(playlist.Owner > 0 && (id == null || id.UserID != playlist.Owner));
        }
 public MediaPlaylistViewModel(
     PlaylistData playlist,
     MediaLink media,
     IPlaylistDataService playlistDataService)
 {
     _playlist            = playlist;
     _media               = media;
     _playlistDataService = playlistDataService;
     IsInPlaylist         = playlist.PlaylistItems.Any(m => m.ID == media.ID);
 }
        public ActionResult Select()
        {
            var playlistData = new PlaylistData
            {
                SelectedGenres     = genreRepository.GetAll().ToList(),
                SelectedPerformers = performerRepository.GetAll().ToList(),
            };

            return(View(playlistData));
        }
        public static PlaylistData LoadXML(string xmlPath)
        {
            XElement     result      = XElement.Load(xmlPath);
            PlaylistData data        = new PlaylistData();
            XElement     generateTag = result.Element("Generate"); //new XElement("Generate");

            data.PlaylistTitle = generateTag.Attribute("play_list_title").Value;
            data.PlaylistType  = (generateTag.Attribute("play_list_type") != null && !string.IsNullOrEmpty(generateTag.Attribute("play_list_type").Value) ? (PlayListType)int.Parse(generateTag.Attribute("play_list_type").Value) : PlayListType.Classic);

            //generateTag.SetAttributeValue("auto_link", "No");
            //generateTag.SetAttributeValue("comment", "");
            //generateTag.SetAttributeValue("file_date", DateTime.Now.ToString("ddMMyyyy"));
            //generateTag.SetAttributeValue("origin", "Piko Traffic Manager");
            //generateTag.SetAttributeValue("play_list_title", block.Data.Title);
            //generateTag.SetAttributeValue("play_list_type", "block");
            List <PlaylistElementData> elementsData = new List <PlaylistElementData>();

            foreach (XElement playListElement in result.Elements("Event"))
            {
                PlaylistElementData elementData = new PlaylistElementData();
                elementData.Duration = playListElement.Attribute("event_duration") != null &&
                                       !string.IsNullOrEmpty(playListElement.Attribute("event_duration").Value) ? (uint)int.Parse(playListElement.Attribute("event_duration").Value) : (uint)0;
                elementData.FileName = playListElement.Attribute("event_file_name_id") != null &&
                                       !string.IsNullOrEmpty(playListElement.Attribute("event_file_name_id").Value) ? playListElement.Attribute("event_file_name_id").Value : "";
                elementData.Repeat = playListElement.Attribute("event_repeat") != null &&
                                     !string.IsNullOrEmpty(playListElement.Attribute("event_repeat").Value) ? bool.Parse(playListElement.Attribute("event_repeat").Value) : false;
                elementData.Title = playListElement.Attribute("event_title") != null &&
                                    !string.IsNullOrEmpty(playListElement.Attribute("event_title").Value) ? playListElement.Attribute("event_title").Value : "";
                List <PlaylistElementSecondaryEventData> listSecData = new List <PlaylistElementSecondaryEventData>();
                if (playListElement.Elements("Event").Count() > 0)
                {
                    foreach (XElement secondaryElement in playListElement.Elements("Event"))
                    {
                        PlaylistElementSecondaryEventData secData = new PlaylistElementSecondaryEventData();
                        secData.Duration = secondaryElement.Attribute("sec_evt_duration") != null &&
                                           !string.IsNullOrEmpty(secondaryElement.Attribute("sec_evt_duration").Value) ? (uint)int.Parse(secondaryElement.Attribute("sec_evt_duration").Value) : (uint)0;
                        secData.ExtendedParam = secondaryElement.Attribute("sec_evt_ext_param") != null &&
                                                !string.IsNullOrEmpty(secondaryElement.Attribute("sec_evt_ext_param").Value) ? secondaryElement.Attribute("sec_evt_ext_param").Value : "";
                        secData.Id = secondaryElement.Attribute("sec_evt_id") != null &&
                                     !string.IsNullOrEmpty(secondaryElement.Attribute("sec_evt_id").Value) ? int.Parse(secondaryElement.Attribute("sec_evt_id").Value) : (int)0;
                        secData.Param = secondaryElement.Attribute("sec_evt_ext_param") != null &&
                                        !string.IsNullOrEmpty(secondaryElement.Attribute("sec_evt_ext_param").Value) ? secondaryElement.Attribute("sec_evt_ext_param").Value : "";
                        secData.TcOffsetType = secondaryElement.Attribute("sec_evt_tc_offset_type") != null &&
                                               !string.IsNullOrEmpty(secondaryElement.Attribute("sec_evt_tc_offset_type").Value) ? (uint)int.Parse(secondaryElement.Attribute("sec_evt_tc_offset_type").Value) : (uint)0;
                        secData.SecondaryEventType = secondaryElement.Attribute("sec_evt_type") != null &&
                                                     !string.IsNullOrEmpty(secondaryElement.Attribute("sec_evt_type").Value) ? secondaryElement.Attribute("sec_evt_type").Value : "";
                        listSecData.Add(secData);
                    }
                }
                elementData.SecondaryEvents = listSecData.ToArray();
                elementsData.Add(elementData);
            }
            data.Elements = elementsData.ToArray();
            return(data);
        }
示例#23
0
 /// <summary>
 /// Checks whether a given playlist contains a given track.
 /// </summary>
 /// <param name="playlist">The playlist to search in</param>
 /// <param name="track">The track to search for</param>
 /// <returns>True of <paramref name="playlist"/> contains <paramref name="track"/>, otherwise false</returns>
 public static bool Contains(PlaylistData playlist, TrackData track)
 {
     foreach (TrackData t in playlist.Tracks)
     {
         if (t.Path == track.Path)
         {
             return(true);
         }
     }
     return(false);
 }
示例#24
0
        public void GetPlaylistFromYoutube(string playlistName, string playlistUrl)
        {
            PlaylistData p = new PlaylistData(playlistName);

            p.GetFromYoutube_OnThread(playlistUrl);
            p.playlistTitle = playlistName;
            p.SaveToFile();

            AddPlaylist(p);
            MainWindow.instance.ShowPlaylistVideos(p);
        }
示例#25
0
        public void SavePlaylist(MusicPage musicPage, string Name)
        {
            var fs        = new FileStream(Name, FileMode.Create);
            var formatter = new BinaryFormatter();
            var data      = new PlaylistData(musicPage);

            formatter.Serialize(fs, data);
            fs.Close();
            fs = new FileStream(Name, FileMode.Open);
            fs.Close();
        }
示例#26
0
 /// <summary>
 /// Invoked when the user clicks "Share" in playlist context menu.
 /// </summary>
 /// <param name="sender">The sender of the event</param>
 /// <param name="e">The event data</param>
 public void SharePlaylist_Clicked(object sender, RoutedEventArgs e)
 {
     foreach (TreeViewItem tvi in GetCurrentItems())
     {
         PlaylistData pld = Tvi2Pl(tvi);
         if (pld != null)
         {
             ServiceManager.SharePlaylist(pld);
         }
     }
 }
 public PlaylistData LoadPlaylist(string playlistId)
 {
     try
     {
         PlaylistData xmlPlayList = PikoXML.LoadXML(System.IO.Path.Combine(PikoDataServiceApp.PikoPlaylistPath, playlistId + ".xml"));
         return(xmlPlayList);
     }
     catch
     {
         return(null);
     }
 }
示例#28
0
 private void UpdatePlaylist(PlaylistData playlist, int index, bool closeMedia)
 {
     SafeCall(() =>
     {
         if (closeMedia)
         {
             Media.Close();
             Player.ClearScreen();
         }
         PlaylistForm.UpdatePlaylist(playlist, index, closeMedia);
     });
 }
示例#29
0
        void UpdatePlaylist(IDataService service, PlaylistData playlistData)
        {
            var playlistItems = new ObservableCollection <PlaylistItemViewModel>();

            foreach (var item in playlistData.Items)
            {
                playlistItems.Add(new PlaylistItemViewModel(item));
            }
            this._playlistData = playlistData;
            this.PlaylistItems = playlistItems;
            this.UpdateVideoInfo(service, playlistData);
        }
示例#30
0
        public void DeletePlaylist(string name)
        {
            string       fileName = GetPlaylistPath(name);
            PlaylistData data     = playlistData.First(p => p.playlistName == name);

            playlistData.Remove(data);
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            SavePlaylistData();
        }
示例#31
0
    void Ready()
    {
        PlaylistData data = Data.Instance.triviaData.data;

        foreach (PlaylistData.VideoData d in data.playlist)
        {
            QuestionLine line = Instantiate(qline);
            line.transform.SetParent(container);
            line.Init(d, OnClicked);
            line.transform.transform.localScale = Vector3.one;
        }
    }
示例#32
0
        private async Task<PlaylistData> identifyDataFromLink(String link)
        {
            PlaylistData plist = new PlaylistData();

            try
            {
                WebClient client = new WebClient();
                String html = "";
                var xhtml = new HtmlAgilityPack.HtmlDocument();

                html = await client.DownloadStringTaskAsync(link);
                xhtml.LoadHtml(html);

                if (link.IndexOf("&list") > -1 || link.IndexOf("playlist") > -1)
                {
                    var div = xhtml.DocumentNode.DescendantNodes().Where(h => h.Name == "div" && h.Attributes.Any(attr => attr.Value == "playlist-header-content")).FirstOrDefault();

                    if(div != null)
                    {
                        plist.name = div.Attributes.FirstOrDefault(a => a.Name == "data-list-title").Value;
                    }
                }
                else
                {
                    var span = xhtml.DocumentNode.DescendantNodes().Where(h => h.Name == "span" && h.Attributes.Any(attr => attr.Value.Equals("eow-title"))).FirstOrDefault();

                    if (span != null)
                        plist.name = span.InnerHtml.Replace("\n", "").TrimStart().TrimEnd();
                }

                plist.length = "0";
                client.Dispose();

                return plist;
            }
            catch (Exception err)
            {
                LogError("Error: identifySongFromLink() - " + err.StackTrace + "\n\n" + err.Message + "\nlink: " + link);
                return plist;
            }
        }
示例#33
0
        /// <summary>
        /// Remove a playlist from the search box's context menu
        /// </summary>
        /// <param name="playlist">The playlist to be removed</param>
        public void RemovePlaylist(PlaylistData playlist)
        {
            // remove from "add to playlist" menu in list
            List<MenuItem> menu_items_to_remove = new List<MenuItem>();
            foreach (MenuItem item in Menu_Add.Items)
            {
                if (item.Header.ToString() == playlist.Name)
                    menu_items_to_remove.Add(item);
            }
            foreach (MenuItem item in menu_items_to_remove)
                Menu_Add.Items.Remove(item);

            // remove from "remove from playlist" menu in list
            menu_items_to_remove.Clear();
            foreach (MenuItem item in Menu_Remove.Items)
            {
                if (item.Header.ToString() == playlist.Name)
                    menu_items_to_remove.Add(item);
            }
            foreach (MenuItem item in menu_items_to_remove)
                Menu_Remove.Items.Remove(item);

            if (SettingsManager.Playlists.Count <= 0)
                Menu_Remove.IsEnabled = false;
        }
示例#34
0
        /// <summary>
        /// Add a new playlist to the search box's context menu
        /// </summary>
        /// <param name="playlist">The playlist to be added</param>
        public void AddPlaylist(PlaylistData playlist)
        {
            // create the menu item in "Add to Playlist" in list
            MenuItem ListAddMenu = new MenuItem();
            ListAddMenu.Header = playlist.Name;
            ListAddMenu.Click += AddToPlaylist_Clicked;
            Menu_Add.Items.Insert(Menu_Add.Items.Count - 1, ListAddMenu);

            // create the menu item in "Remove from Playlist" in list
            MenuItem ListDelMenu = new MenuItem();
            ListDelMenu.Header = playlist.Name;
            ListDelMenu.Click += RemoveFromPlaylist_Clicked;
            Menu_Remove.Items.Insert(Menu_Remove.Items.Count, ListDelMenu);

            Menu_Remove.IsEnabled = true;
        }
示例#35
0
        private async Task proxy(Socket accSock)
        {
            WebClient client = new WebClient();
            HtmlAgilityPack.HtmlDocument xhtml = new HtmlAgilityPack.HtmlDocument();
            Byte[] requbytes = new Byte[8192];
            Byte[] image = null;
            List<Byte> respbs = new List<Byte>();
            List<Byte> requbs = new List<Byte>();
            List<PlaylistData> plistdata = new List<PlaylistData>(); 
            Int32 recvd = -1;
            Int32 start = -1;
            Int32 len = -1;
            String remoteip = ((accSock.RemoteEndPoint is IPEndPoint) ? ((IPEndPoint)accSock.RemoteEndPoint).Address.ToString() : null);
            //StringBuilder responseHeaders = new StringBuilder("HTTP/1.1 200 OK\r\nAccess-Control-Allow-Origin: *\r\nContent-type: text/html\r\n");
            StringBuilder responseHeaders = new StringBuilder("HTTP/1.1 200 OK\r\nAccess-Control-Allow-Origin: *\r\n");
            String link = "";
            String request = "";
            String html = "";
            Boolean overrideResp = false;

            try
            {
                if (!String.IsNullOrEmpty(remoteip))
                    LogHttpReq("\nIpaddress: " + remoteip + "\n");

                if (await waitForDataToBecomeAvailable(2000, accSock))
                {
                    do
                    {
                        recvd = accSock.Receive(requbytes); //Allow for biiger msgs than 8k to be returned
                        request += Encoding.ASCII.GetString(requbytes).Substring(0, recvd);
                        requbs.AddRange(requbytes);
                    }
                    while (accSock.Available > 0);

                    if ((start = request.IndexOf("/proxySrch*")) > -1)
                    {
                        if ((start = request.IndexOf('*')) > -1)
                        {
                            if ((len = request.IndexOf("%7C")) > -1)
                            {
                                link = request.Substring(start+1, (len - start -1));
                                html = await client.DownloadStringTaskAsync(string.Format("https://www.youtube.com/results?search_query={0}", link).Replace(" ", "+"));
                                xhtml.LoadHtml(html);

                                if (xhtml.DocumentNode != null)
                                {
                                    if (xhtml.DocumentNode.OuterHtml != null)
                                    {
                                        foreach (var node in xhtml.DocumentNode.DescendantNodes().Where(h => h.Attributes != null && h.Attributes.Any(attr => attr.Value.Equals("yt-lockup-dismissable"))))
                                        {
                                            foreach (var subnode in node.DescendantNodes())
                                            {
                                                PlaylistData tmp = new PlaylistData();
                                                Boolean abandonsearch = false;
                                                //FIX ALL ALGORITHMS SO IT LOOPS 1NCE THRU EVERYTHING
                                                if(subnode.Attributes.Any(attr => attr.Value == "yt-uix-sessionlink yt-uix-tile-link yt-ui-ellipsis yt-ui-ellipsis-2       spf-link "))
                                                {
                                                    if (node.DescendantNodes().FirstOrDefault(span => span.Attributes.Any(attr => attr.Value == "yt-uix-tooltip yt-channel-title-icon-verified yt-sprite")) != null)
                                                    {
                                                        continue;
                                                    }

                                                    tmp.name = subnode.InnerHtml;   
                                                    tmp.link = subnode.Attributes["href"].Value;

                                                    foreach (var subnodeII in node.ChildNodes[0].ChildNodes[0].ChildNodes)
                                                    {
                                                        if(subnodeII.Name == "span")
                                                        {
                                                            if (subnodeII.InnerHtml.IndexOf(":") > -1)
                                                            {
                                                                tmp.length = subnodeII.InnerHtml;
                                                                break;
                                                            }     
                                                            else
                                                            {
                                                                abandonsearch = true;
                                                                break;
                                                            }
                                                        }

                                                        if (subnodeII.Name == "div" && subnodeII.FirstChild != null && subnodeII.FirstChild.FirstChild != null && subnodeII.FirstChild.FirstChild.Attributes.Any(attr => attr.Name == "src"))
                                                        {
                                                            tmp.protectedVid = (subnodeII.FirstChild.FirstChild.Attributes["src"].Value.IndexOf(".jpg") > -1);
                                                        }
                                                    }

                                                    if(abandonsearch)
                                                    {
                                                        abandonsearch = false;
                                                        continue;
                                                    }

                                                    if(!String.IsNullOrEmpty(tmp.length))
                                                    {
                                                        plistdata.Add(tmp);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        if(plistdata.Any())
                        {
                            StringBuilder execcode = new StringBuilder("plistdata = [");
                            PlaylistData data;

                            for (var i = 0; i < plistdata.Count; i++)
                            {
                                data = plistdata[i];

                                execcode.Append("{ link: '");
                                execcode.Append(data.link);
                                execcode.Append("', name: '");
                                execcode.Append(data.name.Replace("\n", "").Replace("\t", ""));                             
                                execcode.Append("', length: '");
                                execcode.Append(data.length.Replace("\n", "").Replace("\t", ""));
                                execcode.Append("', protectedVid: ");
                                execcode.Append(data.protectedVid.ToString().ToLower());
                                execcode.Append(" },");
                            }

                            execcode.Remove((execcode.Length - 1), 1);
                            execcode.Append("]; showData();");

                            responseHeaders.Append("Content-Length: ");
                            responseHeaders.Append(execcode.Length);
                            responseHeaders.Append("\r\n\r\n");

                            accSock.Send(Encoding.ASCII.GetBytes(responseHeaders.ToString() + execcode));
                            return;
                        
                        }
                    }
                    else if ((start = request.IndexOf("/proxy*")) > -1)
                    {
                        if (request.IndexOf("referer") < start)
                        {
                            String referer = "";

                            start += 7;

                            if (request.IndexOf("proxy**") > -1)
                            {
                                start++;
                                len = (request.IndexOf("HTTP/1.1") - 13);
                            }
                            else if (request.IndexOf('|', start) > -1)
                                len = request.IndexOf('|', start) - start;
                            else if (request.IndexOf("%7C", start) > -1)
                                len = request.IndexOf("%7C", start) - start;

                            link = request.Substring(start, len);

                           var begin = request.IndexOf("Referer: ") + "Referer: ".Length;
                            var end = request.IndexOf('\n', begin);

                            referer = request.Substring(begin, (end - begin - 1));
                           request = request.Replace(referer, "http://www.youtube.com");
                        }
                        else
                        {
                            start = request.IndexOf(":8083/") + 6;
                            len = request.IndexOf(" HTTP/1.1") - start;
                            link = request.Substring(start, len);
                        }
                    }
                    else
                    {
                        start = 4;
                        len = request.IndexOf(" HTTP/1.1") - start;
                        link = request.Substring(start, len);
                    }

                    if (link.IndexOf("://") < 0)
                    {
                        link = "http://www.youtube.com" + link;
                        link = link.Replace(" ", "");
                    }

                    LogHttpReq(request);

                    if (request.IndexOf("text") > -1 && request.IndexOf("Accept: image") == -1 || ((request.IndexOf("Accept") == -1 || request.IndexOf("Accept: */*") > -1) && request.IndexOf("Content-type") == -1))
                    {
                        ServicePointManager.ServerCertificateValidationCallback = delegate
                        {
                            return true;
                        };

                        if (request.IndexOf("GET ") == 0)
                        {
                            //if (request.IndexOf("video/webm") > -1)
                                //request = request.Replace("video/webm", "audio/mp4");

                            //client.UseDefaultCredentials = true;                            
                            {
                                var headers = request.Split(new string[] 
                                {
                                    "\r\n"
                                }, 100, StringSplitOptions.None);

                                //for(var i = 1; i < headers.) parse headers and to client.headers

                                html = await client.DownloadStringTaskAsync(link);
                                //html = await httpRequest(accSock, 1, request, link);

                                if (html.IndexOf("//s.ytimg.com/yts/jsbin/html5player-new-en_US-vflSnomqH/html5player-new.js") > -1)
                                {
                                    overrideResp = true;
                                    html = html.Replace("//s.ytimg.com/yts/jsbin/html5player-new-en_US-vflSnomqH/html5player-new.js", "https://" + setting.IpAddress + ":8083/proxy**http://s.ytimg.com/yts/jsbin/html5player-new-en_US-vflSnomqH/html5player-new.js");
                                }

                                if (html.IndexOf("//s.ytimg.com/yts/jsbin/spf-vflVcVpX_/spf.js") > -1)
                                {
                                    overrideResp = true;
                                    html = html.Replace("//s.ytimg.com/yts/jsbin/spf-vflVcVpX_/spf.js", "https://" + setting.IpAddress + ":8083/proxy**http://s.ytimg.com/yts/jsbin/spf-vflVcVpX_/spf.js?");
                                }

                                if (html.IndexOf("//s.ytimg.com/yts/jsbin/www-en_US-vflENJpqL/base.js") > -1)
                                {
                                    overrideResp = true;
                                    html = html.Replace("//s.ytimg.com/yts/jsbin/www-en_US-vflENJpqL/base.js", "https://" + setting.IpAddress + ":8083/proxy**http://s.ytimg.com/yts/jsbin/www-en_US-vflENJpqL/base.js");
                                }

                                if (link.IndexOf("html5player-new.js") > -1 || link.IndexOf("base.js") > -1 || link.IndexOf("spf.js") > -1)
                                {
                                    overrideResp = true;
                                    html = html.Replace("l.send(d)", "l.send('http://" + setting.IpAddress + ":8083/proxy*' + d + '|')");
                                    html = html.Replace("this.j.open(\"GET\",a);", "this.j.open(\"GET\", 'http://" + setting.IpAddress + ":8083/proxy*' + a + '|');");
                                }

                                if (request.IndexOf("GET /proxy*http://www.youtube.com") > -1 || request.IndexOf("GET /results?search_query=") > -1)
                                {
                                    html = html.Replace("</body></html>", "");
                                    html += proxyjs;
                                }

                                xhtml.LoadHtml(html);
                            }
                        }
                        else
                        {
                            String postData = request.Substring(request.IndexOf("\r\n\r\n")+4);

                            LogDebug("link for POST call..." + link + " and POST data " + postData);

                            html = client.UploadString(link, postData);
                            xhtml.LoadHtml(html);
                        }
                    }

                    if (xhtml.DocumentNode != null)
                    {
                        if (xhtml.DocumentNode.OuterHtml != null)
                        {
                            foreach (var node in xhtml.DocumentNode.DescendantNodes().Where(h => (h.Name == "a") || h.Name == "link"))
                            {
                                foreach (var attr in node.Attributes.Where(h => h.Name == "href"))
                                {
                                    if (attr.Value.IndexOf("http://") == -1 && attr.Value.IndexOf("https://") == -1)
                                        if (attr.Value.IndexOf(".com") == -1)
                                            attr.Value = "http://www.youtube.com" + attr.Value;
                                        else
                                            attr.Value = "http:" + attr.Value;

                                    attr.Value = "http://" + setting.IpAddress + ":8083/proxy*" + attr.Value + "|";
                                }
                            }

                            foreach (var node in xhtml.DocumentNode.DescendantNodes().Where(h => (h.Name == "img")))
                            {
                                foreach (var attr in node.Attributes.Where(h => h.Name == "src"))
                                {
                                    if (attr.Value.IndexOf("http://") == -1 && attr.Value.IndexOf("https://") == -1)
                                        if (attr.Value.IndexOf(".com") == -1)
                                            attr.Value = "http://www.youtube.com" + attr.Value;
                                        else
                                            attr.Value = "http:" + attr.Value;

                                    attr.Value = "http://" + setting.IpAddress + ":8083/proxy*" + attr.Value + "|";
                                }
                            }

                            //if (!client.ResponseHeaders.AllKeys.Contains("Transfer-Encoding"))
                            //{
                                responseHeaders.Append("Content-Length: ");
                                responseHeaders.Append(xhtml.DocumentNode.OuterHtml.Length);
                                responseHeaders.Append("\r\n");
                            //}

                            foreach(var header in client.ResponseHeaders.AllKeys)
                            {
                                if (responseHeaders.ToString().IndexOf(header + ":") == -1 && ((header != "Transfer-Encoding") && (header != "X-XSS-Protection") && (header != "P3P")))
                                {
                                    responseHeaders.Append(header + ": ");
                                    responseHeaders.Append(client.ResponseHeaders[header]);
                                    responseHeaders.Append("\r\n");
                                }
                            }
                            
                            responseHeaders.Append("\r\n");

                            if (!overrideResp)
                            {
                                accSock.Send(Encoding.ASCII.GetBytes(responseHeaders.ToString() + xhtml.DocumentNode.OuterHtml));
                            }
                            else
                            {
                                respbs.InsertRange(0, Encoding.ASCII.GetBytes(responseHeaders.ToString()));
                                //respbs.AddRange(await client.DownloadDataTaskAsync(link));
                                var bs = await httpRequest(1, request, link);
                                accSock.Send(respbs.ToArray());
                            }

                            System.Threading.Thread.Sleep(100);
                            accSock.Close();
                           // accSock.Shutdown(SocketShutdown.Both);
                        }
                        else
                        {
                            responseHeaders.Append("Content-Length: ");
                            responseHeaders.Append(html.Length);
                            responseHeaders.Append("\r\n");

                            foreach (var header in client.ResponseHeaders.AllKeys)
                            {
                                if (responseHeaders.ToString().IndexOf(header + ":") == -1)
                                {
                                    responseHeaders.Append(header + ": ");
                                    responseHeaders.Append(client.ResponseHeaders[header]);
                                    responseHeaders.Append("\r\n");
                                }
                            }
                            
                            responseHeaders.Append("\r\n");

                            accSock.Send(Encoding.ASCII.GetBytes(responseHeaders.ToString() + html));
                            System.Threading.Thread.Sleep(100);
                            accSock.Close();
                            //accSock.Shutdown(SocketShutdown.Both);
                        }
                    }
                    else
                    {
                        image = await client.DownloadDataTaskAsync(link);
                        responseHeaders.AppendFormat("{0}{1}{2}", "Content-Length: ", image.Length, "\r\n\r\n");
                        respbs.AddRange(Encoding.ASCII.GetBytes(responseHeaders.ToString()));
                        respbs.AddRange(image);
                        accSock.Send(respbs.ToArray());
                        System.Threading.Thread.Sleep(100);
                        //accSock.Shutdown(SocketShutdown.Both);
                        accSock.Close();
                    }

                    client.Dispose();
                    accSock.Dispose();
                }
            }
            catch (Exception err)
            {
                if (accSock.Connected)
                {
                    accSock.Shutdown(SocketShutdown.Both);
                    accSock.Close();
                    accSock.Dispose();
                }

                LogError("\nProxy error: " + err.Message + "\n\n" + err.StackTrace + "\n\n" + request);
            }
        }
示例#36
0
        /// <summary>
        /// Uploads a playlist to the cloud.
        /// </summary>
        /// <param name="playlist">The playlist to upload</param>
        private static void UploadPlaylist(PlaylistData playlist)
        {
            if (playlist == null) return;

            JArray tracks = new JArray();
            foreach (TrackData track in playlist.Tracks)
            {
                JObject json = TrackToJSON(track);
                if (json != null)
                    tracks.Add(json);
            }

            JObject para = new JObject();
            para["name"] = OAuth.Manager.UrlEncode(playlist.Name);
            para["is_public"] = "0";
            para["songs"] = tracks;

            syncOutBuffer.Add(new SyncOperation("create", "playlists", para));

            InitiateSyncTimer();
        }
示例#37
0
        /// <summary>
        /// Shares a playlist.
        /// </summary>
        /// <param name="playlist">The playlist to share</param>
        public static void SharePlaylist(PlaylistData playlist)
        {
            ThreadStart shareThread = delegate()
            {
                string query = String.Format("?playlist={0}&object=playlist",
                        OAuth.Manager.UrlEncode(playlist.Name));
                var response = SendRequest("/shares.json", "POST", query);

                if (response == null || response.StatusCode != HttpStatusCode.Created)
                {
                    U.L(LogLevel.Error, "SERVICE", "There was a problem sharing playlist");
                    U.L(LogLevel.Error, "SERVICE", response);
                }
                else
                {
                    U.L(LogLevel.Information, "SERVICE", "Shared playlist successfully");
                }
                if (response != null) response.Close();
            };
            Thread sharethread = new Thread(shareThread);
            sharethread.Name = "Share thread";
            sharethread.Priority = ThreadPriority.Lowest;
            sharethread.Start();
        }
示例#38
0
        /// <summary>
        /// Creates a playlist track list and navigation items
        /// </summary>
        /// <param name="playlist">The data for the playlist to create</param>
        /// <param name="select">Whether to select the playlist after it has been created</param>
        private void CreatePlaylist(PlaylistData playlist, bool select = true)
        {
            Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate()
            {
                if (playlist.ListConfig == null)
                {
                    ViewDetailsConfig vdc = SettingsManager.CreateListConfig();
                    SettingsManager.InitViewDetailsConfig(vdc);
                    vdc.HasNumber = true;
                    vdc.Sorts.Add("asc:Title");
                    vdc.Sorts.Add("asc:Track");
                    vdc.Sorts.Add("asc:Album");
                    vdc.Sorts.Add("asc:Artist");

                    if (SettingsManager.SearchPolicy == SearchPolicy.Global)
                        vdc.Filter = SettingsManager.FileListConfig.Filter;
                    else if (SettingsManager.SearchPolicy == SearchPolicy.Partial && SettingsManager.Playlists.Count > 1)
                        vdc.Filter = SettingsManager.Playlists[0].ListConfig.Filter;

                    playlist.ListConfig = vdc;
                }

                PlaylistTrackLists.Add(playlist.Name, null);
                playlist.Tracks.CollectionChanged +=
                    new NotifyCollectionChangedEventHandler(PlaylistTracks_CollectionChanged);

                // create the item in the navigation tree
                TreeViewItem item = new TreeViewItem();
                item.Selected += NavigationPane.Playlist_Selected;
                item.Drop += NavigationPane.Playlist_Drop;
                item.KeyDown += NavigationPlaylist_KeyDown;
                item.Tag = playlist.Name;
                item.Padding = new Thickness(8, 0, 0, 0);
                item.HorizontalAlignment = HorizontalAlignment.Stretch;
                item.HorizontalContentAlignment = HorizontalAlignment.Stretch;

                DockPanel dp = new DockPanel();
                dp.LastChildFill = false;
                dp.HorizontalAlignment = HorizontalAlignment.Stretch;

                Image img = new Image();
                img.Source = Utilities.GetIcoImage("pack://application:,,,/Platform/Windows 7/GUI/Images/Icons/DiscAudio.ico", 16, 16);
                img.Width = 16;
                img.Height = 16;
                img.Style = (Style)TryFindResource("HandHover");
                dp.Children.Add(img);

                EditableTextBlock etb = new EditableTextBlock();
                etb.EnteredEditMode += new EventHandler(EditableTextBlock_EnteredEditMode);
                etb.Text = playlist.Name;
                etb.Margin = new Thickness(5, 0, 5, 0);
                etb.Edited += NavigationPane.Playlist_Edited;
                etb.Canceled += NavigationPane.Playlist_Canceled;
                etb.HandHover = true;
                dp.Children.Add(etb);

                Image simg = new Image();
                simg.Source = Utilities.GetIcoImage("pack://application:,,,/Platform/Windows 7/GUI/Images/Icons/Search.ico", 16, 16);
                simg.Width = 16;
                simg.Height = 16;
                simg.Margin = new Thickness(5, 0, 5, 0);
                simg.Visibility = Visibility.Collapsed;
                DockPanel.SetDock(simg, Dock.Right);
                dp.Children.Add(simg);

                item.Header = dp;
                item.ContextMenuOpening += new ContextMenuEventHandler(NavigationPane.Playlist_ContextMenuOpening);
                item.ContextMenuClosing += new ContextMenuEventHandler(NavigationPane.Playlist_ContextMenuClosing);
                item.ContextMenu = NavigationPane.playlistMenu;
                NavigationPane.Playlists.Items.Insert(NavigationPane.Playlists.Items.Count - 1, item);
                if (select)
                    item.Focus();

                // create list context menu items
                MenuItem miAdd = new MenuItem();
                miAdd.Header = playlist.Name;
                miAdd.Click += new RoutedEventHandler(listMenuAddToPlaylist_Click);
                listMenuAddToPlaylist.Visibility = System.Windows.Visibility.Visible;
                listMenuAddToPlaylist.Items.Insert(listMenuAddToPlaylist.Items.Count - 1, miAdd);

                MenuItem miDel = new MenuItem();
                miDel.Header = playlist.Name;
                miDel.Click += new RoutedEventHandler(listMenuRemoveFromPlaylist_Click);
                listMenuRemoveFromPlaylist.Visibility = System.Windows.Visibility.Visible;
                listMenuRemoveFromPlaylist.Items.Add(miDel);

                PlaybackControls.Search.AddPlaylist(playlist);

                NavigationPane.SetSearchIndicator("Playlist:" + playlist.Name, playlist.ListConfig);
            }));
        }