Solved

Play a video within app

Posted on 2010-11-27
7
593 Views
Last Modified: 2012-08-14
Hi,

I want to play a video within my application at run time on a click event. I found this code online, how can I tweek it to do what I want?

What references will I need to add?

I am using Vb.NEt and a WPF Application
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim MyStream As System.IO.Stream = System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream("WindowsApplication1.lesson1.mpg")
        Dim MyFileStream As New System.IO.FileStream("TempFile.mpg", FileMode.Create)
        Dim MyBinaryWriter As New BinaryWriter(MyFileStream)

        Try
            Dim MyByte As Byte = MyStream.ReadByte
            While Not MyByte = -1
                MyBinaryWriter.Write(MyByte)
                MyByte = MyStream.ReadByte
            End While
        Catch ex As Exception
        Finally
            MyFileStream.Close()
        End Try
        MyMovie.FileName = "TempFile.mpg"
        MyMovie.Play()

    End Sub

    Private Sub MyMovie_EndOfStream(ByVal sender As Object, ByVal e As AxMediaPlayer._MediaPlayerEvents_EndOfStreamEvent) Handles MyMovie.EndOfStream
        MyMovie.FileName = Nothing
        File.Delete("TempFile.mpg")
    End Sub

Open in new window

0
Comment
Question by:Trying_to_Learn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
7 Comments
 

Author Comment

by:Trying_to_Learn
ID: 34224365
I am using MediaElement now

More references can be found at:
http://msdn.microsoft.com/en-us/library/aa970915.aspx

I tried implementing this but nothing happens...
0
 

Author Comment

by:Trying_to_Learn
ID: 34224367

<MediaElement Source="/MoviesOnTheGo;component/XYZ.mov" Name="MediaElement1" UnloadedBehavior="Manual" LoadedBehavior="Play" />

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 34228929
0
 

Author Comment

by:Trying_to_Learn
ID: 34241146
The tutorial was good, and the only thing relevant to me from that tutorial is the button_play.

All that does is just plays the video, I have the same code, but nothing plays...

It gave me an error first that either loadedbehaviour or unloadedbehaviour has to be set to manual, so I set loadbehaviour = play and unloadbehaviour = manual

and now nothing happens :(

I need this ASAP !!
0
 

Author Comment

by:Trying_to_Learn
ID: 34241149

<MediaElement Source="/MoviesOnTheGo;component/morningglory_trlr_01_480p_dl.wmv" Name="MediaElement1" LoadedBehavior="Play" UnloadedBehavior="Manual" />

Open in new window

0
 

Author Comment

by:Trying_to_Learn
ID: 34241187

'The button which plays the video element

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button2.Click
            MediaElement1.Play()
            MediaElement1.IsEnabled = MediaElement1.IsLoaded
            Button_Coder_Trailers(Button2)
        End Sub
' The code for the media element
<MediaElement Source="/MoviesOnTheGo;component/morningglory_trlr_01_480p_dl.wmv" Name="MediaElement1" LoadedBehavior="Play" Margin="0,0,0,0" Stretch="Fill" UnloadedBehavior="Manual" />

Open in new window

0

Featured Post

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question