Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Play a video within app

Posted on 2010-11-27
7
Medium Priority
?
608 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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…
Suggested Courses

610 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