Mp3 Script

By jaillyn on Jun 24, 2013

An old mp3 script of mine. There's a mysterious issue of the thing forgetting what folder it's set to (as it'll jump to the last folder I picked a song out of for some reason..) But aside from that, it does what I want.

It runs your default mp3 player for playing songs. I guess if you used this to play videos it'd function.. etc.

It plays the song and there's another command to choose if you want the song file to display in channel.

The color choices are part of an elaborate color scheme thing I had set up that's partially scrapped at the moment... I guess I should trim that out for posting here.

on *:load:{
  if (%c1 == $null) set %c1 = 2
  if (%c2 == $null) set %c2 = 6
  if (%c3 == $null) set %c3 = 
}
menu Channel,Query,MenuBar {
  Cabbit AMP 1.5
  .Setup Window:dialog -mn mp3player mp3player
  .Play Song:selectsong
  .Play Random Song:randomsong
  .Display Song:showsong
}

alias F5 { selectsong }
alias F6 { randomsong }
alias F7 { showsong }
alias F8 { dialog -mn mp3player mp3player }

dialog mp3player {
  title "Cabbit AMP 1.5"
  size -1 -1 190 60
  option dbu

  tab "Music Settings",1, 5 5 140 50
  tab "Color Picker",2

  edit %mp3.dir, 4, 10 24 130 10, read, tab 1
  button "Select Music Folder", 5, 10 39 64 12, tab 1
  button "Clear Music Folder", 6, 75 39 64 12, tab 1

  text "Color 1:", 35, 10 25 30 8, tab 2
  combo 36, 30 24 38 117, drop size, tab 2
  text "Color 2:", 37, 80 25 30 8, tab 2
  combo 38, 102 24 38 117, drop size, tab 2
  text "Color 3:", 39, 10 41 30 8, tab 2
  combo 40, 30 40 38 117, drop size, tab 2
  button "Randomize", 41, 105 39 34 12, tab 2
  button "Default", 42, 70 39 34 12, tab 2

  button "OK", 80, 150 26 34 12, ok
  button "Cancel", 81, 150 39 34 12, cancel

}
on *:dialog:mp3player:*:*:{
  if ($devent == init) {
    if (%fullmode == on) { did -c $dname 16 }
    did -r $dname 36,38,40
    did -a $dname 36,38,40 Black
    did -a $dname 36,38,40 Dark Blue
    did -a $dname 36,38,40 Dark Green
    did -a $dname 36,38,40 Red
    did -a $dname 36,38,40 Brown
    did -a $dname 36,38,40 Purple
    did -a $dname 36,38,40 Orange
    did -a $dname 36,38,40 Yellow
    did -a $dname 36,38,40 Green
    did -a $dname 36,38,40 Teal
    did -a $dname 36,38,40 Cyan
    did -a $dname 36,38,40 Blue
    did -a $dname 36,38,40 Pink
    did -a $dname 36,38,40 Dark Grey
    did -a $dname 36,38,40 Grey
    if (%c1 == ) { did -c $dname 36 1 }
    else { did -c $dname 36 $calc($right(%c1,2)) }
    if (%c2 == ) { did -c $dname 38 1 }
    else { did -c $dname 38 $calc($right(%c2,2)) }
    if (%c3 == ) { did -c $dname 40 1 }
    else { did -c $dname 40 $calc($right(%c3,2)) }
  }
  if ($devent == sclick) {
    if ($did == 5) { set %mp3.dir $sdir="Locate Mp3 Directory" | did -ra mp3player 4 %mp3.dir }
    if ($did == 6) { set %mp3.dir | did -ra mp3player 4 %mp3.dir }
    if ( $calc($did(36).sel) == 1 ) { set %c1  }
    elseif ( $calc( $did(36).sel ) < 10 ) { set %c1  $+ 0 $+ $calc($did(36).sel) }
    else { set %c1  $+ $calc($did(36).sel) }
    if ( $calc($did(38).sel) == 1 ) { set %c2  }
    elseif ( $calc($did(38).sel) < 10 ) { set %c2  $+ 0 $+ $calc($did(38).sel) }
    else { set %c2  $+ $calc($did(38).sel) }
    if ( $calc($did(40).sel) == 1 ) { set %c3  }
    elseif ( $calc($did(40).sel) < 10 ) { set %c3  $+ 0 $+ $calc($did(40).sel) }
    else { set %c3  $+ $calc($did(40).sel) }
    if ($did == 41) { did -c $dname 36 $rand(1,15) | did -c $dname 38 $rand(1,15) | did -c $dname 40 $rand(1,15) }
    if ($did == 42) { did -c $dname 36 2 | did -c $dname 38 6 | did -c $dname 40 1 }
  }
}

alias selectsong {
  set %mp3.file $$file="Select File" %mp3.dir 
  if (%mp3.file == $null) { halt } 
  else { run %mp3.file | editsong | unset %mp3.file }
}

alias randomsong {
  set %mp3.num $findfile(%mp3.dir,*.mp3,0)
  set %mp3.ran2 $rand(1,%mp3.num) 
  set %mp3.file $findfile(%mp3.dir,*.mp3,%mp3.ran2)
  run %mp3.file
  editsong
  unset %mp3.file
}

alias editsong { %mp3.file2 = $remove($nopath(%mp3.file),.mp3,.ogg,.mid,.m3u,) } 
alias showsong { describe $active is playing: %c1 $+ %mp3.file2  }

Comments

Sign in to comment.
IllogicTC   -  Jun 30, 2013

Not sure on the bug, but check line 72. Everywhere else the dialog is referenced using "mp3player," but in this one line you have just "mp3."

Also, I see under the alias randomsong you're setting global variables when you could get by using the temporary /var function. %mp3.num and %mp3.ran2 can be set with a var instead, since they aren't ever used outside the alias and only set up data for the next script line.

jaillyn  -  Jul 01, 2013

Fixed line 72. I was converting the dialog/commands before posting and I missed one.

Yeah I modified that on my local copy trying to fix the 'folder issue' I'm having. Nothing I've tried seems to work in making the script remember to open from the folder I choose.. keeps defaulting to wherever I last opened an mp3... well, not always. it decides randomly when it's going to start doing that and I have to unload/load the mrc file to get it going again.

Savage_CL  -  Aug 09, 2013

Your problem is in using $$file=""

$sfile(dir,title,oktext)

Displays the select file dialog and returns the selected filename. Title and oktext are optional. The dir can include a wildcard as a file mask.

That's from the help file. Should make your life easier.

jaillyn  -  Aug 09, 2013

that caused the lil glitch I mentioned to happen immediately :(

Savage_CL  -  Aug 09, 2013

You would define the directory, as so:

var %directory = $sfile("C:/Users/<some user>/Music/",Select Song,Select)
Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.