Sign in to follow this  
Followers 0
nobbe

WMA or MP3 Information Tags

3 posts in this topic

hi

thanks for all help on this

i was trying to get the info tags from a media file

may my result be useful to others too

;===============================================================================

Global $oPlayer = ObjCreate("WMPlayer.OCX")

$song = @ScriptDir & "\test.wma" ; requires full path name ... 
$song = @ScriptDir & "\test1.wma" ; requires full path name ... 
$song = @ScriptDir & "\test.mp3" ; requires full path name ... 

$rc = WMLoadFile($oPlayer, $song)
MsgBox(0, "1 rc", $rc)

$rc = WMGetDuration($oPlayer);
MsgBox(0, "2 rc", $rc)

$rc = $oPlayer.currentmedia.durationstring() ; in   min:sec
MsgBox(0, "3 rc", $rc)

$rc = $oPlayer.mediaCollection.add($song) ; Full path required .. 
MsgBox(0, "4 rc", $rc) ; rc<> 0 ??

$rc = $oPlayer.currentmedia.name() ; name of file (from TAG !)
;MsgBox(0, "5 rc", $rc)

$rc = $oPlayer.currentMedia.getItemInfobyAtom($oPlayer.mediaCollection.getMediaAtom("Artist"));
MsgBox(0, "6a rc", $rc)

$rc = $oPlayer.currentMedia.getItemInfobyAtom($oPlayer.mediaCollection.getMediaAtom("Title")); 
MsgBox(0, "6b rc", $rc)

$rc = $oPlayer.currentMedia.getItemInfobyAtom($oPlayer.mediaCollection.getMediaAtom("Album"));
MsgBox(0, "6c rc", $rc)

$rc = $oPlayer.currentMedia.getItemInfobyAtom($oPlayer.mediaCollection.getMediaAtom("Bitrate"));
MsgBox(0, "6d rc", $rc)

$rc = $oPlayer.currentMedia.getItemInfobyAtom($oPlayer.mediaCollection.getMediaAtom("CreationDate"));
MsgBox(0, "6e rc", $rc)

$rc = $oPlayer.currentMedia.getItemInfobyAtom($oPlayer.mediaCollection.getMediaAtom("Genre"));
MsgBox(0, "6f rc", $rc)

$rc = $oPlayer.currentMedia.getItemInfobyAtom($oPlayer.mediaCollection.getMediaAtom("Copyright")); the copyright holder-- 
MsgBox(0, "6g rc", $rc)


; media player possible asks for upgrade on installed DRM system?
$rc = $oPlayer.currentMedia.getItemInfobyAtom($oPlayer.mediaCollection.getMediaAtom("Is_Protected"));   0 = NO DRM / -1 = DRM
MsgBox(0, "6h rc", $rc) 

#cs
Audio Item Attributes

The following attributes are available for an audio item in the library.

    * AcquisitionTime Attribute
    * AlbumID Attribute
    * AlbumIDAlbumArtist Attribute
    * Author Attribute
    * AverageLevel Attribute
    * Bitrate Attribute
    * BuyNow Attribute
    * BuyTickets Attribute
    * Channels Attribute
    * Copyright Attribute
    * CurrentBitrate Attribute
    * Duration Attribute
    * FileSize Attribute
    * FileType Attribute
    * Is_Protected
    * IsVBR Attribute
    * MediaType Attribute
    * MoreInfo Attribute
    * PartOfSet Attribute
    * PeakValue Attribute
    * PlaylistIndex Attribute
    * ProviderLogoURL Attribute
    * ProviderURL Attribute
    * RecordingTime Attribute
    * RecordingTimeDay Attribute
    * RecordingTimeMonth Attribute
    * RecordingTimeYear Attribute
    * RecordingTimeYearMonth Attribute
    * RecordingTimeYearMonthDay Attribute
    * ReleaseDate Attribute
    * ReleaseDateDay Attribute
    * ReleaseDateMonth Attribute
    * ReleaseDateYear Attribute
    * ReleaseDateYearMonth Attribute
    * ReleaseDateYearMonthDay Attribute
    * RequestState Attribute
    * ShadowFilePath Attribute
    * SourceURL Attribute
    * SyncState Attribute
    * Title Attribute
    * TrackingID Attribute
    * UserCustom1 Attribute
    * UserCustom2 Attribute
    * UserEffectiveRating Attribute
    * UserLastPlayedTime Attribute
    * UserPlayCount Attribute
    * UserPlaycountAfternoon Attribute
    * UserPlaycountEvening Attribute
    * UserPlaycountMorning Attribute
    * UserPlaycountNight Attribute
    * UserPlaycountWeekday Attribute
    * UserPlaycountWeekend Attribute
    * UserRating Attribute
    * UserServiceRating Attribute
    * WM/AlbumArtist Attribute
    * WM/AlbumTitle Attribute
    * WM/Category Attribute
    * WM/Composer Attribute
    * WM/Conductor Attribute
    * WM/ContentDistributor Attribute
    * WM/ContentGroupDescription Attribute
    * WM/EncodingTime Attribute
    * WM/Genre Attribute
    * WM/GenreID Attribute
    * WM/InitialKey Attribute
    * WM/Language Attribute
    * WM/Lyrics Attribute
    * WM/MCDI Attribute
    * WM/MediaClassPrimaryID Attribute
    * WM/MediaClassSecondaryID Attribute
    * WM/Mood Attribute
    * WM/ParentalRating Attribute
    * WM/Period Attribute
    * WM/ProtectionType Attribute
    * WM/Provider Attribute
    * WM/ProviderRating Attribute
    * WM/ProviderStyle Attribute
    * WM/Publisher Attribute
    * WM/SubscriptionContentID Attribute
    * WM/SubTitle Attribute
    * WM/TrackNumber Attribute
    * WM/UniqueFileIdentifier Attribute
    * WM/WMCollectionGroupID Attribute
    * WM/WMCollectionID Attribute
    * WM/WMContentID Attribute
    * WM/Writer Attribute
    * WM/Year Attribute


#ce

; turns the volume down and back up slowly...
For $i = 100 To 0 Step - 1
    WMSetVolume($oPlayer, $i)
    Sleep(10)
Next
For $i = 0 To 100
    WMSetVolume($oPlayer, $i)
    Sleep(10)
Next

MsgBox(0, "pause", "")

WMPause($oPlayer)

Sleep(300)

MsgBox(0, "play", "")


$rc = WMGetPosition($oPlayer)
MsgBox(0, "POS", $rc)


WMPlay($oPlayer)

Sleep(3000)

MsgBox(0, "stop","")
WMStop($oPlayer)

exit ; ----------------------------


; some functions
Func WMLoadFile($wm_obj, $sFilename)
    $wm_obj.url = $sFilename
    While Not WMGetState($wm_obj) = "Playing"
        Sleep(100)
    WEnd
EndFunc   ;==>WMLoadFile

Func WMSetVolume($wm_obj, $iVol)
    ;iVol can be between 0 and 100
    $wm_obj.settings.volume = $iVol
EndFunc   ;==>WMSetVolume

Func WMFastForward($wm_obj)
    $wm_obj.controls.fastForward()
EndFunc   ;==>WMFastForward

Func WMReverse($wm_obj)
    $wm_obj.controls.fastReverse()
EndFunc   ;==>WMReverse

Func WMPause($wm_obj)
    $wm_obj.controls.pause()
EndFunc   ;==>WMPause

Func WMPlay($wm_obj)
    $wm_obj.controls.play()
EndFunc   ;==>WMPlay

Func WMStop($wm_obj)
    $wm_obj.controls.stop()
EndFunc   ;==>WMStop

Func WMGetPosition($wm_obj)
    local $pos
    $pos = $wm_obj.controls.currentPosition ()
    return $pos
EndFunc   ;==>WMGetPosition

Func WMGetDuration($wm_obj)
    Local $len
    $len = $wm_obj.currentMedia.duration
    Return $len

EndFunc   ;==>WMGetDuration



Func WMGetState($wm_obj)
    local $sStates = "Undefined,Stopped,Paused,Playing,ScanForward,ScanReverse,Buffering,"
    $sStates &= "Waiting,MediaEnded,Transitioning,Ready,Reconnecting"
    local $aStates = StringSplit($sStates, ",")
    $iState = $wm_obj.playState ()
    Return $aStates[$iState]
EndFunc   ;==>WMGetState

Share this post


Link to post
Share on other sites



This is neat, but I have a question...

If I already have a song playing in Media Player, how can I get the tag info of the currently playing song?

Share this post


Link to post
Share on other sites

The

$rc = $oPlayer.currentmedia.name() ; name of file (from TAG !)

MsgBox(0, "5 rc", $rc)

Doesn't work, I'm trying it for some time now and it seems like .name can't be done in currentmedia ?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0