Solved

Play a video within app

Posted on 2010-11-27
7
583 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now