Sunday, November 13, 2005

Pandora VB/VS 2005 "Minimize to System Tray" Player

Since I read about Pandora, I’ve been listening to it non-stop. But as I mentioned before, it bugs me that I can't minimize it to the system tray.

Finally I stopped obsessing about it (Who me? Obsessing about something? Na…  ;)  and I took a few minutes and built my own VB/VS 2005 host for it, using the updated WebBrowser and NotifyIcon controls.

Now I have a Pandora Player that I can minimize to my system tray! Yeah. Instead of being hosted in IE, it's just hosted in the new WebBrowser control… No hacking, content removal, etc, etc.

It’s very easy to do…
  1. Create a new VB project

  2. Add a WebBrowser control to the form

  3. Dock the control to the Parent (i.e. Docking = Fill)

  4. Add a NotifyIcon to the form

  5. On the NotifyIcon SmartTag, select “Choose Icon” and pick a icon somewhere on your system.

  6. Paste in the below code to the form.

  7. You’re done! You now have System Tray Pandora Player.. Yeah!


Public Class Form1

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    WebBrowser1.Navigate("http://www.pandora.com/?cmd=tuner")
  End Sub

  Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
    Me.Show()
    Me.WindowState = FormWindowState.Normal
    NotifyIcon1.Visible = False

  End Sub

  Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize

    If Me.WindowState = FormWindowState.Minimized Then
      NotifyIcon1.Visible = True
      Me.Hide()
    End If

  End Sub

End Class


Update #1 11/13/2005 @ 2:14 PM (PST):
There's one thing that is a little weird...

The Flash player does not respond to clicks unless you first click on the hosting web page. For each click you want to make on the Flash app, you must first click on the web page and then the Flash app...

So if you want to pause the playing, click on the web page area above the player and then click on the pause button... If you want to say "I Like it" on a song, click on the page, the song (to get the song menu), the page again and then finally on the "I Like It" menu item.

Yeah it's kind of a pain but for me its worth it to have a SysTray player... Your milage may vary, yada, yada, yada...

8 comments:

  1. Did you find a way to load the page in your application in Minimize mode?

    ReplyDelete
  2. Solve the weird "click the page then click the Flash control" thing that I talked about in Update #1?

    Nope, not yet... But I havn'r really tried hard either. I still use the app (pretty much every day) and the issue isn't that big of one so I live with with for now.

    I am thinking that to solve this I might need to move beyond the WebBrowser control and directly host IE on the page (http://coolthingoftheday.blogspot.com/2006/03/extending-net-20-webbrowser-control.html)

    ReplyDelete
  3. Seems lovely, but way too technical for me. If it's not a Firefox xpi or Google/Opera widget I'm lost! Gotta love the Pandora though!

    ReplyDelete
  4. You can also use the Microsoft Web Browser COM object to get around the Flash clicking problem.

    I compiled a C# version and threw it up on my site.

    Download here: http://www.silassewell.com/blog/article.php?article=3

    ReplyDelete
  5. Great tip, thank you.

    With a quick tweak, my PandoraPlayer is using the Microsoft Web Broswer COM control and now the Flash click issue is resolved.

    Less than two minutes of work and an irritating problem is resolved... Now that's a tip! :)

    Thanks again...

    ReplyDelete
  6. http://silassewell.googlepages.com/pandora

    ReplyDelete
  7. Try this app at http://openpandora.googlepages.com/

    ReplyDelete
  8. Some of the things that the OpenPandora project does looks pretty interesting. Thanks...

    ReplyDelete

NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...

ALL comments are moderated. I will review every comment before it will appear on the blog.

Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...

I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...

Please see my comment policy for more information if you are interested.

Thanks,
Greg

PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...