DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Taking an item from a listbox and casting it to a WMP control? (.NET)  (Read 4,571 times)

wreckedcarzz

  • Still lurking. Still an anthro.
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,629
    • Participated in NANY Challenge Twice
    • Coding Snacks
    • Furry Fandom Badge - Furry Fandom
    • Linux User
OK, this one has been driving me up the wall for a while now.

I have a WMP control and a listview. Simple enough.

What I am trying to do is allow the user to double-click an item in the listview, and add it to a playlist (begin playing it in the WMP control). I have tried numerous ways to do this, and all of them give an error saying that it cannot cast the type String to WMPlayer (or whatever the name of the WMP control backend is called).

Avoiding sounding like a total idiot, here is the current code that I have (that is still a total FAIL)

Code: (vbnet)
Private Sub ListView1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick
        'Playlist = Player.newPlaylist("myPlayList", "")
        'Player.currentPlaylist = ListView1.SelectedIndices
        'InfoLabel.Visible = False

        Dim Playlist As IWMPPlaylist = ListView1.SelectedItems.ToString
        'Dim theMedia = libForm.TheMedia
        Playlist = Player.currentPlaylist

        ' Set the current media. It will play automatically.
        Player.currentMedia = Playlist

    End Sub

Anyone got a tutorial on this? Ideas? Am I a total oblivious idiot and am missing one line of code??? :tellme: H-E-L-P! ;D

-Brandon

Original address: https://www.donationcoder.com/forum/index.php?topic=13868.0