Beispiel #1
0
        public IAsyncResult BeginLoadImage(Session session, AsyncCallback userCallback, object state)
        {
            byte[] imageId = new byte[20];

            bool hasImage = LibSpotify.sp_playlist_get_image_r(Handle, imageId);

            if (!hasImage)
            {
                AsyncLoadImageResult result = new AsyncLoadImageResult(userCallback, state);
                result.CompletedSynchronously = true;
                result.SetCallbackComplete();
                result.SetCompleted(Error.Ok);
                return(result);
            }

            IntPtr p = System.Runtime.InteropServices.Marshal.AllocHGlobal(imageId.Length);

            try
            {
                System.Runtime.InteropServices.Marshal.Copy(imageId, 0, p, imageId.Length);
                return(ImageLoader.Begin((ptr, size) => { return ptr; }, p, session, ImageSize.Normal, userCallback, state));
            }
            finally
            {
                System.Runtime.InteropServices.Marshal.FreeHGlobal(p);
            }
        }