I am trying to create a Package using System.IO.Packaging. My package (package.pkg) has the following structure;
(Content)
Document.xml
(Resources)
Image1.jpeg
Video1.wmv
To add the Image1.jpeg to the package, I have used the MIME type, System.Net.Mime.MediaTypeNames.Image.Jpeg for contentType parameter, and for the Video1.wmv file the contentType parameter that I am passing is “video/x-ms-wmv”.
Now, I have a WPF application where I want to use this package. I am using the sample code in
Packaging Samples to Read and Write the Packages. Inside my WPF application, I have an Image control and a MediaElement. I am using PackUriHelper class to create the PackUri for the Image and Video inside my Package. Something like this;
var imageUri = PackUriHelper.Create(new Uri(@"C:\Users\Manish\Desktop\package.pkg"), resourcePart.Uri);
var videoUri = PackUriHelper.Create(new Uri(@"C:\Users\Manish\Desktop\package.pkg"), resourcePart.Uri);
My Xaml is like this;
<Grid>
<Border BorderBrush="Black" BorderThickness="5">
<StackPanel Orientation="Horizontal">
<Image Name="img"/>
<MediaElement Name="vid" LoadedBehavior="Manual"/>
</StackPanel>
</Border>
<Button Height="20" Width="20" Click="Button_Click"/>
</Grid>
In my code-behind I am doing this;
img.Source = imageUri;
vid.Source = videoUri;
vid.Play();
Now my Image control loads from the source alright but not my Video. I know loading the video is possible. The article here depicts that it is possible;
A New Standard For Packaging Your Data
What then is making it so challenging? Any helps shall be greatly appreciated.