mIRC Home    About    Download    Register    News    Help

Print Thread
#137267 10/12/05 08:46 PM
Joined: Dec 2005
Posts: 4
R
Self-satisified door
OP Offline
Self-satisified door
R
Joined: Dec 2005
Posts: 4
How can I make an MP3 player play .wma? because i have this mp3 player in my script but it only play loads my .mp3s and not my .wmas.
Can somebody help me

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
You can use the WMP object model to play audio files. Half a year ago, out of pure boredom, I made some WMP controls, their usage should be straightforward.

Code:
; Windows Media PLayer controls
 [color:red]  [/color] 
alias wmp.playfile wmp main url $sfile($iif($1,$1-,$mircdir),Select an audio file)
alias wmp.play wmp controls play
alias wmp.pause wmp controls pause
alias wmp.stop wmp controls stop
alias wmp.next wmp controls next
alias wmp.previous wmp controls previous
alias wmp.fastforward wmp controls fastforward
alias wmp.fastreverse wmp controls fastreverse
 [color:red]  [/color] 
alias wmp.quit {
  if ($com(wmp.main)) {
    wmp main close
    tokenize 32 wmp.main wmp.controls wmp.settings wmp.currentmedia
    scon -r if ($com( $* )) .comclose $*
  }
}
 [color:red]  [/color] 
alias wmp.currentpos {
  if ($isid) return $wmp(controls,currentposition) 
  if ($1 !isnum 0-) return 
  wmp controls currentposition $1 
}
 [color:red]  [/color] 
alias wmp.currentposstring {
  if ($isid) return $wmp(controls,currentpositionstring)
  wmp controls currentpositionstring $$1
}
 [color:red]  [/color] 
alias wmp.volume {
  if ($isid) return $wmp(settings,volume,2) 
  if ($1 !isnum 0-100) return 
  wmp settings volume $1
}
 [color:red]  [/color] 
alias wmp.mute {
  if ($isid) return $wmp(settings,mute,2) 
  if (!$istok(true false,$1,32)) return 
  wmp settings mute $1
}
 [color:red]  [/color] 
alias wmp.info {
  /*
  This identifier obviously doesn't work until you've actually played something, as
  it retrieves the specified property of the currently or last playing song.

  Examples:

  artist
  album
  albumartist
  genre
  label
  language
  mood
  bitrate
  copyright
  currentbitrate
  description
  director
  originalindex
  duration
  filesize
  filetype
  isvbr
  mediatype
  peakvalue
  Producedby
  recordingtime
  releasedate
  sourceurl
  title
  titlenum
  UserLastPlayedTime
  PlayCount
  WM/BeatsPerMinute
  WM/Category
  WM/Codec
  WM/GenreID
  WM/ParentalRating
  WM/Producer
  WM/Year
  ...
  */
  return $wmp(currentmedia,getiteminfo,$$1)
}
 [color:red]  [/color] 
alias wmp {
  if (!$com(wmp.main)) .comopen wmp.main wmplayer.ocx 
  var %obj = wmp. $+ $1, %t
  if (!$com(%obj)) { 
    %t = $com(wmp.main,$1,2,dispatch* %obj) 
    if (!$com(%obj)) { 
      echo -ac info * WMP: error dispatching to %obj 
      return 
    }
  }
  if ($0 > 2) %t = $com(%obj,$2,$iif($2 == getiteminfo,3,4),$iif($3 isnum,uint,bstr*),$3-) 
  else %t = $com(%obj,$2,$iif($isid,3,1))
  return $com(%obj).result
}


For more information take a look at the WMP Object Model Reference


Gone.
Joined: Jan 2004
Posts: 6
Y
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
Y
Joined: Jan 2004
Posts: 6
When I use the

$wmp.info(sourceurl)

it doesnt retrieve the proper information. Somtimes it will just keep returning the same song, regardless of what song I have playing. Sometimes, I wont have a song playing at all, and it will return a song.

Any idea why it might be doing this?

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Quote:
Sometimes, I wont have a song playing at all, and it will return a song.

This is normal, take a look at the description of the properties, it explicitly states:

"it retrieves the specified property of the currently or last playing song."

Quote:
Somtimes it will just keep returning the same song, regardless of what song I have playing.


That's because what you are looking for is the url property, not the sourceurl property (I know, it's confusing)

Here: alias wmp.url return $wmp(main,url)


The /wmp.next and previous controls don't work right now, because you need to have multiple items in the playlist. I don't have the time or motivation right now to add that, I made these controls in a hurry, I don't use them myself.


Gone.
Joined: Jan 2004
Posts: 6
Y
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
Y
Joined: Jan 2004
Posts: 6
Thanks fiberoptics. I saw that in the description. I thought that it had meant, current song if one was playing, or last song if nothing is playing.

Works fine wth that though. thanks

Joined: Jan 2004
Posts: 6
Y
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
Y
Joined: Jan 2004
Posts: 6
Hey FIberoptics, I'm not sure if its something with Mirc 6.17 or not, since I didnt try to use the volume controls in 6.16. But, just in case anyone uses this, I'd figure I'd post back about it.

For some reason the two aliases.

alias wmp.volume {
if ($isid) return $wmp(settings,volume,2)
if ($1 !isnum 0-100) return
wmp settings volume $1
}

alias wmp.mute {
if ($isid) return $wmp(settings,mute,2)
if (!$istok(true false,$1,32)) return
wmp settings mute $1
}


the ,2 in $wmp(settings,volume,2) them is being used to set the volume for example, when its used as an identifier. I removed it on both of those aliases and they work fine now. I dont know that much about com though, So Im not sure if thats expected behavior or something in 6.17 that changed to affect that.

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Yea, those ,2 aren't supposed to be there, probably put them there out of habit as to retrieve a property from an object you specify $com(object,property,2)


Gone.

Link Copied to Clipboard