Can you help me about inserting video in resources of visual basic and how to call it and play in my media player in a form..because i have media player in my project and my problem is how can i insert video and call it from resources...
i hope you can help me..Thanks a lot..!
I am going to assume that you mean adding a video to the embedded resources.
From the menu, goto Project->Properties. Then select the "Resources" tab. Next Select "Add Rersource"->"From Existing File". You can then select your video file. The file will be inserted with the File Name minus the extension as a binary array.
As far as I know, the media player control can only except a file reference to play. Therefore, you will need to write the binary array to a temporary file first.
Private TmpFiles As New List(Of String) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim fi As New IO.FileInfo(IO.Path.GetTempFileName()) Dim tmppath As String = IO.Path.GetTempFileName() ' The tmp file will have a ".tmp" extension ' The media player uses the extension to identify the proper codec to use to decode the file ' I used a wma video, so I will change the extension to that tmppath = tmppath.Replace(".tmp", ".wma") ' Create the file and write the resource array to it Dim tmp As IO.Stream = IO.File.Create(tmppath) ' Amanda is the name of my file tmp.Write(My.Resources.Amanda, 0, My.Resources.Amanda.Length) tmp.Close() 'Save a reference to tmp file so that you can delete it on the Form.Closing event TmpFiles.Add(tmppath) ' tell the player to play the file WMP1.currentMedia = WMP1.newMedia(tmppath) End Sub Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing For Each file As String In TmpFiles Try IO.File.Delete(file) Catch ex As Exception '' End Try Next End Sub
Thank you for this I am getting closer with your help. Regards Jakewebbe (Bill)
Hi TnTinMN Your code works fine but when I go to debug I get this message. 'Error 1 Unable to write to output file 'C:\Users\Bill\documents\visual studio 2010\Projects\resources test 2\resources test 2\obj\x86\Debug\resources test 2.exe': System Error &H8007000e& resources test 2'
My project name is resources test 2
I was wondering if this error is generated because of the total file sizes being around half a gig and or the amount of files I have added to the resources which would total around 35.
Any idea would be helpful, thanks.
i am using visual studio 2015 and trying to export data which i am importing through excel by the user selected Excel file. Now the importing part has been successfully completed i am using OLEDB Connection but Stuck in exporting the same data to a new Excel file. tried ...
I am creating a program that when you print an author, you must show all the information of all the books that the author has written. Add a new attribute in the Author class that will be "BooksWriting: List (Book)".
I have expanded the program so that it also ...
I am currently creating a simulation of a pizza ordering system in object oriented program. I have some question. the instruction and guideline is long but I will try and cut it down a lot. the instruction is to create a program that simulate a pizza restaurant using ...