- Joined
- Jul 26, 2016
- Messages
- 29
The following code loads songs from the "Songs" folder into a listbox. I can click on any of the songs in the listbox, which loads the song into an <AUDIO> control. I can click play on the Audio control to play the song.
However, I would like it to play through the list of songs in the listbox without me having to click on each individual song.
I am trying to call a VB subroutine from within the <AUDIO> tag using the onended event. Here's the code:
For some reason, it's not recognizing the subroutine that I'm calling. The onended has to be a Javascript routine, but I'm trying to call a VBScript from with Javascript.
If I can get the onended event to work, I could figure out a routine to play the next song without having to manually click an item in the listbox.
If this doesn't work, anyone have suggestions to play multiple songs using the <AUDIO> control?
Thanks in advance for the help.
Code:
<script language="vbscript" runat="server">
Public SongToPlay As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then ' First time ASPX page is loaded.
SongToPlay = "Songs/Song1.mp3"
Dim pathLocal As String
Dim pathSongs As String
' Get current path
pathLocal = HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ServerVariables("PATH"))
pathSongs = pathLocal & "\Songs"
Dim MyFile, MyPath As String
MyPath = pathSongs ' Set Folder location for songs
MyFile = Dir(pathSongs & "\*.mp3")
Do While MyFile <> "" ' Start the loop.
' Use bitwise comparison to make sure MyName is a directory.
lbAllSongs.Items.Add(MyFile)
MyFile = Dir() ' Get next entry.
Loop
lbAllSongs.SelectedIndex = 0 ' Sets first song as default
Else
lblSelectedSong.Text = lbAllSongs.SelectedItem.Text
SongToPlay = "Songs/" & lbAllSongs.SelectedItem.Text
End If ' If Not IsPostBack
End Sub ' Page_Load
</script>
However, I would like it to play through the list of songs in the listbox without me having to click on each individual song.
I am trying to call a VB subroutine from within the <AUDIO> tag using the onended event. Here's the code:
Code:
<audio id="audioPlayer" src="<%=SongToPlay %>" controls="true" onended="audioPlayerOnEnded()"></audio>
For some reason, it's not recognizing the subroutine that I'm calling. The onended has to be a Javascript routine, but I'm trying to call a VBScript from with Javascript.
If I can get the onended event to work, I could figure out a routine to play the next song without having to manually click an item in the listbox.
If this doesn't work, anyone have suggestions to play multiple songs using the <AUDIO> control?
Thanks in advance for the help.