Ejemplo n.º 1
0
    private void SavePlayList()
    {
      string strNewFileName = playlistPlayer.CurrentPlaylistName;
      if (GetKeyboard(ref strNewFileName))
      {
        string strPath = Path.GetFileNameWithoutExtension(strNewFileName);
        string strPlayListPath = string.Empty;
        using (Profile.Settings xmlreader = new Profile.MPSettings())
        {
          strPlayListPath = xmlreader.GetValueAsString("music", "playlists", string.Empty);
          strPlayListPath = Util.Utils.RemoveTrailingSlash(strPlayListPath);
        }

        strPath += ".m3u";
        if (strPlayListPath.Length != 0)
        {
          strPath = strPlayListPath + @"\" + strPath;
        }
        PlayList playlist = new PlayList();
        for (int i = 0; i < facadeLayout.Count; ++i)
        {
          GUIListItem pItem = facadeLayout[i];
          PlayListItem newItem = new PlayListItem();
          newItem.FileName = pItem.Path;
          newItem.Description = pItem.Label;
          newItem.Duration = pItem.Duration;
          newItem.Type = PlayListItem.PlayListItemType.Audio;
          playlist.Add(newItem);
        }
        IPlayListIO saver = new PlayListM3uIO();
        saver.Save(playlist, strPath);
      }
    }
    private void OnSavePlayList()
    {
      currentSelectedItem = facadeLayout.SelectedListItemIndex;
      string playlistFileName = string.Empty;
      if (GetKeyboard(ref playlistFileName))
      {
        string playListPath = string.Empty;
        using (Profile.Settings xmlreader = new Profile.MPSettings())
        {
          playListPath = xmlreader.GetValueAsString("movies", "playlists", string.Empty);
          playListPath = Util.Utils.RemoveTrailingSlash(playListPath);
        }

        string fullPlayListPath = Path.GetFileNameWithoutExtension(playlistFileName);

        fullPlayListPath += ".m3u";
        if (playListPath.Length != 0)
        {
          fullPlayListPath = playListPath + @"\" + fullPlayListPath;
        }
        PlayList playlist = new PlayList();
        for (int i = 0; i < facadeLayout.Count; ++i)
        {
          GUIListItem listItem = facadeLayout[i];
          PlayListItem playListItem = new PlayListItem();
          playListItem.FileName = listItem.Path;
          playListItem.Description = listItem.Label;
          playListItem.Duration = listItem.Duration;
          playListItem.Type = PlayListItem.PlayListItemType.Video;
          playlist.Add(playListItem);
        }
        PlayListM3uIO saver = new PlayListM3uIO();
        saver.Save(playlist, fullPlayListPath);
      }
    }
Ejemplo n.º 3
0
    public override void DeInit()
    {
      GUIWindowManager.Receivers -= new SendMessageHandler(this.OnThreadMessage);
      GUIWindowManager.OnNewAction -= new OnActionHandler(this.OnNewAction);

      if (_lastRequest != null)
      {
        ascrobbler.RemoveRequest(_lastRequest);
      }

      // Save the default Playlist
      if (_savePlaylistOnExit)
      {
          Log.Info("Playlist: Saving default playlist {0}", _defaultPlaylist);
          IPlayListIO saver = new PlayListM3uIO();
          PlayList playlist = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_MUSIC);
          PlayList playlistTmp = new PlayList();
          // Sort out Playlist Items residing on a CD, as they are gonna most likely to change
          foreach (PlayListItem item in playlist)
          {
              if (Path.GetExtension(item.FileName) != ".cda")
              {
                  playlistTmp.Add(item);
              }
          }

          if (playlistTmp.Count > 0)
          {
              saver.Save(playlistTmp, Path.Combine(_playlistFolder, _defaultPlaylist));
          }
      }

      base.DeInit();
    }
Ejemplo n.º 4
0
        /// <summary>
        /// Save the current playlist to file
        /// </summary>
        /// <param name="name">Name of new playlist</param>
        internal static void SaveCurrentPlaylist(string name)
        {
            try
            {
                using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
                {
                    string playlistFolder = reader.GetValueAsString("music", "playlists", "");

                    if (!Path.IsPathRooted(playlistFolder))
                    {
                        playlistFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), playlistFolder);
                    }

                    PlayListPlayer playListPlayer = PlayListPlayer.SingletonPlayer;
                    PlayList playList = playListPlayer.GetPlaylist(playListPlayer.CurrentPlaylistType);

                    String fileName = Path.Combine(playlistFolder, name + ".m3u");

                    PlayListM3uIO m3uPlayList = new PlayListM3uIO();
                    m3uPlayList.Save(playList, fileName);

                }
            }
            catch (Exception ex)
            {
                WifiRemote.LogMessage("Error saving playlist: " + ex.ToString(), WifiRemote.LogType.Warn);
            }
        }