Is it possible..

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Is it possible..

Postby DranoK » Mon Dec 19, 2005 12:28 am

Is it possible to write a script that would, when activated, pause the music between each song and prompt me for a rating? This would be useful when listening to something for the first time, as all to often I forget about rating the music so end up with only one or two tracks with ratings.

Thanks!
DranoK
 

Postby trixmoto » Mon Dec 19, 2005 4:23 am

You want this prompt to appear at the end of every song?
Download my scripts at trixmoto.net. If you're interested, check out my Uniface blog.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.

Image Image
trixmoto
 
Posts: 9891
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK

Postby Steegy » Mon Dec 19, 2005 9:33 am

Code: Select all
See new version below
Last edited by Steegy on Wed Jul 04, 2007 7:34 am, edited 1 time in total.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
Steegy
 
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium

Postby DranoK » Mon Dec 19, 2005 2:47 pm

Awesome, I'll try it out and let you know as soon as I get home. You kick ass Steegy =)

If it's easy enough a menu item or some other way to turn it on or off would be great.

Thanks again!
DranoK
 

Postby Steegy » Mon Dec 19, 2005 3:46 pm

If it's easy enough a menu item or some other way to turn it on or off would be great.


See newer version below.
Last edited by Steegy on Wed Jul 04, 2007 7:33 am, edited 1 time in total.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
Steegy
 
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium

Postby DranoK » Wed Dec 21, 2005 11:37 pm

Awesome, it works perfectly! ^^;
DranoK
 

Postby locu » Thu May 03, 2007 8:41 am

As I don't like to rate songs the first time I actually listened to them, I did a little modification to this script which actually considers the playcount of the played song as well. This way I get the popup after listening to the song the second time.

Simply replace:
Code: Select all
If PreviouslyPlayedSong.Rating = -1 Then

in RatePlayedSong.vbs with
Code: Select all
If PreviouslyPlayedSong.Rating = -1 And PreviouslyPlayedSong.Playcounter > 1 Then

Of course, you can set this number to any other as well (if you want to listen to a song for ten times, before you rate it ;)
locu
 
Posts: 20
Joined: Thu Nov 09, 2006 12:16 am
Location: Berlin, Germany

Postby Lhademmor » Tue Jul 03, 2007 3:51 am

Steegy ==> Is it possible to make the buttons consist of the rating-stars instead of number? (I.e. "90" becomes 4½ star, "80" becomes 4 star and so on...)
Apart from that this is a cool add-on!
Lhademmor
 

Postby Steegy » Wed Jul 04, 2007 7:32 am

Here's an updated version.
You can change the caption of the rating buttons by changing the contents of the BtnCapt array.

This script in an autoscript without installer. See the FAQ for installation instructions.

Code: Select all
'====================================================================================
' MEDIAMONKEY SCRIPT: RatePlayedSong v1.1 (last updated 2007-07-04)    by   Steegy
'
'  Shows a dialog when a song is started, to rate the previous played song.
'====================================================================================
Option Explicit

Dim BtnCapt : BtnCapt = Array("5", "4½", "4", "3½", "3", "2½", "2", "1½", "1", "½", "0")

Dim PreviousSong
Dim DoneSettingRating
Dim MI


Sub OnStartup
    If SDB.IniFile.StringValue("RatePlayedSong", "Enabled") = "" Then
        SDB.IniFile.BoolValue("RatePlayedSong", "Enabled") = True
    End If

    Set MI = SDB.UI.AddMenuItem(SDB.UI.Menu_Scripts, 1, 1)
    MI.Caption = "Rate Played Song"
    MI.Hint = "Activate/deactivate dialog for rating played song"
    MI.Checked = SDB.IniFile.BoolValue("RatePlayedSong", "Enabled")
    Script.RegisterEvent MI, "OnClick", "MI_OnClick"
   
    Script.RegisterEvent SDB, "OnPlay", "RatePlayedSong"
End Sub


Sub RatePlayedSong
    If Not IsEmpty(PreviousSong) And MI.Checked Then
        If PreviousSong.Rating = -1 Then
           
            SDB.Player.Pause
            SDB.Player.PlaybackTime = 0
           
            Dim PreviousSongRating : PreviousSongRating = PreviousSong.Rating
           
            Dim Ret : Ret = GetForm().ShowModal
           
            If Ret = 2 Then   ' If Cancel
                PreviousSong.Rating = PreviousSongRating
                PreviousSong.UpdateDB
            End If
           
            SDB.Player.Play
       
        End If
    End If
   
    Set PreviousSong = SDB.Player.CurrentSong
End Sub


Function GetForm
    Set GetForm = SDB.Objects("RatePlayedSong_Form")
   
    If GetForm Is Nothing Then
        Dim bheight : bheight = 23
        Dim bwidth : bwidth = 35
        Set GetForm = SDB.UI.NewForm
        GetForm.Common.SetRect 100, 100, 360, 190
        GetForm.BorderStyle  = 3   ' Resizable
        GetForm.FormPosition = 4   ' Screen Center
        GetForm.SavePositionName = "RatePlayedSong_Form"
        GetForm.Caption = "Rate Previously Played Song"
        Set SDB.Objects("RatePlayedSong_Form") = GetForm
       
        Dim lblTit : Set lblTit = SDB.UI.NewLabel(GetForm)
        lblTit.Caption = "Title:  " & PreviousSong.Title
        lblTit.Common.Left = 10
        lblTit.Common.Top = 14
       
        Dim lblArt : Set lblArt = SDB.UI.NewLabel(GetForm)
        lblArt.Caption = "Artist: " & PreviousSong.ArtistName
        lblArt.Common.Left = 10
        lblArt.Common.Top = lblTit.Common.Top + lblTit.Common.Height +7
       
        Dim i, btnPcnt
        For i = 0 To 10
            Set btnPcnt = SDB.UI.NewButton(GetForm)
            btnPcnt.Caption = BtnCapt(i)
            btnPcnt.Common.MinHeight = i
            btnPcnt.Common.Height = bheight
            btnPcnt.Common.Width = bwidth
            btnPcnt.Common.Top = lblArt.Common.Top + lblArt.Common.Height + 10 + (i MOD 2)*bheight
            btnPcnt.Common.Left = 50 + i*(bwidth - bwidth/2 + 5)
            Script.RegisterEvent btnPcnt.Common, "OnClick", "RateButton_OnClick"
        Next
       
        Dim btnOk : Set btnOk = SDB.UI.NewButton(GetForm)
        btnOk.Caption = "OK"
        btnOk.Common.SetRect GetForm.Common.Width/2 - 155, lblArt.Common.Top + lblArt.Common.Height + 10 + 2*bheight + 10 + 5, 150, bheight
        btnOk.Default = True
        btnOk.ModalResult = 1
       
        Dim btnCancel : Set btnCancel = SDB.UI.NewButton(GetForm)
        btnCancel.Caption = "Cancel Changes"
        btnCancel.Common.SetRect GetForm.Common.Width/2 + 5, BtnOK.Common.Top, 150, bheight
        btnCancel.Cancel = True
        btnCancel.ModalResult = 2
    End If
End Function


Sub RateButton_OnClick(RateButton)
    PreviousSong.Rating = 100 - 10 * RateButton.Common.MinHeight
    PreviousSong.UpdateDB
End Sub


Sub MI_OnClick(MI)
   MI.Checked = Not MI.Checked
   SDB.IniFile.BoolValue("RatePlayedSong", "Enabled") = MI.Checked
End Sub
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
Steegy
 
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium

Small change to fix a minor annoyance

Postby CaptainRoo » Thu Oct 11, 2007 9:58 pm

Hello all, especially Steegy,

Thanks for the script. I find it quite useful, but there was this annoying behavior: it would show the title and artist of the first song that had to be rated and it would not update afterwards.

I made some small modifications to the GetForm function (commented all he changes). Here it is - just swap it out with the current 'GetForm' with the help of a text editor to try it.

:P

Code: Select all
Function GetForm
    Set GetForm = SDB.Objects("RatePlayedSong_Form")
' Initialize the two variables here because they will be used in both sides of the conditional
    Dim lblTit
    Dim lblArt

    If GetForm Is Nothing Then
        Dim bheight : bheight = 23
        Dim bwidth : bwidth = 35
        Set GetForm = SDB.UI.NewForm
        GetForm.Common.SetRect 100, 100, 360, 190
        GetForm.BorderStyle  = 3   ' Resizable
        GetForm.FormPosition = 4   ' Screen Center
        GetForm.SavePositionName = "RatePlayedSong_Form"
        GetForm.Caption = "Rate Previously Played Song"
        Set SDB.Objects("RatePlayedSong_Form") = GetForm

        Set lblTit = SDB.UI.NewLabel(GetForm)
        lblTit.Caption = "Title:  " & PreviousSong.Title
        lblTit.Common.Left = 10
        lblTit.Common.Top = 14
' Initialize a new named label object, so we can refer to it later
        Set SDB.Objects("RatePlayedSong_Form_lblTit") = lblTit

        Set lblArt = SDB.UI.NewLabel(GetForm)
        lblArt.Caption = "Artist: " & PreviousSong.ArtistName
        lblArt.Common.Left = 10
        lblArt.Common.Top = lblTit.Common.Top + lblTit.Common.Height +7
' same as above
        Set SDB.Objects("RatePlayedSong_Form_lblArt") = lblArt

        Dim i, btnPcnt
        For i = 0 To 10
            Set btnPcnt = SDB.UI.NewButton(GetForm)
            btnPcnt.Caption = BtnCapt(i)
            btnPcnt.Common.MinHeight = i
            btnPcnt.Common.Height = bheight
            btnPcnt.Common.Width = bwidth
            btnPcnt.Common.Top = lblArt.Common.Top + lblArt.Common.Height + 10 + (i MOD 2)*bheight
            btnPcnt.Common.Left = 50 + i*(bwidth - bwidth/2 + 5)
            Script.RegisterEvent btnPcnt.Common, "OnClick", "RateButton_OnClick"
        Next

        Dim btnOk : Set btnOk = SDB.UI.NewButton(GetForm)
        btnOk.Caption = "OK"
        btnOk.Common.SetRect GetForm.Common.Width/2 - 155, lblArt.Common.Top + lblArt.Common.Height + 10 + 2*bheight + 10 + 5, 150, bheight
        btnOk.Default = True
        btnOk.ModalResult = 1

        Dim btnCancel : Set btnCancel = SDB.UI.NewButton(GetForm)
        btnCancel.Caption = "Cancel Changes"
        btnCancel.Common.SetRect GetForm.Common.Width/2 + 5, BtnOK.Common.Top, 150, bheight
        btnCancel.Cancel = True
        btnCancel.ModalResult = 2
    Else
' this bit is for when the form appears for not the first time
' capture the named label objects in lblTit and lblArt and update their content
        Set lblTit = SDB.Objects("RatePlayedSong_Form_lblTit")
        lblTit.Caption = "Title:  " & PreviousSong.Title

        Set lblArt = SDB.Objects("RatePlayedSong_Form_lblArt")
        lblArt.Caption = "Artist: " & PreviousSong.ArtistName
    End If
End Function

HTH,

Gábor
CaptainRoo
 
Posts: 8
Joined: Wed Sep 12, 2007 5:38 pm
Location: NY, USA - BP, HUN

Postby Steegy » Fri Oct 12, 2007 11:04 am

Oops. So my "updated" version wasn't completely fine.

Thanks for the update.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
Steegy
 
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium

button

Postby horstl » Sun Feb 24, 2008 12:08 pm

heeey =)

first of all, thank you for this script, but i have one problem, because i dont see a button oder something like this in my menu or so...

there is nothing to turn it on/off

do you know what it could be? i have the mm3
horstl
 

Re: Is it possible..

Postby Guest » Wed Oct 15, 2008 6:45 pm

This is a GREAT script for those who rate songs. My problem was that I found myself distracted and not listening to the songs every time. I needed a replay button. So I eliminated the OK button and replaced it with a Replay Song button. Now if you click a rating, the song is rated and the form exits. If you click replay song, the song replays and the form exits.

I could have never done this from scratch, so thank you Steegy and others.
Code: Select all
'====================================================================================
' MEDIAMONKEY SCRIPT: RatePlayedSong v1.1 (last updated 2007-07-04)    by   Steegy
'
'  Shows a dialog when a song is started, to rate the previous played song.
'====================================================================================
Option Explicit

Dim BtnCapt : BtnCapt = Array("5", "4½", "4", "3½", "3", "2½", "2", "1½", "1", "½", "0")

Dim Rpl
Dim PreviousSong
Dim DoneSettingRating
Dim MI


Sub OnStartup
    If SDB.IniFile.StringValue("RatePlayedSong", "Enabled") = "" Then
        SDB.IniFile.BoolValue("RatePlayedSong", "Enabled") = True
    End If

    Set MI = SDB.UI.AddMenuItem(SDB.UI.Menu_Scripts, 1, 1)
    MI.Caption = "Rate Played Song"
    MI.Hint = "Activate/deactivate dialog for rating played song"
    MI.Checked = SDB.IniFile.BoolValue("RatePlayedSong", "Enabled")
    Script.RegisterEvent MI, "OnClick", "MI_OnClick"
   
    Script.RegisterEvent SDB, "OnPlay", "RatePlayedSong"
End Sub


Sub RatePlayedSong

If Rpl = 1 Then
    Rpl = 0
    Exit Sub
Else
    If Not IsEmpty(PreviousSong) And MI.Checked Then
        If PreviousSong.Rating = -1 Then
            SDB.Player.Pause
            SDB.Player.PlaybackTime = 0
           
            Dim PreviousSongRating : PreviousSongRating = PreviousSong.Rating
           
            Dim Ret : Ret = GetForm().ShowModal
      
            If Ret <> 1 Then   ' If Cancel or Rated
                SDB.Player.Play
            End If

        End If
    End If
End If

Set PreviousSong = SDB.Player.CurrentSong

End Sub


Function GetForm
    Set GetForm = SDB.Objects("RatePlayedSong_Form")
' Initialize the two variables here because they will be used in both sides of the conditional
    Dim lblTit
    Dim lblArt

    If GetForm Is Nothing Then
        Dim bheight : bheight = 23
        Dim bwidth : bwidth = 35
        Set GetForm = SDB.UI.NewForm
        GetForm.Common.SetRect 100, 100, 360, 190
        GetForm.BorderStyle  = 3   ' Resizable
        GetForm.FormPosition = 4   ' Screen Center
        GetForm.SavePositionName = "RatePlayedSong_Form"
        GetForm.Caption = "Rate Previously Played Song"
        Set SDB.Objects("RatePlayedSong_Form") = GetForm

        Set lblTit = SDB.UI.NewLabel(GetForm)
        lblTit.Caption = "Title:  " & PreviousSong.Title
        lblTit.Common.Left = 10
        lblTit.Common.Top = 14
' Initialize a new named label object, so we can refer to it later
        Set SDB.Objects("RatePlayedSong_Form_lblTit") = lblTit

        Set lblArt = SDB.UI.NewLabel(GetForm)
        lblArt.Caption = "Artist: " & PreviousSong.ArtistName
        lblArt.Common.Left = 10
        lblArt.Common.Top = lblTit.Common.Top + lblTit.Common.Height +7
' same as above
        Set SDB.Objects("RatePlayedSong_Form_lblArt") = lblArt

        Dim i, btnPcnt
        For i = 0 To 10
            Set btnPcnt = SDB.UI.NewButton(GetForm)
            btnPcnt.Caption = BtnCapt(i)
            btnPcnt.Common.MinHeight = i
            btnPcnt.Common.Height = bheight
            btnPcnt.Common.Width = bwidth
            btnPcnt.Common.Top = lblArt.Common.Top + lblArt.Common.Height + 10 + (i MOD 2)*bheight
            btnPcnt.Common.Left = 50 + i*(bwidth - bwidth/2 + 5)
            btnPcnt.ModalResult = 3                           
            Script.RegisterEvent btnPcnt.Common, "OnClick", "RateButton_OnClick"
        Next

        Dim btnrepl : Set btnrepl = SDB.UI.NewButton(GetForm)
   btnrepl.Caption = "Replay Song"
   btnrepl.Common.SetRect GetForm.Common.Width/2 - 155, lblArt.Common.Top + lblArt.Common.Height + 10 + 2*bheight + 10 + 5, 150, bheight
   btnrepl.Default = True
        btnrepl.ModalResult = 1
   Script.RegisterEvent btnrepl.Common, "OnClick", "ReplaySong_OnClick"

        Dim btnCancel : Set btnCancel = SDB.UI.NewButton(GetForm)
        btnCancel.Caption = "Cancel Changes"
        btnCancel.Common.SetRect GetForm.Common.Width/2 + 5, Btnrepl.Common.Top, 150, bheight         
        btnCancel.Cancel = True
        btnCancel.ModalResult = 2
    Else
' this bit is for when the form appears for not the first time
' capture the named label objects in lblTit and lblArt and update their content
        Set lblTit = SDB.Objects("RatePlayedSong_Form_lblTit")
        lblTit.Caption = "Title:  " & PreviousSong.Title

        Set lblArt = SDB.Objects("RatePlayedSong_Form_lblArt")
        lblArt.Caption = "Artist: " & PreviousSong.ArtistName
    End If
End Function



Sub RateButton_OnClick(RateButton)
    PreviousSong.Rating = 100 - 10 * RateButton.Common.MinHeight
    PreviousSong.UpdateDB
End Sub


Sub MI_OnClick(MI)
   MI.Checked = Not MI.Checked
   SDB.IniFile.BoolValue("RatePlayedSong", "Enabled") = MI.Checked
End Sub

'Add Replay Song Script
Sub ReplaySong_OnClick(ReplaySong)
     Rpl = 1
     SDB.Player.Previous

End Sub
Guest
 

Re: Is it possible..

Postby avera991 » Sun Jan 11, 2009 6:38 am

Replay isnt working, its only closing script window and song remains stopped
avera991
 

Re: Is it possible..

Postby lucasso » Sun Sep 13, 2009 6:49 am

Hi, is it possible to customize this script so that it keeps playing a song until the song gets a rate? I've been tinkering with the script with no luck.
lucasso
 

Next

Return to Need Help with Addons?

Who is online

Users browsing this forum: Bing [Bot] and 12 guests