The idea for this script came from
this topic.
What it does
This scipt monitors the player and inserts (in percent) how much of the song has been played in the Played table. This way not only it records if a song has been played less than the 1/3 of its time (which is the default value that MM records the play) but also adds how much of the files duration we had listened evetime we played the song.
Useness
Nice to keep track of your file usages... and urghhh i can't think of anything else
Requirements
This scripts
requires from you to add a new column inside the "Played" table which you must name
PlayPercentage and use integer as its datatype
Known Issues
This script (by design) doesn't update the play counter. This means that MM is responsible for updating the play counter (which is done every time the 1/3 of a file has been played). There are scripts out there than will update Play counter according to the statistics stored in the Played table if you like to....
Instructions
First of all create a new column inside the "Played" table which you must name
PlayPercentage and use integer as its datatype. If you don't have access then you have a problem....
If you don't know how to do it search Access help, its quite easy
Afterwards insert the following lines at the end of
the
Scripts.ini:
Code: Select all
[Percentage]
FileName=Auto\Percentage.vbs
ProcName=SetPercentage
Order=10
DisplayName=SetPercentage
Description=SetPercentage
Language=VBScript
ScriptType=2
Create a new text file and add the following lines:
Code: Select all
'==========================================================================
' NAME: SetPercentage.vbs
'
' AUTHOR: psyXonova
' DATE : 06/10/2005
'
' COMMENT: This script sole purpose is to call the setpercentageext.vbs every
' time the playback of a song starts. Must be put in the auto folder
'==========================================================================
Sub SetPercentage
Dim WShell, Command, Result
Set WShell = CreateObject("WScript.Shell")
'This is the path to the SetPercentageExt.vbs
'If yours is located elsewhere change the value
Command = Chr(34)&"C:\Program Files\MediaMonkey\Scripts\SetPercentageExt.vbs"&Chr(34)
Result = WShell.Run(Command, 1, 1)
End Sub
Save this file as
SetPercentage.vbs inside the Scripts\Auto folder
Create another textfile and paste those lines:
Code: Select all
'==========================================================================
' NAME: SetPercentageExt.vbs
'
' AUTHOR: psyXonova
' DATE : 06/10/2005
'
' COMMENT: This script is called by the auto script setpercentage.vbs every
' time a new song starts playing.
' This scripts stops execution if the player is stopped or If
' current playback Time Is smaller than the last value entered
' in the table. This means that if you seek backwards to a file
' it will stop scripts execution
'==========================================================================
'Initilization
Dim SDB
Set SDB = CreateObject("SongsDB.SDBApplication")
Dim itm, percentage, StrQuery, totaltime, CurrentTime, StartTime, id, iter, song
Set itm = SDB.Player.CurrentSong
totaltime = itm.SongLength
StartTime = Now()
song = itm.ID
'Add the first entry in the played table (you must create a new column named PlayPercentage first
strQuery = "INSERT INTO Played (IdSong, PlayDate, PlayPercentage) VALUES (" & itm.ID & ", Now(), 1)"
SDB.Database.ExecSQL(strQuery)
StrQuery = "SELECT Played.IdPlay FROM Played Where Played.IDSong = " & itm.ID & " ORDER BY Played.IdPlay DESC"
Set Iter = SDB.Database.OpenSQL(strQuery)
'Get the rows id so from now on we update this and don't add new rows
id = iter.stringbyname("IdPlay")
'Start Updating every 2 seconds
Do While SDB.Player.PlaybackTime < totaltime
WScript.Sleep 2000 'This is the update interval in milliseconds. DONT MAKE IT LOWER THAN 1000 !!!!
If SDB.Player.isPlaying = False Then Exit Do 'Stop script if playback has stopped
' stop script if playback time is lower than the last value entered.
' Had to add this because script does't realize if the player started playing another
' and continues to update song statistics even though the playback of the specific song has stopped
If CurrentTime > SDB.Player.PlaybackTime Then Exit Do
percentage = Round((SDB.Player.PlaybackTime/TotalTime)*100,0)
' If playback percentage is higher than 90% make it 100
' This way we will have 100 percent values in our statistics if the playback
' is reaching to the end (otherwise this would be almost impossible since
' script checks for playback status every 2 seconds
If percentage > 90 Then
percentage = 100
End If
If percentage > 35 Then
StrQuery = "DELETE Played.IdPlay FROM Played WHERE Played.IdPlay > " & id & " AND Played.IDSong = " & itm.ID
SDB.Database.ExecSQL(strQuery)
End If
' Update Statistics
strQuery = "UPDATE Played Set Played.PlayPercentage = " & percentage & " WHERE Played.IdPlay = " & id & " AND Played.IdSong = " & itm.ID
SDB.Database.ExecSQL(strQuery)
CurrentTime = SDB.Player.PlaybackTime
Loop
Save this file as
SetPercentageExt.vbs inside the Scripts folder (not auto)
Restart MM. Begin playing your files as normal.
Check your statistics inside the Played table everytime you want.
You can now create scripts that access those statistics and use them as you please!!!
Hope you like it

The idea for this script came from [url=http://www.mediamonkey.com/forum/viewtopic.php?t=5038]this topic[/url].
[b]What it does[/b]
This scipt monitors the player and inserts (in percent) how much of the song has been played in the Played table. This way not only it records if a song has been played less than the 1/3 of its time (which is the default value that MM records the play) but also adds how much of the files duration we had listened evetime we played the song.
[b]Useness[/b]
Nice to keep track of your file usages... and urghhh i can't think of anything else :cry:
[b]Requirements[/b]
This scripts [b]requires from you[/b] to add a new column inside the "Played" table which you must name [b]PlayPercentage[/b] and use integer as its datatype
[b]Known Issues[/b]
This script (by design) doesn't update the play counter. This means that MM is responsible for updating the play counter (which is done every time the 1/3 of a file has been played). There are scripts out there than will update Play counter according to the statistics stored in the Played table if you like to....
[b]Instructions[/b]
First of all create a new column inside the "Played" table which you must name [b]PlayPercentage[/b] and use integer as its datatype. If you don't have access then you have a problem....
If you don't know how to do it search Access help, its quite easy
Afterwards insert the following lines at the end of
the [b]Scripts.ini[/b]:
[code][Percentage]
FileName=Auto\Percentage.vbs
ProcName=SetPercentage
Order=10
DisplayName=SetPercentage
Description=SetPercentage
Language=VBScript
ScriptType=2[/code]
Create a new text file and add the following lines:
[code]'==========================================================================
' NAME: SetPercentage.vbs
'
' AUTHOR: psyXonova
' DATE : 06/10/2005
'
' COMMENT: This script sole purpose is to call the setpercentageext.vbs every
' time the playback of a song starts. Must be put in the auto folder
'==========================================================================
Sub SetPercentage
Dim WShell, Command, Result
Set WShell = CreateObject("WScript.Shell")
'This is the path to the SetPercentageExt.vbs
'If yours is located elsewhere change the value
Command = Chr(34)&"C:\Program Files\MediaMonkey\Scripts\SetPercentageExt.vbs"&Chr(34)
Result = WShell.Run(Command, 1, 1)
End Sub[/code]
Save this file as [b]SetPercentage.vbs inside the Scripts\Auto[/b] folder
Create another textfile and paste those lines:
[code]'==========================================================================
' NAME: SetPercentageExt.vbs
'
' AUTHOR: psyXonova
' DATE : 06/10/2005
'
' COMMENT: This script is called by the auto script setpercentage.vbs every
' time a new song starts playing.
' This scripts stops execution if the player is stopped or If
' current playback Time Is smaller than the last value entered
' in the table. This means that if you seek backwards to a file
' it will stop scripts execution
'==========================================================================
'Initilization
Dim SDB
Set SDB = CreateObject("SongsDB.SDBApplication")
Dim itm, percentage, StrQuery, totaltime, CurrentTime, StartTime, id, iter, song
Set itm = SDB.Player.CurrentSong
totaltime = itm.SongLength
StartTime = Now()
song = itm.ID
'Add the first entry in the played table (you must create a new column named PlayPercentage first
strQuery = "INSERT INTO Played (IdSong, PlayDate, PlayPercentage) VALUES (" & itm.ID & ", Now(), 1)"
SDB.Database.ExecSQL(strQuery)
StrQuery = "SELECT Played.IdPlay FROM Played Where Played.IDSong = " & itm.ID & " ORDER BY Played.IdPlay DESC"
Set Iter = SDB.Database.OpenSQL(strQuery)
'Get the rows id so from now on we update this and don't add new rows
id = iter.stringbyname("IdPlay")
'Start Updating every 2 seconds
Do While SDB.Player.PlaybackTime < totaltime
WScript.Sleep 2000 'This is the update interval in milliseconds. DONT MAKE IT LOWER THAN 1000 !!!!
If SDB.Player.isPlaying = False Then Exit Do 'Stop script if playback has stopped
' stop script if playback time is lower than the last value entered.
' Had to add this because script does't realize if the player started playing another
' and continues to update song statistics even though the playback of the specific song has stopped
If CurrentTime > SDB.Player.PlaybackTime Then Exit Do
percentage = Round((SDB.Player.PlaybackTime/TotalTime)*100,0)
' If playback percentage is higher than 90% make it 100
' This way we will have 100 percent values in our statistics if the playback
' is reaching to the end (otherwise this would be almost impossible since
' script checks for playback status every 2 seconds
If percentage > 90 Then
percentage = 100
End If
If percentage > 35 Then
StrQuery = "DELETE Played.IdPlay FROM Played WHERE Played.IdPlay > " & id & " AND Played.IDSong = " & itm.ID
SDB.Database.ExecSQL(strQuery)
End If
' Update Statistics
strQuery = "UPDATE Played Set Played.PlayPercentage = " & percentage & " WHERE Played.IdPlay = " & id & " AND Played.IdSong = " & itm.ID
SDB.Database.ExecSQL(strQuery)
CurrentTime = SDB.Player.PlaybackTime
Loop[/code]
Save this file as [b]SetPercentageExt.vbs inside the Scripts folder (not auto)[/b]
Restart MM. Begin playing your files as normal.
Check your statistics inside the Played table everytime you want.
You can now create scripts that access those statistics and use them as you please!!!
Hope you like it :lol: