I have been having trouble getting wave files into the resources of this project.
I tried to add the wave files by right clicking on 'Resources' in the Solution Explorer and selecting 'Add' and 'Existing Item'
That added the files to the Resources list but I couldn't select it with code.
I restored my files by loading a copy of a backup to ensure that there were no problems with project and then tried a different way to add the wave files.
I opened Resource Explorer by clicking on 'View', hovered over 'Other Windows' to open the next list where I clicked on 'Resource Explorer'.
After opening Resource Explorer I clicked the green + symbol which opened the 'Add New Resource to Form1' window.
In this window I changed the Type to audio.
I clicked on 'Select File' navigated to the folder and then selected the 'Alarm01.wav' file.
To ensure I had a valid and working .wav file I copied the 'Alarm01.wav' file from C:\Windows\Media folder to another, which will play directly from the folder using the 1st line in the Button1 _Click event.
The Name field took on the name of the file and the only option for 'Add To File' was 'Form1' so I didn't change these.
The file showed up under the 'Resources'
I then tried adding the resource to the same code that would play the file from it's original folder this is the 2nd line in the Button1 _Click event, but I keep getting the same result, My.Resources.Alarm01 is underlined in red with the error 'BC30456: 'Alarm01' is not a member of 'Clock_App_V1.2.MyResources'.
There is more code for the mediaplayer but this is all that was needed to play the sounds.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
FullAlarmFilePath = "D:\Desktop\New folder\Alarm01.wav"
'FullAlarmFilePath = My.Resources.Alarm01.ToString
'FullAlarmFilePath = My.Resources.AarrowUp2.ToString
PlaySound()
End Sub
Private Sub PlaySound()
AxWindowsMediaPlayer1.URL = FullAlarmFilePath
AlarmSounding = True
AxWindowsMediaPlayer1.Ctlcontrols.play()
End Sub
As an experiment I added another line, the 3rd line in the Button1 _Click event which selects a bitmap image to play, but I didn't get the error '<name>' is not a member of '<classname>'.
Obviously if I clicked on the button to play it then mediaplayer would tell me that it wasn't the correct format.
This showed me that the bitmap was considered as part of the resources and that I could select it when typing the code, but I can't select Alarm01.wav that is part of the same resources.
I remember having the same problem a long time ago with images and found that if I added them by using the background image of a control, such as a button or picture box it would work.
That is how I have been adding images ever since and is how I added the image used in the code.
So I tried adding a bitmap the same way as I added the audio and found that it gives the same result, when writing code it doesn't recognise that the bitmap is there.
It must be something to do with how I'm adding the files.
Does anybody know what I am missing or doing wrong, because I can't see what it could be.