|
-
Oct 19th, 2022, 05:48 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] How to addressing wav and gif from resources?
Hi, these two lines of codes already tested and works properly. What if you include those *.wav(s) and *.gif(s) in app resources? How can we address them using My.Recourses?
Code:
Dim animatedImage As New Bitmap(Application.StartupPath & "\splash.gif")
Code:
My.Computer.Audio.Play("select.wav")
Need to achieve something independent and app-included like this: (Following codes are examples and errors surly pop up)
Code:
Dim animatedImage As New Bitmap(My.Resources.splash)
Code:
My.Computer.Audio.Play(My.Resources.select)
-
Oct 19th, 2022, 08:24 AM
#2
Re: How to addressing wav and gif from resources?
Firstly, if errors pop up and you want us to help you fix them, don't you think it would be a good idea to provide us with the error messages? That's just common sense.
When you add an existing file to your Resources, the type of property generated in My.Resources will depend on the type of file you added. You can see the type of each property just like you can any other in code. If you do this:
vb.bet Code:
Dim x = My.Resources.splash
then you'll be able to see what type that property is as you type or by checking the type inferred for x. For a GIF file, I'd expect the property to be type Image and the object it returns to be type Bitmap.
For the WAV, I would expect the property to be either Byte() or perhaps UnmanagedMemoryStream or the like. In either case, you should be able to pass it directly to Play as long as you provide a second argument of type AudioPlayMode. I suspect that the error message actually told you that, but I can only guess.
-
Oct 21st, 2022, 04:12 AM
#3
Thread Starter
Hyperactive Member
Re: How to addressing wav and gif from resources?
I might be a bit less artful in describing things, sorry for that
I achieve correct results for first part of the thread. You can call a wave file anywhere in your WinForms VB.NET projects from My.Resources via
Code:
My.Computer.Audio.Play(My.Resources.ButtonClick, AudioPlayMode.Background)
Second part which was GIF files, Difficult part is, Application runs and do things with no errors (To mention) Only additional information is
Instead of
Code:
Dim animatedImage As New Bitmap(Application.StartupPath & "\splash.gif")
I used
Code:
Dim animatedImage As New Bitmap(My.Resources.splash, My.Resources.splash.Size)
The goal is to "play" GIF file once in a picturebox then proceed. Problem is only the first frame of GIF will be shown. Should I vast the gif array as its length, if so HOW?
-
Oct 21st, 2022, 05:49 AM
#4
Re: How to addressing wav and gif from resources?
 Originally Posted by pourkascheff
I used
Code:
Dim animatedImage As New Bitmap(My.Resources.splash, My.Resources.splash.Size)
The goal is to "play" GIF file once in a picturebox then proceed. Problem is only the first frame of GIF will be shown. Should I vast the gif array as its length, if so HOW?
I thought we already covered this:
vb.net Code:
Dim animatedImage = My.Resources.splash
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|