webGadget audio question

Just starting out? Need help? Post your questions and find answers here.
User avatar
minimy
Enthusiast
Enthusiast
Posts: 336
Joined: Mon Jul 08, 2013 8:43 pm

webGadget audio question

Post by minimy »

Is posible change the webgadget audio volume?
Or turn mute or any thing like this?
Thanks!!
If translation=Error: reply="Sorry, Im Spanish": Endif
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 617
Joined: Mon May 09, 2011 9:36 am

Re: webGadget audio question

Post by VB6_to_PBx »

minimy wrote:Is posible change the webgadget audio volume?
Or turn mute or any thing like this?
Thanks!!
this Code can change Volume and Mute

Code: Select all

;===== Registry: temp setting to optimise web gadget =====
Global     sglpValueName.s = GetFilePart(ProgramFilename())
Global          lglpData.l = 11001
Global lglpdwDisposition.l
Global       igphkResult.i

If RegCreateKeyEx_(#HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", 0, #Null, #REG_OPTION_VOLATILE, #KEY_ALL_ACCESS, #Null, @igphkResult, @lglpdwDisposition) = #ERROR_SUCCESS
    RegSetValueEx_(igphkResult, sglpValueName, 0, #REG_DWORD, @lglpData, SizeOf(LONG))
      RegCloseKey_(igphkResult)
EndIf


Global.s HTML, Filename
Declare Player()

OpenWindow(0, 0, 0, 1200, 940, "WebGadget", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
		  CreateMenu(1, WindowID(0))
    MenuTitle("Files")
		  MenuItem(0," Open  File ")

WebGadget(5, 0, 0, 1200, 940, "about:blank")

Repeat
    Event = WaitWindowEvent()
    Select Event
    Case #PB_Event_Menu
							Filename = OpenFileRequester("Choose a mp4", "", "MP4|*.mp4;*.flv;*.mp3", 0)  ;Pattern$ = "Videos |*.flv;*.mp4"
							SetWindowTitle(0,Filename)
							Player()
							SetGadgetItemText(5, #PB_Web_HtmlCode, HTML)
   Case #PB_Event_SizeWindow
        ResizeGadget(5, 0, 0,WindowWidth(0)-20, WindowHeight(0)-20)
   EndSelect
Until Event = #PB_Event_CloseWindow

; Declare Player()
Procedure Player()
HTML = "<html>" + 
"<body>" +
"<button onclick='playPause()'>Play / Pause</button>" +
"<button onclick='setMuteVolume()' type='button'>Mute volume</button>" +
"<button onclick='setQuarterVolume()' type='button'>Set volume to 25 %</button>" +
"<button onclick='setHalfVolume()' type='button'>Set volume to 50 %</button>" +
"<button onclick='setFullVolume()' type='button'>Set volume to 100 %</button><br>" +
"<button onclick='VidSize640x480()' type='button'>Video Size 640x480</button>" +
"<button onclick='VidSize940x705()' type='button'>Video Size 940x705</button>" +
"<button onclick='VidSize1160x870()' type='button'>Video Size 1160x870</button><br>" + 

"<video id='myVideo' controls>" +
"<source src='"+Filename+"'></video>" +
"<script>" +
"var vid = document.getElementById('myVideo');" +
"vid.volume = 1;" +
"vid.width = 1160;" +
"vid.height = 870;" +

"var playPause = function() {" +
"if (vid.paused)" +
"    vid.play();" +
"else" +
"    vid.pause();" +
"};" +

"var getVolume = function() {" + 
"alert(vid.volume);" +
"};" +

"var setMuteVolume = function() {" +
"vid.volume = 0;" +
"};" +

"var setQuarterVolume = function() {" +
"vid.volume = 0.25;" +
"};" +

"var setHalfVolume = function() {" +
"vid.volume = 0.5;" +
"};" +

"var setFullVolume = function() {" +
"vid.volume = 1;" +
"};" +


"var VidSize640x480 = function() {" + 
"vid.width = 640;" +
"vid.height = 480;" +
"};" +

"var VidSize940x705 = function() {" + 
"vid.width = 940;" +
"vid.height = 705;" +
"};" +

"var VidSize1160x870 = function() {" + 
"vid.width = 1160;" +
"vid.height = 870;" +
"};" +

"</script>" +
"</html>"

EndProcedure


 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
User avatar
minimy
Enthusiast
Enthusiast
Posts: 336
Joined: Mon Jul 08, 2013 8:43 pm

Re: webGadget audio question

Post by minimy »

Hey VB6_to_PBx thank you very much!!
I see, you use HTML5 video and a bit of js to control the options.
Very clever!!

Do you know any way to execute js functions into webgadget from PB?
Is this possible?

Thanks again!!
If translation=Error: reply="Sorry, Im Spanish": Endif
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 617
Joined: Mon May 09, 2011 9:36 am

Re: webGadget audio question

Post by VB6_to_PBx »

minimy wrote:Hey VB6_to_PBx thank you very much!!
I see, you use HTML5 video and a bit of js to control the options.
Very clever!!

Do you know any way to execute js functions into webgadget from PB?
Is this possible?

Thanks again!!

i'm just a Beginner in HTML5 and this was my first effort using HTML5 How To's from here :
https://www.w3schools.com/html/html5_video.asp

i'm actually using most of this PB Code to display .MP4 Help videos bundled with my Softwares


i recommend replacing this Code line :

Code: Select all

Filename = OpenFileRequester("Choose a mp4", "", "MP4|*.mp4;*.flv;*.mp3", 0)  ;Pattern$ = "Videos |*.flv;*.mp4"
with this new Code line :

Code: Select all

Filename = OpenFileRequester("Choose a mp4", "", "MP4|*.mp4", 0)
because it seems HTML5 Player has too much difficulty in playing various .FLV and .MP3 files
.MP4 files always seem to work ... could be my FireFox version + Win10 Computer ?? , i haven't tested in Window's Edge Browser

maybe some PureBasic Experts can help you out more ,
and look into SpiderBasic
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
User avatar
minimy
Enthusiast
Enthusiast
Posts: 336
Joined: Mon Jul 08, 2013 8:43 pm

Re: webGadget audio question

Post by minimy »

Hi VB6_to_PBx, yes. The good formats for web are mp4,webm and ogv.
Nice job!

I will be noob for ever, after lot of years programming.. lol. :mrgreen:

Thanks and happy christmas friend!
If translation=Error: reply="Sorry, Im Spanish": Endif
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 617
Joined: Mon May 09, 2011 9:36 am

Re: webGadget audio question

Post by VB6_to_PBx »

minimy wrote:Hi VB6_to_PBx, yes. The good formats for web are mp4,webm and ogv.
Nice job!

I will be noob for ever, after lot of years programming.. lol. :mrgreen:

Thanks and happy christmas friend!
glad it helped you ,
and have a Merry Christmas to you and yours !
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
User avatar
minimy
Enthusiast
Enthusiast
Posts: 336
Joined: Mon Jul 08, 2013 8:43 pm

Re: webGadget audio question

Post by minimy »

Hey VB2PB sorry i no see your post.
Many, many thanks friend! Be happy and be safe!
If translation=Error: reply="Sorry, Im Spanish": Endif
Post Reply