Solved

Play a video within app

Posted on 2010-11-27
7
591 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
  • 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
 

Author Comment

by:Trying_to_Learn
ID: 34224377
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

839 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