We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Oh my gosh!!
#1
I've made a media player w/ Small Basic!!

Requirements: LitDev 1.2.30.0 Beta and higher
ID: FMBV557.000
Link: https://smallbasic.com/program/?FMBV557.000

Code:
Init()

Sub Init
 
  GraphicsWindow.BackgroundColor = "#FF408080"
 
  GraphicsWindow.Title = "Untitled Small Media Player Window"
  GraphicsWindow.BrushColor = "Black"
  GraphicsWindow.FontName = "MS Gothic"
  SlFlBtn = Controls.AddButton("Select File",20,140)
  Controls.SetSize(SlFlBtn,101,25)
 
  PlayBtn = Controls.AddButton("Play",20,170)
  Controls.SetSize(PlayBtn,101,25)
 
  GraphicsWindow.BrushColor = "#FF000040"
  GraphicsWindow.PenColor = "#FF000040"
  Overlay = Shapes.AddRectangle(530,290)
  Shapes.Move(Overlay,220,100)
 
  GraphicsWindow.BrushColor = "Black"
  GraphicsWindow.FontName = "Times New Roman"
  GraphicsWindow.FontBold = "False"
  NmWnTb = Controls.AddTextBox(20,100)
  Controls.SetTextBoxText(NmWnTb,"")
  Controls.SetSize(NmWnTb,100,25)
 
  GraphicsWindow.FontName = "MS Gothic"
  GraphicsWindow.FontBold = "True"
  SubmitBtn = Controls.AddButton("Submit",140,100)
  Controls.SetSize(SubmitBtn,51,25)
 
  GraphicsWindow.FontName = "Ubuntu Mono"
  GraphicsWindow.FontBold = "False"
  LabelNmWn = Shapes.AddText("Name Window:")
  Controls.SetSize(LabelNmWn,87,15)
  Shapes.Move(LabelNmWn,20,80)
 
  GraphicsWindow.BrushColor = "#FFFFFF80"
  GraphicsWindow.FontName = "Segoe UI"
  GraphicsWindow.FontBold = "True"
  GraphicsWindow.FontSize = 24
  Logo = Shapes.AddText("Basic Media Player")
  Controls.SetSize(Logo,220,30)
  Shapes.Move(Logo,0,0)
  GraphicsWindow.FontBold = "False"
 
  GraphicsWindow.BrushColor = "Black"
  GraphicsWindow.FontName = "MS Gothic"
  GraphicsWindow.FontSize = 12
  GraphicsWindow.FontBold = "True"
  AboutBtn = Controls.AddButton("About",230,10)
  Controls.SetSize(AboutBtn,51,25)
 
  LicenseBtn = Controls.AddButton("Licensing",290,10)
  Controls.SetSize(LicenseBtn,71,25)
 
  MediaPlayer = LDControls.AddMediaPlayer(530,290)
  Shapes.Move(MediaPlayer,220,100)
 
  PauseBtn = Controls.AddButton("Pause",20,200)
  Controls.SetSize(PauseBtn,101,24.5)
 
  LDControls.MediaPlayerEnded = Pause
  Controls.ButtonClicked = Onclick
 
EndSub
  Sub Pause
    LDControls.MediaPlayerPause(MediaPlayer)
  EndSub
  Sub Onclick
    last = Controls.LastClickedButton
    If last = SubmitBtn Then
      windowname = Controls.GetTextBoxText(NmWnTb)
      GraphicsWindow.Title = windowname
    ElseIf last = LicenseBtn Then
      GraphicsWindow.ShowMessage("GPLv3", "")
    ElseIf last = AboutBtn Then
      GraphicsWindow.ShowMessage("You have the right to modify and republish the altered software. Created by sm4llprogrammer2008", "")
    ElseIf last = SlFlBtn Then
      getfile = LDDialogs.OpenFile("1=png;2=jpg;3=mp3;4=wav;5=mp4","")
    ElseIf last = PlayBtn Then
      LDControls.MediaPlayerLoad(MediaPlayer, getfile)
      LDControls.MediaPlayerPlay(MediaPlayer)
    ElseIf last = PauseBtn Then
      LDControls.MediaPlayerPause(MediaPlayer)
    EndIf
  EndSub

Feel free to expand, again!
[-] The following 3 users Like sm4llprogrammer2008's post:
  • AbsoluteBeginner, litdev, z-s
Reply


Messages In This Thread
Oh my gosh!! - by sm4llprogrammer2008 - 04-19-2025, 05:48 PM
RE: Oh my gosh!! - by martmen - 05-05-2025, 02:42 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)