mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2005
Posts: 10
X
Xthar Offline OP
Pikka bird
OP Offline
Pikka bird
X
Joined: Aug 2005
Posts: 10
how can i play random songs wit hthe click of a button on the mp3 dialog

Joined: Aug 2005
Posts: 9
R
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
R
Joined: Aug 2005
Posts: 9
I assume you're writing an MP3 dialog, and not just asking how to play randomly on someone else's.

First of all, all of the songs on the playlist should be assigned an internal number i hope. Something like this would work, assuming playlist is 1-n, the variable %numsongs stores the total number of songs on the playlist and the alias play is what you use to start playjng a song.

Code:
on *:dialog:mp3_dialog_name:sclick:random_button_id: {
  var %rand = $rand(1,%numsongs)
  play %rand
}


"So long and thanks for all the fish"
Joined: Aug 2005
Posts: 10
X
Xthar Offline OP
Pikka bird
OP Offline
Pikka bird
X
Joined: Aug 2005
Posts: 10
no there not assigned to a number how do i make them assigen a number?
this is my whole mp3 script meby you can jus fix it
--------------------------------
dialog Mp3 {
title [X]thar [M]p3
size -1 -1 333 293
option dbu
list 1,23 2 289 230, vsbar
button "Play",3, 21 235 60 14
button "Stop",4, 21 272 60 14
button "Pause",5, 136 233 60 14
button "Resume",6, 138 272 60 14
button "Random",13, 193 252 60 14
button "Load Mp3s",7, 79 252 60 14
button "Vol Up",9, 252 233 60 14
button "Vol Down",10, 253 273 60 14
button "Close",11, 147 253 38 14,ok
icon 12, 1 1 333 239, Xthar.png, index
}
on *:dialog:Mp3:dclick:1: {
splay %mp3.dir $+ $did(1).seltext $+ .mp3
inc %songs | amsg 4[14Mp³4] 4[8Playing4] 4[14 $+ $nopath($did(Mp3,1).seltext) $+ 4] [14 $+ $round($calc($lof($inmp3.fname) / 1000000),2) $+ mb $+ $+ 4] [14 Length4:14 $+ $asctime($calc($mp3($inmp3.fname).length / 1024 + $timezone),n:ss)) $+ 4] 4[14 $calc($mp3($inmp3.fname).sample /1000) 14k4H14z 4] 4[14Played4:14 %songs Songs4] 4[14Mp³4]
}
on *:dialog:Mp3:sclick:3: { splay %mp3.dir $+ $did($dname,1).seltext $+ .mp3 }
on *:dialog:Mp3:sclick:7: {
set %mp3.dir $sdir="Find The Directory For Your Mp3 Player"
did -r $dname 1
var %a = $findfile(%mp3.dir,*.mp3,0,did -az $dname 1 $remove($nopath($1-),.mp3))
}
on *:dialog:Mp3:init:0: {
var %a = $findfile(%mp3.dir,*.mp3,0,did -az $dname 1 $remove($nopath($1-),.mp3))
}
on *:dialog:Mp3:sclick:4: {
splay stop
amsg 4[14Mp³4] 4[4Stoped] 4[14 $+ $nopath($did(Mp3,1).seltext) $+ 4] 4[14Mp³4]
}
on *:dialog:Mp3:sclick:5: {
splay pause
amsg 4[14Mp³4] [8Paused4] 4[14 $+ $nopath($did(Mp3,1).seltext) $+ 4] 4[14Mp³4]
}
on *:dialog:Mp3:sclick:13: {
something goes here
}
on *:dialog:Mp3:sclick:6: {
splay resume
amsg 4[14Mp³4] 4[8Resuming4] 4[14 $+ $nopath($did(Mp3,1).seltext) $+ 4] [14 $+ $round($calc($lof($inmp3.fname) / 1000000),2) $+ mb $+ $+ 4] [14 Length4:14 $+ $asctime($calc($mp3($inmp3.fname).length / 1024 + $timezone),n:ss)) $+ 4] 4[14 $calc($mp3($inmp3.fname).sample /1000) 14k4H14z 4] 4[14Played4:14 %songs Songs4] 4[14Mp³4]
}
on 1:dialog:Mp3:sclick:9: {
mp3bajar 2
}
on 1:dialog:Mp3:sclick:10: {
mp3subir 2
}
on 1:dialog:Mp3:init:0: {
set %mp3d 1
orale
did -ra Mp3 13 Vol $round($calc(( $vol(mp3) / 650 ) - 1 ),0) $+ %
}
alias -l mp3subir { /set %mp3vol $calc($vol(mp3) - ( $1 * 5000 )) | /vol -p %mp3vol | /unset %mp3vol | did -ra Mp3 13 Vol $round($calc( $vol(mp3) / 650 ),0) $+ % }
alias -l mp3bajar { /set %mp3vol $calc($vol(mp3) + ( $1 * 5000 )) | /vol -p %mp3vol | /unset %mp3vol | did -ra Mp3 13 Vol $round($calc(($vol(mp3) / 650 ) - 1 ),0) $+ % }
------------------------------------

Last edited by Xthar; 18/08/05 03:59 AM.
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Please use the Code tags. They make reading code a lot easier.

Joined: Aug 2005
Posts: 10
X
Xthar Offline OP
Pikka bird
OP Offline
Pikka bird
X
Joined: Aug 2005
Posts: 10
Code:
 dialog Mp3 {
title [X]thar [M]p3
size -1 -1 333 293
option dbu
list 1,23 2 289 230, vsbar
button "Play",3, 21 235 60 14
button "Stop",4, 21 272 60 14
button "Pause",5, 136 233 60 14
button "Resume",6, 138 272 60 14
button "Random",13, 193 252 60 14
button "Load Mp3s",7, 79 252 60 14
button "Vol Up",9, 252 233 60 14
button "Vol Down",10, 253 273 60 14
button "Close",11, 147 253 38 14,ok
icon 12, 1 1 333 239, Xthar.png, index
}
on *:dialog:Mp3:dclick:1: {
splay %mp3.dir $+ $did(1).seltext $+ .mp3
inc %songs | amsg 4[14Mp³4] 4[8Playing4] 4[14 $+ $nopath($did(Mp3,1).seltext) $+ 4] [14 $+ $round($calc($lof($inmp3.fname) / 1000000),2) $+ mb $+ $+ 4] [14 Length4:14 $+ $asctime($calc($mp3($inmp3.fname).length / 1024 + $timezone),n:ss)) $+ 4] 4[14 $calc($mp3($inmp3.fname).sample /1000) 14k4H14z 4] 4[14Played4:14 %songs Songs4] 4[14Mp³4]
}
on *:dialog:Mp3:sclick:3: { splay %mp3.dir $+ $did($dname,1).seltext $+ .mp3 }
on *:dialog:Mp3:sclick:7: {
set %mp3.dir $sdir="Find The Directory For Your Mp3 Player"
did -r $dname 1
var %a = $findfile(%mp3.dir,*.mp3,0,did -az $dname 1 $remove($nopath($1-),.mp3))
}
on *:dialog:Mp3:init:0: {
var %a = $findfile(%mp3.dir,*.mp3,0,did -az $dname 1 $remove($nopath($1-),.mp3))
}
on *:dialog:Mp3:sclick:4: {
splay stop
amsg 4[14Mp³4] 4[4Stoped] 4[14 $+ $nopath($did(Mp3,1).seltext) $+ 4] 4[14Mp³4]
}
on *:dialog:Mp3:sclick:5: {
splay pause
amsg 4[14Mp³4] [8Paused4] 4[14 $+ $nopath($did(Mp3,1).seltext) $+ 4] 4[14Mp³4]
}
on *:dialog:Mp3:sclick:13: {
something goes here
}
on *:dialog:Mp3:sclick:6: {
splay resume
amsg 4[14Mp³4] 4[8Resuming4] 4[14 $+ $nopath($did(Mp3,1).seltext) $+ 4] [14 $+ $round($calc($lof($inmp3.fname) / 1000000),2) $+ mb $+ $+ 4] [14 Length4:14 $+ $asctime($calc($mp3($inmp3.fname).length / 1024 + $timezone),n:ss)) $+ 4] 4[14 $calc($mp3($inmp3.fname).sample /1000) 14k4H14z 4] 4[14Played4:14 %songs Songs4] 4[14Mp³4]
}
on 1:dialog:Mp3:sclick:9: {
mp3bajar 2
}
on 1:dialog:Mp3:sclick:10: {
mp3subir 2
}
on 1:dialog:Mp3:init:0: {
set %mp3d 1
orale
did -ra Mp3 13 Vol $round($calc(( $vol(mp3) / 650 ) - 1 ),0) $+ %
}
alias -l mp3subir { /set %mp3vol $calc($vol(mp3) - ( $1 * 5000 )) | /vol -p %mp3vol | /unset %mp3vol | did -ra Mp3 13 Vol $round($calc( $vol(mp3) / 650 ),0) $+ % }
alias -l mp3bajar { /set %mp3vol $calc($vol(mp3) + ( $1 * 5000 )) | /vol -p %mp3vol | /unset %mp3vol | did -ra Mp3 13 Vol $round($calc(($vol(mp3) / 650 ) - 1 ),0) $+ % }  

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Try:

Code:
on *:dialog:Mp3:sclick:13: {
  var %file = $findfile(%mp3.dir,*.mp3,$rand(1,$findfile(%mp3.dir,*.mp3,0)))
  splay %file
  did -c mp3 1 $didwm(mp3,1,$nopath($remove(%file,.mp3)),1)
}

Joined: Aug 2005
Posts: 10
X
Xthar Offline OP
Pikka bird
OP Offline
Pikka bird
X
Joined: Aug 2005
Posts: 10
yo dude thx for the help but i need it so that when ya hit the play button and play a song and after the song is over it will play a nother random song ya know what i mean

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Ok, clicking the Stop or Play button will unset the Random Play setting, so you have a way to disable it. Sorry it took so long for me to reply, I had to play a song and wait for it to end to see if it still played randomly.

Try..

Code:
dialog Mp3 {
  title [X]thar [M]p3
  size -1 -1 333 293
  option dbu
  list 1,23 2 289 230, vsbar
  button "Play",3, 21 235 60 14
  button "Stop",4, 21 272 60 14
  button "Pause",5, 136 233 60 14
  button "Resume",6, 138 272 60 14
  button "Random",13, 193 252 60 14
  button "Load Mp3s",7, 79 252 60 14
  button "Vol Up",9, 252 233 60 14
  button "Vol Down",10, 253 273 60 14
  button "Close",11, 147 253 38 14,ok
}
on *:dialog:Mp3:dclick:1: {
  splay %mp3.dir $+ $did(1).seltext $+ .mp3
  inc %songs | amsg 4[14Mp³4] 4[8Playing4] 4[14 $+ $nopath($did(Mp3,1).seltext) $+ 4] [14 $+ $round($calc($lof($inmp3.fname) / 1000000),2) $+ mb $+ $+ 4] [14 Length4:14 $+ $asctime($calc($mp3($inmp3.fname).length / 1024 + $timezone),n:ss)) $+ 4] 4[14 $calc($mp3($inmp3.fname).sample /1000) 14k4H14z 4] 4[14Played4:14 %songs Songs4] 4[14Mp³4]
}
on *:dialog:Mp3:sclick:3: { 
  splay %mp3.dir $+ $did($dname,1).seltext $+ .mp3
  set %rand $iif(%rand == 1,0,1)
}
on *:dialog:Mp3:sclick:7: {
  set %mp3.dir $sdir="Find The Directory For Your Mp3 Player"
  did -r $dname 1
  var %a = $findfile(%mp3.dir,*.mp3,0,did -az $dname 1 $remove($nopath($1-),.mp3))
}
on *:dialog:Mp3:init:0: {
  var %a = $findfile(%mp3.dir,*.mp3,0,did -az $dname 1 $remove($nopath($1-),.mp3))
}
on *:dialog:Mp3:sclick:4: {
  splay stop
  set %rand $iif(%rand == 1,0,1)
  amsg 4[14Mp³4] 4[4Stoped] 4[14 $+ $nopath($did(Mp3,1).seltext) $+ 4] 4[14Mp³4]
}
on *:dialog:Mp3:sclick:5: {
  splay pause
  amsg 4[14Mp³4] [8Paused4] 4[14 $+ $nopath($did(Mp3,1).seltext) $+ 4] 4[14Mp³4]
}
on *:dialog:Mp3:sclick:13: {
  random.play
}
on *:dialog:Mp3:sclick:6: {
  splay resume
  amsg 4[14Mp³4] 4[8Resuming4] 4[14 $+ $nopath($did(Mp3,1).seltext) $+ 4] [14 $+ $round($calc($lof($inmp3.fname) / 1000000),2) $+ mb $+ $+ 4] [14 Length4:14 $+ $asctime($calc($mp3($inmp3.fname).length / 1024 + $timezone),n:ss)) $+ 4] 4[14 $calc($mp3($inmp3.fname).sample /1000) 14k4H14z 4] 4[14Played4:14 %songs Songs4] 4[14Mp³4]
}
on 1:dialog:Mp3:sclick:9: {
  mp3bajar 2
}
on 1:dialog:Mp3:sclick:10: {
  mp3subir 2
}
on 1:dialog:Mp3:init:0: {
  set %mp3d 1
  orale
  did -ra Mp3 13 Vol $round($calc(( $vol(mp3) / 650 ) - 1 ),0) $+ %
}

On *:Mp3end: {
  if (%rand) random.play
}

alias random.play {
  %file = $findfile(%mp3.dir,*.mp3,$rand(1,$findfile(%mp3.dir,*.mp3,0)))
  %rand = 1
  splay %file
  if ($dialog(mp3)) did -c mp3 1 $didwm(mp3,1,$nopath($remove(%file,.mp3)),1)
}

alias -l mp3subir { /set %mp3vol $calc($vol(mp3) - ( $1 * 5000 )) | /vol -p %mp3vol | /unset %mp3vol | did -ra Mp3 13 Vol $round($calc( $vol(mp3) / 650 ),0) $+ % }
alias -l mp3bajar { /set %mp3vol $calc($vol(mp3) + ( $1 * 5000 )) | /vol -p %mp3vol | /unset %mp3vol | did -ra Mp3 13 Vol $round($calc(($vol(mp3) / 650 ) - 1 ),0) $+ % } 

Joined: Aug 2005
Posts: 10
X
Xthar Offline OP
Pikka bird
OP Offline
Pikka bird
X
Joined: Aug 2005
Posts: 10
thx dude it works


Link Copied to Clipboard