Platforms to show: All Mac Windows Linux Cross-Platform
/Main/Web Edition Examples/Music in Web App Web1
Function:
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Main/Web Edition Examples/Music in Web App Web1
This example is the version from Thu, 6th Apr 2016.
Function:
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Main/Web Edition Examples/Music in Web App Web1
This example is the version from Thu, 6th Apr 2016.
Project "Music in Web App Web1.xojo_binary_project"
Class App Inherits WebApplication
EventHandler Sub Open(args() as String)
// you need to change file names or provide similar files
dim f as FolderItem = FindFile("Jingle_Bells.m4v")
if f = nil then
print "Failed to find Jingle_Bells.m4v file."
quit
end if
dim bM as binarystream = BinaryStream.Open(f)
dim bO as binarystream = BinaryStream.Open(f.Parent.Child("Jingle_Bells.ogg"))
audioFileM4V = new WebFile
audioFileM4V.Data = bM.Read(BM.Length)
audioFileM4V.Filename = "music.m4a"
audioFileM4V.MIMEType = "audio/m4a"
audioFileM4V.Session = nil
audioFileOGG = new WebFile
audioFileOGG.Data = bO.Read(BO.Length)
audioFileOGG.Filename = "music.ogg"
audioFileOGG.MIMEType = "audio/ogg"
audioFileOGG.Session = nil
End EventHandler
Function FindFile(name as string) As FolderItem
// Look for file in parent folders from executable on
dim parent as FolderItem = app.ExecutableFile.Parent
while parent<>Nil
dim file as FolderItem = parent.Child(name)
if file<>Nil and file.Exists then
Return file
end if
parent = parent.Parent
wend
End Function
Property audioFileM4V As WebFile
Property audioFileOGG As WebFile
End Class
Class Session Inherits WebSession
Const ErrorDialogCancel = "Do Not Send"
Const ErrorDialogMessage = "This application has encountered an error and cannot continue."
Const ErrorDialogQuestion = "Please describe what you were doing right before the error occurred:"
Const ErrorDialogSubmit = "Send"
Const ErrorThankYou = "Thank You"
Const ErrorThankYouMessage = "Your feedback helps us make improvements."
Const NoJavascriptInstructions = "To turn Javascript on, please refer to your browser settings window."
Const NoJavascriptMessage = "Javascript must be enabled to access this page."
End Class
Class WebPage1 Inherits WebPage
Control Link1 Inherits WebLink
ControlInstance Link1 Inherits WebLink
End Control
Control Button1 Inherits WebButton
ControlInstance Button1 Inherits WebButton
EventHandler Sub Action()
me.ExecuteJavaScript("document.getElementById('mymusic').play();")
End EventHandler
End Control
Control Label1 Inherits WebLabel
ControlInstance Label1 Inherits WebLabel
End Control
Control Button2 Inherits WebButton
ControlInstance Button2 Inherits WebButton
EventHandler Sub Action()
me.ExecuteJavaScript("document.getElementById('mymusic').pause();")
End EventHandler
End Control
Control PageSource1 Inherits WebPageSource
ControlInstance PageSource1 Inherits WebPageSource
EventHandler Sub EditSource(ByRef Source As String, Location As Integer)
dim urlo as string = app.audioFileOGG.URL
dim urlm as string = app.audioFileM4V.URL
source = "<audio id=""mymusic"" preload=""auto"">"+_
"<source src="""+urlo+""" type=""audio/ogg"" />"+_
"<source src="""+urlm+""" type=""audio/mpeg"" />Your browser does not support the audio element.</audio>"
End EventHandler
End Control
Control Label2 Inherits WebLabel
ControlInstance Label2 Inherits WebLabel
End Control
Control Slider1 Inherits WebSlider
ControlInstance Slider1 Inherits WebSlider
EventHandler Sub ValueChanged()
me.ExecuteJavaScript("document.getElementById('mymusic').volume="+str(me.Value/100.0)+";")
End EventHandler
End Control
Control Label3 Inherits WebLabel
ControlInstance Label3 Inherits WebLabel
End Control
Control Label4 Inherits WebLabel
ControlInstance Label4 Inherits WebLabel
EventHandler Sub Open()
me.text = "Compiled with Real Studio "+RBVersionString+" and MBS Real Studio Plugins "+mbs.VersionString
End EventHandler
End Control
End Class
FileTypes1
Filetype audio/m4a
End FileTypes1
End Project
See also:
- /Main/Web Edition Examples/Infos Web1
- /Main/Web Edition Examples/Infos Web2
- /Main/Web Edition Examples/Invisible FileUploader with Button Web1
- /Main/Web Edition Examples/Little database sample Web1
- /Main/Web Edition Examples/TicTacToe game/TicTacToe game Web1
- /Main/Web Edition Examples/TicTacToe game/TicTacToe game Web2
- /Main/Web Edition Examples/WebApp with missing pictures Web1
- /Main/Web Loadbalancer Example/MyApp
The items on this page are in the following plugins: MBS Main Plugin.
Feedback: Report problem or ask question.