Page 1 of 1

Pandora window

Posted: Sun Feb 26, 2006 2:40 am
by revbob
What better way to spend a rainy weekend than to write a script in a language you don't know to interface with an API you don't understand very well. :wink:

Here's a script that runs Pandora in either (a) your default browser or (b) a popup window.

[see follow-up for revised code]

Now a couple of questions.

First, is there a way to embed the MSIE ActiveX control in the main window of MM? I'm not entirely sure I want to do that, but I'd like to find out how anyhow. You never know when it might come in handy.

Second, am I even close to the way COM events will be handled in 2.5.2? How do you actually shut down the ActiveX control when you exit from its parent?

Version 1.1

Posted: Wed Apr 12, 2006 10:49 pm
by revbob
Now, thanks to Steegy, it turns off the player when you close the window. This is so cool!

Code: Select all

'==========================================================================
'
' MediaMonkey Script
'
' NAME: PandoraNode v1.1
' DESCRIPTION:
'  Adds a node to the Web menu that opens Pandora (or substitute your
'  favorite web page) either in your default web browser or in a popup
'  child window of MM.
'
'  Heavily indebted to StreamsTreeNode by Steegy
'    http://www.mediamonkey.com/forum/viewtopic.php?t=8336
'  and openlink.vbs by tvjunky
'    http://www.mediamonkey.com/forum/viewtopic.php?t=5407
'  and jiri's application note on scripting features in 2.5.2
'    http://www.mediamonkey.com/forum/viewtopic.php?t=7660
'
' AUTHOR: Bob Crispen
' DATE  : 12.04.2006
'
' INSTALL:
' - Copy script to MediaMonkey's "Scripts\Auto" folder
'
'==========================================================================
'>> ForumURL: http://www.mediamonkey.com/forum/viewtopic.php?p=37961
'>> ScriptName: PandoraNode
'>> VersionNumber: 1.1
'>> Author: Bob Crispen
'>>>>EndOfProperties

'##############################################################################################

Dim Tree

' OnStartup event handler
Sub OnStartup

  ' Point to the main tree
  Set Tree = SDB.MainTree

  ' Create a node
  Dim PandoraNode
  Set PandoraNode = Tree.CreateNode

  ' Fill in the node label, icon, URL to open, this script, and the
  ' function to call when you click on the node.
  PandoraNode.Caption = "Pandora"
  PandoraNode.IconIndex = 37
  PandoraNode.CustomData = "http://www.pandora.com/"
  PandoraNode.UseScript = Script.ScriptPath
 
  ' Pick one
  Script.RegisterEvent PandoraNode, "OnNodeFocused", "OpenInPopup"
  ' Script.RegisterEvent PandoraNode, "OnNodeFocused", "OpenInDefaultBrowser"

  ' Under the Web main tree node seems like a logical place for Pandora
  Tree.AddNode Tree.Node_Web, PandoraNode, 2

End Sub

' OnClose event handler
Sub FormClose(Node)
  SDB.Objects("Pandora Window") = Nothing
  SDB.Objects("Pandora Browser").Navigate "about:blank"
  SDB.Objects("Pandora Browser") = Nothing
End Sub

' Open up the URL in your default web browser
Sub OpenInDefaultBrowser(Node)
  Dim WPandoraShell, Command
  Set WPandoraShell = CreateObject("WScript.Shell")
  Command = Node.CustomData
  Result = WPandoraShell.Run(Command, 0, 0)
End Sub

' Open the URL in a popup window containing a browser control.
Sub OpenInPopup(Node)
  Dim Form, BrowserControl, Command
  Command = Node.CustomData
  Set Form = SDB.UI.NewForm
  Form.Common.SetRect 100, 100, 900, 700
  Form.Caption = Command
  Set BrowserControl = SDB.UI.NewActiveX(Form, "Shell.Explorer")
  BrowserControl.Common.Align = 5         ' Fill all client rectangle
  BrowserControl.Interf.Navigate Command  ' Go to the specified URL
  Form.Common.Visible = True
  SDB.Objects("Pandora Window") = Form    ' Make the window hang about
  SDB.Objects("Pandora Browser") = BrowserControl.Interf
  Script.RegisterEvent Form, "OnClose", "FormClose"
End Sub
Probably lots of solecisms (like, why is Tree global? do you have to Dim stuff and then Set it?) because I know exactly zero Visual Basic. But it works and doesn't do stuff that's half as evil as a lot of programs I run all the time.

Thanks, Steegy.

Posted: Wed Apr 12, 2006 11:20 pm
by rovingcowboy
i was wondering if the child window memory leak i found about in winxp has caused you some trouble but since you got it working i guess not.

but you might want to check that out in the news and other stuff room. just to make sure.

8)


Also just a reminder.

but why not put the information for your script

you posted in the all scripts sticky thread so it is easier to find then looking through all the beta messages.

Posted: Thu Apr 13, 2006 9:11 am
by revbob
but why not put the information for your script you posted in the all scripts sticky thread so it is easier to find then looking through all the beta messages.
Uhh, because I didn't know? I posted a wish for a script in the script wishlist thread -- silly me -- and got growled at.

:wink:

Posted: Sun May 07, 2006 6:48 pm
by wallstreetwalker
revbob, nice work

will you update the script?
like make it a dockable window or add some other options

thanks alot

Posted: Sun Jul 09, 2006 7:52 pm
by RBasil
I agree, I would love to have this shown in a dockable window. Any script artists want to give it a try?

Posted: Sun Sep 10, 2006 7:49 am
by alexflorisca
Very nice script, i use pandora at work and it's brilliant. One thing though - I use 2 different sound drivers on my PC - I have the default sound driver as my headphones and I set MM to use my speakers (different driver) to play music (mainly for playing games while listening to music). Pandora plays thrugh my headphones and not speakers. I know little about mm scripting but I'm thinking that if your using mm browser, you can set it to use the same audio driver as mm itself?

Just a thought, would be cool to see this change if possible

Posted: Tue Oct 03, 2006 12:49 pm
by Vulgrin
I culled this version together from this script and another script example that I found in the forums that does the same thing, but loads it into the main web window.

Code: Select all

Sub OnStartup
  Set Tree = SDB.MainTree

  Set PandoraNode = Tree.CreateNode
  PandoraNode.Caption = "Pandora"
  PandoraNode.IconIndex = 37
  Script.RegisterEvent PandoraNode, "OnNodeFocused", "NodeFocus"
PandoraNode.HasChildren = False

Tree.AddNode Tree.Node_Web, PandoraNode, 2
  
End Sub

Function NodeFocus( PandoraNode)
  NodeFocus = 2
  SDB.WebControl.Navigate "http://www.Pandora.Com"
End Function

Re: Pandora window

Posted: Thu Dec 03, 2009 12:58 pm
by rovingcowboy
labiteena wrote:How do I make it so that a song sounds correctly on my iPod when I only use one headphone? On some songs, I need to use both headphones for the song to sound right (for example, the vocals will only come through one headphone and the acoustics will come through the other one). I'd like to know if i can make it so the sound is evenly distributed so i can only use one headphone. This way i can still talk to my friends and hear what is going on around me.

what you want to do is get an dsp plugin that will make the song mono. one i have is found in the winamp plugin pages.
or was? its an old one called wide and dynamic, very simple one. has few things but does help on sound by making it wide stereo which when played through a plugin that is for surround sound, gives that more depth and makes it sound a little better in that mode. but on the same knob you can turn it the other way all the way back to mono, this will then put the sound to the one speaker or headphone speaker and you can turn the volume to your speaker you use. and off the other one. so you could then hear the song and your friends and still keep track of your surroundings.

:D

Re: Pandora window

Posted: Fri Jan 15, 2010 10:00 pm
by mi0j
Thanks revbob and Vulgrin for the awesome script. Works perfectly.

Re: Pandora window

Posted: Wed Jun 09, 2010 6:34 pm
by maleorderbride
Script works great!

The only thing I might want is to be able to control the audio output channel. Right now, instead of using MM's output selection the pandora window seems to be using the default/primary sound device. I am sure that is fine 99.99% of the time, but this would be used for a HTPC and required to run multiple instances of MM to different rooms simultaneously.

Can anyone rework the script? Or is this a Pandora issue, not really a MM/script problem?

Thanks!

Re: Pandora window

Posted: Wed Jan 12, 2011 7:58 pm
by sickofusernames
Nice work. I use Pandora a lot because I like a lot of different types of music, but am usually only in the mood for specific ones at any given time. I think the best script would be if you could somehow link your library to Pandora's database and get the information for the songs in your library so that you could do what Pandora does but only within your own library. Does that make sense? I don't know if it is possible, but something between this script and trixmoto's genrefinder that can get moods from Allmusic.com.

Is this possible? (I don't know anything about writing scripts.) And if it is possible, would you be interested in attempting to write the script?

Thanks for the Pandora script you wrote!

Re: Pandora window

Posted: Tue Nov 27, 2012 8:05 am
by Demonduskk
I Copied the script to MediaMonkey's "Scripts\Auto" folder, but nothing appears under the Web Node.
&
cant we just right click on the Web Node & 'Add new bookmark' ?

Help please..!

Re: Pandora window

Posted: Mon May 20, 2013 12:20 am
by yremogtnom
Awesome!

Just started using Pandora to get a feel for some music I'm just getting into, as I wouldn't have CDs for them yet... and had to keep it running through the browser. As I would rather NOT do that, I tried finding a gadget (Win 7 x64) for Pandora, but - alas - none work.

So this was WONDERFUL to come across - Not only can I use it in my music player, which makes sense, but I can even open a tab to search and see if I have something when it comes on!

Thank you!!!!!