Results 1 to 16 of 16

Thread: How can I run a video file from the VB properties "resources" tab?

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    7

    Question How can I run a video file from the VB properties "resources" tab?

    Hello, ????????????????????????????????????????????????????????
    I was wondering how to compile a program (windows form app) that can play a new movie trailer video. I saved the trailer to the properties tab under Resources "files". I want to push a button in my form to activate and play the movie.

    To play a WAV file you can type: My.Computer.Play(My.Resources.......)
    Furthermore, I want to do the same thing but with movie trailer video.
    How can I do so?
    ???????????????????????????????????????????????????????????????????????????
    -Mike

  2. #2

    Re: How can I run a video file from the VB properties "resources" tab?

    Use a Movie Control, and set it's source to My.Resources.....whatever its called.

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How can I run a video file from the VB properties "resources" tab?

    First up, it's My.Computer.Audio.Play, so it's only for audio and, more specifically, only for WAV format sounds. There is support for the WAV format built in but there is no native support for any other audio format or any video format at all. To play any other media file you either need a component that supports that format added to your application or else you need to play the file in an external media player, e.g. Windows Media Player.

    Note that Windows Media Player will play many common video formats AND you can add a WMP component to your form. That said, I'm fairly certain the WMP component will only paly files. I don't think it will not accept binary data directly. When you add a video file to your resources it ceases to be a file and it gets returned by My.Resources as a Byte array, i.e. raw binary data.

    So, I would suggest that you first of all add Windows Media Player to your VS Toolbox, which you do from the COM Components tab. You can then add an instance to your form, just as you do for any other control. You'll then need to determine whether the control will accept binary data or requires a file. If it accepts binary data then you can pass your Byte array to it directly, otherwise you'll have to save the data to a file and then pass its path to the control. If you need to create a file then you should do so in the user's temp folder.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How can I run a video file from the VB properties "resources" tab?

    Quote Originally Posted by formlesstree4 View Post
    Use a Movie Control, and set it's source to My.Resources.....whatever its called.
    What's a "Movie Control"? Is that maybe a WPF thing?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    7

    Re: How can I run a video file from the VB properties "resources" tab?

    Quote Originally Posted by formlesstree4 View Post
    Use a Movie Control, and set it's source to My.Resources.....whatever its called.
    Hello,

    Where do I find the Movie Control?
    Is it under COM components?
    How do I add the video to my resources, so I can compile the program to run on another computer without having to install the video separately?
    Is there another location to chose other than resources?

    -Mike

  6. #6

    Re: How can I run a video file from the VB properties "resources" tab?

    Quote Originally Posted by jmcilhinney View Post
    What's a "Movie Control"? Is that maybe a WPF thing?
    I know what a movie control is, I just don't know the path to his movie resource, that's why I went '.....' off the My.resources thingy.

  7. #7
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    Re: How can I run a video file from the VB properties "resources" tab?

    If ist a flash Movie there are COM references for SWF and SWF ActiveX controls. I found this forum link on MSDN on the same subject, hope this helps;
    http://social.msdn.microsoft.com/For...-8613a8d9ae52/

    If you want to use the Media Player, right click on the toolbox and select Choose Items, go to Com and check the WMP. Place and instance on your form. You can then control it programmatically using;

    axWindowsMediaPlayer.URL = <path>
    AxWindowsMediaPlayer1.Ctlcontrols.play()
    AxWindowsMediaPlayer1.Ctlcontrols.stop()

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How can I run a video file from the VB properties "resources" tab?

    Quote Originally Posted by formlesstree4 View Post
    I know what a movie control is
    Good for you. I don't, which is why I asked. Perhaps you could provide an answer.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    7

    Re: How can I run a video file from the VB properties "resources" tab?

    Quote Originally Posted by jmcilhinney View Post
    First up, it's My.Computer.Audio.Play, so it's only for audio and, more specifically, only for WAV format sounds. There is support for the WAV format built in but there is no native support for any other audio format or any video format at all. To play any other media file you either need a component that supports that format added to your application or else you need to play the file in an external media player, e.g. Windows Media Player.

    Note that Windows Media Player will play many common video formats AND you can add a WMP component to your form. That said, I'm fairly certain the WMP component will only paly files. I don't think it will not accept binary data directly. When you add a video file to your resources it ceases to be a file and it gets returned by My.Resources as a Byte array, i.e. raw binary data.

    So, I would suggest that you first of all add Windows Media Player to your VS Toolbox, which you do from the COM Components tab. You can then add an instance to your form, just as you do for any other control. You'll then need to determine whether the control will accept binary data or requires a file. If it accepts binary data then you can pass your Byte array to it directly, otherwise you'll have to save the data to a file and then pass its path to the control. If you need to create a file then you should do so in the user's temp folder.
    Hello,
    What I mean is: My.Computer... but replace "audio" with "video or whatever it is..."

    Where can I store the video to make it part of the program (.exe)?

    I want to transfer this program to another computer that runs the .NET Framework, but I want to transfer the program as a whole.

    Is their a place in resources like "files"? Where?

    _Mike

  10. #10

    Re: How can I run a video file from the VB properties "resources" tab?

    Usually, resources are compiled right into the program.

  11. #11
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How can I run a video file from the VB properties "resources" tab?

    Quote Originally Posted by MSeanS View Post
    Hello,
    What I mean is: My.Computer... but replace "audio" with "video or whatever it is..."

    Where can I store the video to make it part of the program (.exe)?

    I want to transfer this program to another computer that runs the .NET Framework, but I want to transfer the program as a whole.

    Is their a place in resources like "files"? Where?

    _Mike
    Once you add a file to your project as a resource it ceases to be a file. Resources are compiled right inot the binary code of your application. My.Resources is a simple way to access those resources in code. It will return the data contained in the resource in the most convenient form possible for the type of object originally added. If you add a video file to your aplication's resources then the most convenient form possible is a Byte array.

    As I have said, there is native support for WAV format sounds in the .NET Framework, which is why My.Computer.Audio can play WAV sounds. It can play a WAV file or it can play a Byte array that contains the data for a WAV file. That's the sum total of media support. No other audio formats and no video formats are natively supported, as I've previously explained. As I've also already explained, to play a video you're going to either have to add a component to your form that supports video, which Windows Forms does not provide by default, or else play the video in an external media player. Generally speaking, even if you choose the first option, you're not going to be able to provide your video as a Byte array, but rather save the data as a file and then tell your component to play that file. This is all just repeating what I put in my previous post.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  12. #12

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    7

    Re: How can I run a video file from the VB properties "resources" tab?

    In VB 2008 express, what video component is available to load and play the stored video of my choice? Where is it locate? Is it under .COM components or what else? What is it called? How do I store the video to the .exe program to transfer it to another computer, without uploading it separately?

    I do not mean I want to use a WAV file, nor an audio file. I am, actually, trying to play a Terminator Salvation Trailer.

  13. #13
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How can I run a video file from the VB properties "resources" tab?

    I know that you don't want to play a WAV file. I was merely pointing out that the fact that you can call My.Computer.Audio.Play was irrelevant to your current predicament because it applies to WAV files only and no other media formats.

    I've already told you how to add Windows Media Player to your form, if you'd care to read what's been posted.

    To add a file to your resources you go to the Resources tab of the project properties and add the file.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  14. #14

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    7

    Re: How can I run a video file from the VB properties "resources" tab?

    Hello,

    I finally was able to run the video in my project by using Apple Quicktime's COM property; however, when adding an extra audio file ("the song from T2"), I got this message:

    Error 1 The "GenerateResource" task failed unexpectedly.
    System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
    at System.IO.MemoryStream.set_Capacity(Int32 value)
    at System.IO.MemoryStream.EnsureCapacity(Int32 value)
    at System.IO.MemoryStream.WriteByte(Byte value)
    at System.IO.BinaryWriter.Write(Byte value)
    at System.Resources.ResourceWriter.Write7BitEncodedInt(BinaryWriter store, Int32 value)
    at System.Resources.ResourceWriter.Generate()
    at System.Resources.ResourceWriter.Dispose(Boolean disposing)
    at System.Resources.ResourceWriter.Close()
    at Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(IResourceWriter writer)
    at Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(String filename)
    at Microsoft.Build.Tasks.ProcessResourceFiles.ProcessFile(String inFile, String outFile)
    at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, ArrayList inputs, ArrayList outputs, Boolean sourcePath, String language, String namespacename, String resourcesNamespace, String filename, String classname, Boolean publicClass)
    at Microsoft.Build.Tasks.GenerateResource.Execute()
    at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult) Terminator Practice 4

    I was wondering what it means?

    Does itg mean that there is not enough space in the program to have the extra audio file?

    If that is true:

    How can I transfer the program with IExpress on Vista (Hit run - then type iexpress)?

    What is the command in source code and under what location can I execute the extra form with the media player and T2 song, through iexpress?

    Thanks,

    Mike

  15. #15
    Lively Member dinglu's Avatar
    Join Date
    May 2008
    Location
    Western Sydney, NSW, Australia
    Posts
    94

    Re: How can I run a video file from the VB properties "resources" tab?

    I dont know about the error but if you refer to bulldogs post above you can find that you can use windows media player, which is located in COM components and he tells you everything. but thats if you want to use something other than quicktime,

    The error i cant help you with

  16. #16

    Re: How can I run a video file from the VB properties "resources" tab?

    System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. <- actual error.

    Use the WMP Control. Read bulldog's post. I don't know why you would go and use a different control than specified, and then request help, when another, simpler control was already suggested. It makes no sense.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width