Is it possible..

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

liamgarrett
Posts: 5
Joined: Mon Sep 14, 2009 9:39 pm

Re: Is it possible..

Post by liamgarrett » Sun Sep 20, 2009 3:19 pm

Sorry to waste your time, everybody, but I think it's awesome you guys know how to do this kind of stuff. I guess I sound a little like a Luddite or something, but I think it's unbelievable what you guys can do with just a little bit of code.
Keep it up!
-Liam

Guest

Re: Is it possible..

Post by Guest » Tue Apr 20, 2010 12:36 pm

I know this is not a new script by any means but I think its great and I'm glad I found it. It deserves some real publicity. A lot of people would use ratings if they were prompted and in the end it would make them happier to have songs rated.
Guest wrote: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

Speed Pete
Posts: 39
Joined: Thu Jun 15, 2006 11:30 am

Re: Is it possible..

Post by Speed Pete » Tue Aug 17, 2010 4:45 am

I could use a variation of this script, but I am not able to write it myself :oops:
Perhaps anyone is interested to do some modifications?:

I often have to rate many songs, but to do this there is no need to hear the complete song. So I want MM to play a song in the playlist. While playing I want to input the rating via a shortcut or using some buttons - does not matter how. After receiving the rating I want MM to skip to the next song and start all over to rate this.

It would be great, if seomone wants to do that. :D

projectfallback
Posts: 10
Joined: Mon Dec 01, 2008 10:35 pm

Re: Is it possible..

Post by projectfallback » Tue Aug 17, 2010 9:30 am

You should be able to go to Options > Hotkeys to see a list of hotkeys, ticking them as Global means they work when it is not in focus.

Ctrl+Alt+1 rates currently playing track 1 star
Ctrl+Alt+4 rates currently playing track 4 stars etc

Speed Pete
Posts: 39
Joined: Thu Jun 15, 2006 11:30 am

Re: Is it possible..

Post by Speed Pete » Tue Aug 17, 2010 11:07 am

:oops: Oh my God - so easy... Thank you!

DocWeini
Posts: 9
Joined: Wed Mar 19, 2008 6:13 am
Location: Cologne, Germany

Re: Is it possible..

Post by DocWeini » Fri Aug 20, 2010 11:05 am

I think I'm blind - but is there any other action that can be taken except for turning the script on and off?
Plus: I need the possibility to stop the player after each song to rate a big bunch of songs over again.

Thx for any help :)
MM v4.0.7.1511 Gold

DScoffers

Re: Is it possible..

Post by DScoffers » Thu Jul 04, 2013 3:55 pm

Resurrecting a very old thread here - is there a more up-to-date place to discuss this script?

I've been using this script for a long time now, but it seems to have stopped working recently. I'm not sure when.
It's definitely not a permissions issue.
Manually setting a rating in MM sets the correct tag, but when rating using the script, nothing happens.
Version: 4.0.7.1511

Can anyone provide any assistance?

DScoffers2

Re: Is it possible..

Post by DScoffers2 » Sat May 03, 2014 3:12 am

I found a solution to my problem, so I thought I'd post it here for anyone else searching for an answer.

The current script will update the rating in the database, but not edit the tags of the mp3 file.
I sync files between multiple locations so this wouldn't work for me.
Towards the end of the script, I have edited it to include the line "PreviousSong.WriteTags" so that it updates the rating in the database and writes the rating to the tag in the mp3 file.

Code: Select all

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

Post Reply