?
Solved

Play a video within app

Posted on 2010-11-27
7
Medium Priority
?
599 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
Industry Leaders: 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 2000 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

Interactive Way of Training for the AWS CSA Exam

An interactive way of learning that will help you visualize core concepts so that you can be more effective when taking your AWS certification exam.  Built for students by a student to help them understand the concepts that they are being taught.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

800 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