Exemplo n.º 1
0
        public List <Playlist> GetPlaylists()
        {
            List <Playlist> playlists = new List <Playlist> ();

            IntPtr ptr = Playlist.LIBMTP_Get_Playlist_List(Handle);

            while (ptr != IntPtr.Zero)
            {
                PlaylistStruct d = (PlaylistStruct)Marshal.PtrToStructure(ptr, typeof(PlaylistStruct));
                playlists.Add(new Playlist(this, d));
                ptr = d.next;
            }

            return(playlists);
        }
Exemplo n.º 2
0
        internal static List <Playlist> GetPlaylists(MtpDevice device)
        {
            List <Playlist> playlists = new List <Playlist> ();
            IntPtr          ptr       = Playlist.LIBMTP_Get_Playlist_List(device.Handle);

            while (ptr != IntPtr.Zero)
            {
                // Destroy the struct *after* we use it to ensure we don't access freed memory
                // for the 'tracks' variable
                PlaylistStruct d = (PlaylistStruct)Marshal.PtrToStructure(ptr, typeof(PlaylistStruct));
                playlists.Add(new Playlist(device, d));
                LIBMTP_destroy_playlist_t(ptr);
                ptr = d.next;
            }
            return(playlists);
        }