Click here to Skip to main content
13,737,584 members
Click here to Skip to main content

Stats

30.4K views
1.7K downloads
5 bookmarked
Posted 8 Sep 2011
Licenced CPOL

Play AVI files in Silverlight 5 using MediaElement and MediaStreamSource - P/Invoke

, 14 Sep 2011
This code demostrates how to use Silverlight 5 with OOB+elevated trust to play a local video (.avi). Uses P/Invoke support for native code
CMSS_S5_plusWriteableBitmap
Silverlight5_SampleVB1
Bin
Debug
Silverlight5_SampleVB1.dll
Silverlight5_SampleVB1.xap
Classes
My Project
Silverlight5_SampleVB1.vbproj.user
Silverlight5_SampleVB1.Web
bin
Silverlight5_SampleVB1.Web.dll
Silverlight5_SampleVB1.Web.pdb
ClientBin
Silverlight5_SampleVB1.xap
My Project
Application.myapp
MyExtensions
Silverlight5_SampleVB1.Web.vbproj.user
CustomMediaStreamSourceS5
Silverlight5_SampleVB1
Bin
Debug
Silverlight5_SampleVB1.dll
Silverlight5_SampleVB1.xap
Classes
My Project
Silverlight5_SampleVB1.vbproj.user
Silverlight5_SampleVB1.Web
bin
Silverlight5_SampleVB1.Web.dll
Silverlight5_SampleVB1.Web.pdb
ClientBin
Silverlight5_SampleVB1.xap
My Project
Application.myapp
MyExtensions
Silverlight5_SampleVB1.Web.vbproj.user
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>
    </ProductVersion>
    <SchemaVersion>
    </SchemaVersion>
    <ProjectGuid>{D821A952-4686-4297-931B-B96203AFBCB3}</ProjectGuid>
    <ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <RootNamespace>Silverlight5_SampleVB1</RootNamespace>
    <AssemblyName>Silverlight5_SampleVB1</AssemblyName>
    <TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
    <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
    <SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
    <SilverlightApplication>true</SilverlightApplication>
    <SupportedCultures>
    </SupportedCultures>
    <XapOutputs>true</XapOutputs>
    <GenerateSilverlightManifest>true</GenerateSilverlightManifest>
    <XapFilename>Silverlight5_SampleVB1.xap</XapFilename>
    <SilverlightManifestTemplate>My Project\AppManifest.xml</SilverlightManifestTemplate>
    <SilverlightAppEntry>Silverlight5_SampleVB1.App</SilverlightAppEntry>
    <TestPageFileName>Silverlight5_SampleVB1TestPage.html</TestPageFileName>
    <CreateTestPage>true</CreateTestPage>
    <ValidateXaml>true</ValidateXaml>
    <EnableOutOfBrowser>true</EnableOutOfBrowser>
    <OutOfBrowserSettingsFile>My Project\OutOfBrowserSettings.xml</OutOfBrowserSettingsFile>
    <UsePlatformExtensions>false</UsePlatformExtensions>
    <ThrowErrorsInValidation>true</ThrowErrorsInValidation>
    <LinkedServerProject>
    </LinkedServerProject>
  </PropertyGroup>
  <!-- This property group is only here to support building this project using the 
       MSBuild 3.5 toolset. In order to work correctly with this older toolset, it needs 
       to set the TargetFrameworkVersion to v3.5 -->
  <PropertyGroup Condition="'$(MSBuildToolsVersion)' == '3.5'">
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <DefineDebug>true</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <NoStdLib>true</NoStdLib>
    <NoConfig>true</NoConfig>
    <MyType>Empty</MyType>
    <OutputPath>Bin\Debug</OutputPath>
    <DocumentationFile>Silverlight5_SampleVB1.xml</DocumentationFile>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
    <DefineConstants>SILVERLIGHT=1</DefineConstants>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <DefineDebug>false</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <NoStdLib>true</NoStdLib>
    <NoConfig>true</NoConfig>
    <Optimize>true</Optimize>
    <OutputPath>Bin\Release</OutputPath>
    <DocumentationFile>Silverlight5_SampleVB1.xml</DocumentationFile>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
    <DefineConstants>SILVERLIGHT=1</DefineConstants>
  </PropertyGroup>
  <PropertyGroup>
    <OptionExplicit>On</OptionExplicit>
  </PropertyGroup>
  <PropertyGroup>
    <OptionCompare>Binary</OptionCompare>
  </PropertyGroup>
  <PropertyGroup>
    <OptionStrict>Off</OptionStrict>
  </PropertyGroup>
  <PropertyGroup>
    <OptionInfer>On</OptionInfer>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="mscorlib" />
    <Reference Include="System.Windows" />
    <Reference Include="system" />
    <Reference Include="System.Core" />
    <Reference Include="System.Net" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Windows.Browser" />
  </ItemGroup>
  <ItemGroup>
    <Import Include="Microsoft.VisualBasic" />
    <Import Include="System" />
    <Import Include="System.Linq" />
    <Import Include="System.Collections.Generic" />
    <Import Include="System.Xml" />
    <Import Include="System.Net" />
    <Import Include="System.Windows" />
    <Import Include="System.Windows.Controls" />
    <Import Include="System.Windows.Documents" />
    <Import Include="System.Windows.Ink" />
    <Import Include="System.Windows.Input" />
    <Import Include="System.Windows.Media" />
    <Import Include="System.Windows.Media.Animation" />
    <Import Include="System.Windows.Shapes" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="App.xaml.vb">
      <DependentUpon>App.xaml</DependentUpon>
    </Compile>
    <Compile Include="Classes\cAVIDefs.vb" />
    <Compile Include="Classes\MyDerivedMediaStreamSource.vb" />
    <Compile Include="Classes\Sample.vb" />
    <Compile Include="MainPage.xaml.vb">
      <DependentUpon>MainPage.xaml</DependentUpon>
    </Compile>
    <Compile Include="My Project\AssemblyInfo.vb" />
  </ItemGroup>
  <ItemGroup>
    <ApplicationDefinition Include="App.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:Compile</Generator>
    </ApplicationDefinition>
    <Page Include="MainPage.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:Compile</Generator>
    </Page>
  </ItemGroup>
  <ItemGroup>
    <None Include="My Project\AppManifest.xml" />
  </ItemGroup>
  <ItemGroup>
    <None Include="My Project\OutOfBrowserSettings.xml" />
  </ItemGroup>
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.VisualBasic.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
  <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
        <SilverlightProjectProperties />
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>
</Project>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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

Share

About the Author

Amir Eshaq
Other Norconsult Telematics, KSA
Canada Canada
I have been a Developer for many years. I have worked as Senior Developer in Kenya, Canada and Saudi Arabia. I enjoy coding and I am looking forward to more challenges with new Technologies

I am currently IT Manager at Norconsult Telematics, Saudi Arabia.

You may also be interested in...

Pro
Pro
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180920.1 | Last Updated 14 Sep 2011
Article Copyright 2011 by Amir Eshaq
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid