Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,092 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,813 people online right now. Registration is fast and FREE... Join Now!




add song to wmp playlist wpl

 
Reply to this topicStart new topic

add song to wmp playlist wpl

IDIS
10 May, 2008 - 11:20 PM
Post #1

New D.I.C Head
*

Joined: 30 Apr, 2008
Posts: 13

Hello,

I use the wmp control. How can i add a song to an existing playlist( to playlist thats already in my documents\my music\my playlists?

CODE

Imports System.io

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents ListView1 As System.Windows.Forms.ListView
    Friend WithEvents ListView2 As System.Windows.Forms.ListView
    Friend WithEvents ListView3 As System.Windows.Forms.ListView
    Friend WithEvents btnLoad As System.Windows.Forms.Button
    Friend WithEvents wmplayer1 As AxWMPLib.AxWindowsMediaPlayer
    Friend WithEvents btnsavlist As System.Windows.Forms.Button
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents btnloadexistpllist As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
        Me.ListView1 = New System.Windows.Forms.ListView
        Me.ListView2 = New System.Windows.Forms.ListView
        Me.ListView3 = New System.Windows.Forms.ListView
        Me.btnLoad = New System.Windows.Forms.Button
        Me.wmplayer1 = New AxWMPLib.AxWindowsMediaPlayer
        Me.btnsavlist = New System.Windows.Forms.Button
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.btnloadexistpllist = New System.Windows.Forms.Button
        CType(Me.wmplayer1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'ListView1
        '
        Me.ListView1.FullRowSelect = True
        Me.ListView1.Location = New System.Drawing.Point(16, 16)
        Me.ListView1.Name = "ListView1"
        Me.ListView1.Size = New System.Drawing.Size(184, 448)
        Me.ListView1.TabIndex = 0
        Me.ListView1.View = System.Windows.Forms.View.Details
        '
        'ListView2
        '
        Me.ListView2.FullRowSelect = True
        Me.ListView2.Location = New System.Drawing.Point(408, 16)
        Me.ListView2.Name = "ListView2"
        Me.ListView2.Size = New System.Drawing.Size(184, 448)
        Me.ListView2.TabIndex = 1
        Me.ListView2.View = System.Windows.Forms.View.Details
        '
        'ListView3
        '
        Me.ListView3.FullRowSelect = True
        Me.ListView3.Location = New System.Drawing.Point(808, 16)
        Me.ListView3.Name = "ListView3"
        Me.ListView3.Size = New System.Drawing.Size(184, 448)
        Me.ListView3.TabIndex = 2
        Me.ListView3.View = System.Windows.Forms.View.Details
        '
        'btnLoad
        '
        Me.btnLoad.Location = New System.Drawing.Point(240, 8)
        Me.btnLoad.Name = "btnLoad"
        Me.btnLoad.TabIndex = 3
        Me.btnLoad.Text = "Load Playlist"
        '
        'wmplayer1
        '
        Me.wmplayer1.Enabled = True
        Me.wmplayer1.Location = New System.Drawing.Point(256, 96)
        Me.wmplayer1.Name = "wmplayer1"
        Me.wmplayer1.OcxState = CType(resources.GetObject("wmplayer1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.wmplayer1.TabIndex = 4
        Me.wmplayer1.Visible = False
        '
        'btnsavlist
        '
        Me.btnsavlist.Location = New System.Drawing.Point(656, 80)
        Me.btnsavlist.Name = "btnsavlist"
        Me.btnsavlist.TabIndex = 5
        Me.btnsavlist.Text = "Save"
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(624, 48)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(144, 20)
        Me.TextBox1.TabIndex = 6
        Me.TextBox1.Text = ""
        '
        'btnloadexistpllist
        '
        Me.btnloadexistpllist.Location = New System.Drawing.Point(656, 8)
        Me.btnloadexistpllist.Name = "btnloadexistpllist"
        Me.btnloadexistpllist.TabIndex = 7
        Me.btnloadexistpllist.Text = "existing playlist"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(1032, 558)
        Me.Controls.Add(Me.btnloadexistpllist)
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.btnsavlist)
        Me.Controls.Add(Me.wmplayer1)
        Me.Controls.Add(Me.btnLoad)
        Me.Controls.Add(Me.ListView3)
        Me.Controls.Add(Me.ListView2)
        Me.Controls.Add(Me.ListView1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        CType(Me.wmplayer1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region



    Dim typeSpecialFolder As System.Environment.SpecialFolder
    Const Pad As String = "C:\Documents and settings\admin\Mijn Documenten\Mijn Muziek\Mijn Afspeellijsten\"     '<=== ADJUST YOUR PATH HERE

    Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
        ListView1.Columns.Add("Afspeellijst", 110, HorizontalAlignment.Left)

        ListView2.Columns.Add("Titel", 300, HorizontalAlignment.Left)
        ListView2.Columns.Add("Locatie", 0, HorizontalAlignment.Left)
        ListView3.Columns.Add("Titel", 300, HorizontalAlignment.Left)
        ListView3.Columns.Add("Locatie", 0, HorizontalAlignment.Left)

    End Sub

    Private Sub btnload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
        Dim Bestand, BestandsNaam As String

        Dim Bestanden() As String = Directory.GetFiles(Pad)
        For Each Bestand In Bestanden
            BestandsNaam = Bestand.ToString.Replace(Pad, "")
            BestandsNaam = BestandsNaam.Substring(0, BestandsNaam.IndexOf("."))
            ListView1.Items.Add(BestandsNaam)
        Next
    End Sub

    Private Sub ListView1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.Click
        Dim Info(1) As String
        Dim wmp As WMPLib.WindowsMediaPlayer = New WMPLib.WindowsMediaPlayerClass
        Dim playlist As WMPLib.IWMPPlaylist
        Dim itm As ListViewItem = ListView1.SelectedItems(0)

        Dim Bestandsnaam As String = itm.SubItems(0).Text.ToString
        playlist = wmp.newPlaylist(Bestandsnaam, Pad & Bestandsnaam & ".wpl")

        ListView2.Items.Clear()
        For i As Integer = 0 To playlist.count - 1
            Info(0) = playlist.Item(i).getItemInfo("Title")
            Info(1) = playlist.Item(i).getItemInfo("SourceUrl")
            itm = New ListViewItem(Info)
            ListView2.Items.Add(itm)
        Next

    End Sub

    Private Sub ListView2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView2.Click

        ListView3.Items.Add(ListView2.SelectedItems(0).Clone)

    End Sub

    Private Sub btnsavelist_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsavlist.Click
        Dim itm As ListViewItem
        Dim AlleItems As New ListView.ListViewItemCollection(ListView3)
        Dim Playlist As WMPLib.IWMPPlaylist = wmplayer1.newPlaylist(Trim(TextBox1.Text), "")

        For Each itm In AlleItems
            Try
                Playlist.appendItem(wmplayer1.newMedia(itm.SubItems(1).Text))
            Catch
            End Try
        Next
        wmplayer1.playlistCollection.importPlaylist(Playlist)
    End Sub



    Private Sub btnloadexistpllist_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnloadexistpllist.Click
        Dim Info(1) As String
        Dim wmp As WMPLib.WindowsMediaPlayer = New WMPLib.WindowsMediaPlayerClass
        Dim playlist As WMPLib.IWMPPlaylist
        Dim itm As ListViewItem

        Dim bestandsnaam As String
        playlist = wmp.newPlaylist(bestandsnaam, Pad & bestandsnaam & "TOP 40 MUZIEK.wpl") 'adjust your wpl here

        ListView3.Items.Clear()

        For i As Integer = 0 To playlist.count - 1
            Info(0) = playlist.Item(i).getItemInfo("Title")
            Info(1) = playlist.Item(i).getItemInfo("SourceUrl")
            itm = New ListViewItem(Info)
            ListView3.Items.Add(itm)
        Next
        ListView3.Items(0).Selected = True

        wmplayer1.URL = System.Environment.GetFolderPath(typeSpecialFolder.MyMusic) + "\Mijn Afspeellijsten\" + "TOP 40 MUZIEK.wpl" ' adjust your wpl here
        wmplayer1.Ctlcontrols.play()
    End Sub
End Class


This post has been edited by IDIS: 11 May, 2008 - 07:27 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 12:05AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month