[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.3

WMP 10 Play random song from specified folder

Asked by Alpenist_05 in Microsoft Visual Basic.Net

Tags: axwindowsmediaplayer1

Hi all,
Using VB.Net and WMP 10
Can enyone help me to make the form1 play a random song from a "songs" folder in the same directory?
I managed to list the contents "*.MP3" files in a listBox in the form. but I couldn't figure how to configure this list as a mediaplayer list!!
Is it possible to make it play randomly from that list?

below is the code I'm using.

Thank you in Advance.
+++++++++++++++++
Code begin
+++++++++++++++++

Imports AxWMPLib
Imports WMPLib
Imports System.IO

Public Class Form1
    Inherits System.Windows.Forms.Form

    Dim foldDial = New System.Windows.Forms.FolderBrowserDialog
    Private SongFolder As System.String

#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 btn_Exit As System.Windows.Forms.Button
    Friend WithEvents lbl_path As System.Windows.Forms.Label
    Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
    Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
    Friend WithEvents AxWindowsMediaPlayer1 As AxWMPLib.AxWindowsMediaPlayer
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
        Me.btn_Exit = New System.Windows.Forms.Button
        Me.lbl_path = New System.Windows.Forms.Label
        Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
        Me.ListBox1 = New System.Windows.Forms.ListBox
        Me.AxWindowsMediaPlayer1 = New AxWMPLib.AxWindowsMediaPlayer
        CType(Me.AxWindowsMediaPlayer1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'btn_Exit
        '
        Me.btn_Exit.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.btn_Exit.Location = New System.Drawing.Point(402, 237)
        Me.btn_Exit.Name = "btn_Exit"
        Me.btn_Exit.Size = New System.Drawing.Size(105, 24)
        Me.btn_Exit.TabIndex = 1
        Me.btn_Exit.Text = "&Exit"
        '
        'lbl_path
        '
        Me.lbl_path.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.lbl_path.Location = New System.Drawing.Point(24, 159)
        Me.lbl_path.Name = "lbl_path"
        Me.lbl_path.Size = New System.Drawing.Size(210, 23)
        Me.lbl_path.TabIndex = 3
        Me.lbl_path.Text = "Label1"
        '
        'ListBox1
        '
        Me.ListBox1.Location = New System.Drawing.Point(12, 24)
        Me.ListBox1.Name = "ListBox1"
        Me.ListBox1.Size = New System.Drawing.Size(207, 95)
        Me.ListBox1.TabIndex = 4
        '
        'AxWindowsMediaPlayer1
        '
        Me.AxWindowsMediaPlayer1.Enabled = True
        Me.AxWindowsMediaPlayer1.Location = New System.Drawing.Point(357, 159)
        Me.AxWindowsMediaPlayer1.Name = "AxWindowsMediaPlayer1"
        Me.AxWindowsMediaPlayer1.OcxState = CType(resources.GetObject("AxWindowsMediaPlayer1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.AxWindowsMediaPlayer1.TabIndex = 5
        Me.AxWindowsMediaPlayer1.Visible = False
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(550, 296)
        Me.Controls.Add(Me.AxWindowsMediaPlayer1)
        Me.Controls.Add(Me.ListBox1)
        Me.Controls.Add(Me.lbl_path)
        Me.Controls.Add(Me.btn_Exit)
        Me.Name = "Form1"
        Me.Text = "Form1"
        CType(Me.AxWindowsMediaPlayer1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub
#End Region

    Private Sub btn_Exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Exit.Click
        Me.Close()

    End Sub

    Private Sub FillSongsListBox(ByVal path As String)
        If path.Length = 0 Then
            Return
        End If

        Dim di As DirectoryInfo = New DirectoryInfo(path)
        Dim fi() As FileInfo = di.GetFiles("*.mp3")
        Me.ListBox1.Items.Clear()
        Me.ListBox1.Text = ""
        Dim nxFi As FileInfo
        For Each nxFi In fi
            Me.ListBox1.Items.Add(nxFi.Name)
        Next
    End Sub

    Private Function LoadPathFromRegisTry() As String
        'RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\SkinCrafter\SkinCrafter Demo");
        'return rk.GetValue("SkinPath").ToString();
        Return ""
    End Function

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'load songs Folder
        foldDial.SelectedPath = "songs"
        SongFolder = foldDial.SelectedPath
        Me.lbl_path.Text = SongFolder

        FillSongsListBox(SongFolder)

        '----------------------------


    End Sub


End Class

+++++++++++++++++
Code End
+++++++++++++++++
[+][-]09/23/05 09:15 AM, ID: 14945615Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/23/05 10:44 AM, ID: 14946626Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/23/05 11:05 AM, ID: 14946825Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Microsoft Visual Basic.Net
Tags: axwindowsmediaplayer1
Sign Up Now!
Solution Provided By: WorkingJourneyman
Participating Experts: 1
Solution Grade: A
 
[+][-]02/03/06 04:43 PM, ID: 15870013Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]02/03/06 05:27 PM, ID: 15870241Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/07/06 03:52 AM, ID: 15891254Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81