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.
Nice to keep track of your file usages... and urghhh i can't think of anything else
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
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....
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
Code: Select all
[Percentage] FileName=Auto\Percentage.vbs ProcName=SetPercentage Order=10 DisplayName=SetPercentage Description=SetPercentage Language=VBScript ScriptType=2
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
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
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