[DarkBASIC] Basic media player menu

User Tag List

Results 1 to 5 of 5
  1. #1
    warsheep's Avatar Contributor
    Reputation
    184
    Join Date
    Sep 2006
    Posts
    1,216
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [DarkBASIC] Basic media player

    Ok, this is a simple media player I've been working on. So far, I wont release the whole source, but instead, a little piece to get you going.

    I'll write this in a guideish way, if you just want the source, go the the bottom.
    Code:
    print "Type your song. Remember the file type! (.mp3 or something)"
    input " ", songname$
    This will display "Type your song. Remember the file type! (.mp3 or something)" on the screen, and it will await the user to type in something.
    What the user types in, will be saved as songname$.

    Now, we'd want the program to check up for the song, and play it.
    Code:
    LOAD MUSIC songname$, 1
    PLAY MUSIC 1
    Now, what happens is that the music gets loaded into the program, and will start to play it. Though, this will be almost nothing, we'll need a stop and resume function, as well as some eye candy!

    So, add
    goto menu
    in the above code.

    Now, add a few empty lines, and write
    menu:

    Below this, write
    [code]
    cls
    sync : center text screen width()/2,screen height()/3,"Now playing:" : sync
    sync : center text screen width()/2,screen height()/2,songname$ : sync
    [code]
    This one is a bit though to explain, though, its a bit easy if you think over it.
    Sync, updates the screen or something.. tbh, I aint 100% sure what it does, so I wont try to explain it. The rest of the code will center some text, display "now playing:" and the value of songname below.

    Now, for a stop/new/play function, go back to the beginning, and write
    start:

    That is to add a way back, in case the listener wants to change the song.

    So far, the code should look somewhat like this:
    Code:
    print "Type your song. Remember the file type! (.mp3 or something)"
    start:
    input " ", songname$
    
    
    
    LOAD MUSIC songname$, 1
    PLAY MUSIC 1
    goto menu
    
    
    
    
    menu:
    cls
    sync : center text screen width()/2,screen height()/3,"Now playing:" : sync
    sync : center text screen width()/2,screen height()/2,songname$ : sync
    As you can see, we don't really need the goto menu function, as the program would just go there since there is no code in between, but if you make the application bigger, it gets nice to be able to travel between the functions easier.

    Now, we'd want to add a option for the user to type in "new" to choose a new song, or, to direct the program to the beginning, "pause" to pause the music, and "play" to resume it.

    The following code goes below the current one.
    Code:
    input " ", Menu$
    
    rem We'll wait for any key to be pressed. Lets hope they find the any key!
    If Menu$ = "new"
    
    rem Giving a notice that they have choosed a new one
      print "Select a new song"
    
    rem Lets stop the music, else it will all becomme rather messy!
      STOP MUSIC 1
    
    rem As the song is already stored as song number 1, we'll need to clear it.
      DELETE MUSIC 1
    rem The music is stopped.
    
    rem Going back to the process of getting a new song!
      cls
      goto start
    
    rem We're closing the new check.
    endif
    
    if Menu$ = "pause"
      print "Paused."
      PAUSE MUSIC 1
      wait 1000
      goto menu
    endif
    
    if Menu$ = "play"
      Print "Resumed"
      RESUME MUSIC 1
      wait 1000
      goto menu
    endif
    
    print "could not understand command!"
    Ok, if you look over it, its going to look at it this way:
    If menu$ = "valueish"
    If that is correct, it will run that code. If NOT, it will find the endif tag, and continue from there. If you look over it, its rather basic and easy to understand, so I aint going to explain it that much. If you notice, in the end, its a print command, the reason I can place it there is because the code hasn't been picked up, there has been no results, which means that it could not understand the command.

    That should be it, I think... If it has any bugs, then I challenge you to find it, because that would be a great way to learn.

    Anyways, going to get some sleep, its 03:31, haven't slept for a while, + got the news that my grandpa died not long ago.. :/

    goodnight!
    (Ps: Adding the full code here tomorrow, + I'll look over it to make sure it works as it should)
    FOR A MOMENT, NOTHING HAPPENED. THEN, AFTER A SECOND OR SO, NOTHING CONTINUED TO HAPPEN.

    [DarkBASIC] Basic media player
  2. #2
    ReidE96's Avatar Archer Authenticator enabled
    Reputation
    470
    Join Date
    Dec 2006
    Posts
    1,625
    Thanks G/R
    1/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nicely done warsheep, I see you managed to finish it off +Rep for you.

    A little tip: You might want to consider learning the FUNCTION command. It could make this code rather different, and much simpler.

  3. #3
    warsheep's Avatar Contributor
    Reputation
    184
    Join Date
    Sep 2006
    Posts
    1,216
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, working on the functions now.... Its a bit... Weird, tbh, but VERY helpful.

    Anyways, this isn't really the media player I am working on, this is some leftover code which I tested with, my media player is a bit more advanced atm.

    Btw, thanks Reid!
    FOR A MOMENT, NOTHING HAPPENED. THEN, AFTER A SECOND OR SO, NOTHING CONTINUED TO HAPPEN.

  4. #4
    ReidE96's Avatar Archer Authenticator enabled
    Reputation
    470
    Join Date
    Dec 2006
    Posts
    1,625
    Thanks G/R
    1/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem Functions will make your life easier, because instead of jumping to different points in the code, you can just call the function again, making the code much neater. GOTO is generally used for something like an installer, where if they chose, say, custom install they could pick the settings manually, where if they chose, say, express install you could GOTO the installing part and have it use the default settings.

  5. #5
    warsheep's Avatar Contributor
    Reputation
    184
    Join Date
    Sep 2006
    Posts
    1,216
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I could've done that with the pause and play functions, perhaps even the play function, to avoid having to do it all so hard...
    FOR A MOMENT, NOTHING HAPPENED. THEN, AFTER A SECOND OR SO, NOTHING CONTINUED TO HAPPEN.

Similar Threads

  1. Windows Media Player WoW Theme!
    By Hiddennoremac in forum World of Warcraft General
    Replies: 0
    Last Post: 11-07-2008, 03:44 AM
  2. [media player] vlc media player
    By tangos in forum Community Chat
    Replies: 10
    Last Post: 04-20-2008, 11:11 PM
  3. Windows media player helps wow load faster?
    By gladiator101 in forum World of Warcraft Guides
    Replies: 10
    Last Post: 01-30-2008, 04:56 AM
  4. Media Player speed up WoW.
    By Viiper in forum World of Warcraft Exploits
    Replies: 8
    Last Post: 12-31-2007, 12:03 PM
All times are GMT -5. The time now is 07:39 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search