Click here to Skip to main content
15,887,416 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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;
C#
var imageUri = PackUriHelper.Create(new Uri(@"C:\Users\Manish\Desktop\package.pkg"), resourcePart.Uri); //resourcePart = Image1.jpeg
//imageUri receives ‘pack://file:,,,C:,Users,Manish,Desktop,package.pkg/Resources/Image1.jpeg’
var videoUri = PackUriHelper.Create(new Uri(@"C:\Users\Manish\Desktop\package.pkg"), resourcePart.Uri);     //resourcePart = Video1.wmv
//videoUri receives ‘pack://file:,,,C:,Users,Manish,Desktop,package.pkg/Resources/Video1.wmv’

My Xaml is like this;
HTML
<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;
C#
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.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900