This is a migrated thread and some comments may be shown as answers.

Processing files before upload

1 Answer 67 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 10 May 2013, 03:58 PM
Hi,

I'm using Telerik Upload for uploading multiple Videos. All is setup and working with Upload handler. Now, I need to add a feature where I must create a thumbnail of the video file before its uploaded. see below my current code for generating the thumbnail

private byte[] CreateThumbNail(string fileExtention, FileInfo vidFile)
{
    //FileInfoFileInfo mFile = new FileInfo(filepath);
    try
    {
        WriteableBitmap thumbnail = null;
        switch (fileExtention)
        {
            case ".wmv":
            case ".mp4":
            case ".mov":
                SimplePlayerSettings mSettings = new SimplePlayerSettings();
                SimplePlayer mediaPlayer = new SimplePlayer();
                //mSettings.DeliveryMethod = Microsoft.SilverlightMediaFramework.Plugins.Primitives.DeliveryMethods.Streaming;
                mSettings.StreamSource = vidFile.OpenRead();
                mediaPlayer.InitPlayer(mSettings);
                mediaPlayer.Playlist.Clear();
                mediaPlayer.Stop();
                mediaPlayer.SeekToPosition(5);
                thumbnail = new WriteableBitmap(mediaPlayer, null);
                break;
            default:
                return null;
        }
 
        BitmapImage bmpImg = new BitmapImage();
        using (MemoryStream stream = new MemoryStream())
        {
            PngBitmapEncoder encoder = new PngBitmapEncoder();
            encoder.Frames.Add(BitmapFrame.Create(thumbnail));
            encoder.Save(stream);
            return stream.ToArray();
        }
    }
    catch (Exception ex)
    {
        return null;
    }
 
}

Now, what my problem is, the video file cannot be loaded and throws an error about access denied. Any help would be appriciated.

Thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Tina Stancheva
Telerik team
answered on 15 May 2013, 03:34 PM
Hello Eric,

Unfortunately I wasn't able to reproduce this issue from the code you provided. And I'm not sure how and where you call the CreateThumbNail() method. Can you please elaborate a bit more on your implementation?

Thank you in advance.

All the best,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Upload
Asked by
Thomas
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or