private void GeneratePlaylist(DirectoryInfo dir, bool recursive, bool shuffle)
    {
        this.Response.Buffer      = false;
        this.Response.ContentType = "application/xspf+xml";

        // Allow caching of the non-shuffled playlists.
        // Shuffled ones should be cached because they change every time.
        // Note: since v. 2.0 we have stopped generating shuffled lists
        // and instead generated regular lists and tell the player to do
        // shuffling on its own.
        this.Response.Cache.SetCacheability(shuffle ? HttpCacheability.NoCache : HttpCacheability.Private);
        //if (!shuffle)
        //    this.Response.Cache.SetLastModified(dir.LastAccessTime);

        PlaylistType playlist = new PlaylistType();

        this.RenderPlaylistHeader(dir, playlist);

        List <FileInfo> mediaFiles = new List <FileInfo>();

        UtilityMethods.FindMediaFiles(mediaFiles, dir, recursive);
        this.RenderPlaylistTracks(mediaFiles, playlist, shuffle);

        this.Response.ContentEncoding = System.Text.ASCIIEncoding.UTF8;
        XmlSerializer ser = new XmlSerializer(playlist.GetType());

        ser.Serialize(this.Response.Output, playlist);
    }
示例#2
0
    private void GeneratePlaylist(DirectoryInfo dir, bool recursive, bool shuffle)
    {
        this.Response.Buffer      = false;
        this.Response.ContentType = "application/xspf+xml";
        this.Response.Cache.SetCacheability(shuffle ? HttpCacheability.NoCache : HttpCacheability.Private);
        //if (!shuffle)
        //    this.Response.Cache.SetLastModified(dir.LastAccessTime);

        PlaylistType playlist = new PlaylistType();

        this.RenderPlaylistHeader(dir, playlist);

        List <FileInfo> mediaFiles = new List <FileInfo>();

        FindMediaFiles(mediaFiles, dir, recursive);
        this.RenderPlaylistTracks(mediaFiles, playlist, shuffle);

        this.Response.ContentEncoding = System.Text.ASCIIEncoding.UTF8;
        XmlSerializer ser = new XmlSerializer(playlist.GetType());

        ser.Serialize(this.Response.Output, playlist);
    }