How can u create a progress bar and a playlist for a custom media player??!!
can anyone help??!!

For progressBar: Use a System.Windows.Timer class. You only have to get the total time and then set the beginning and the end of the timer. Use Tick event of the timer, to move the progressBar forward.
Heres an example:

private void InitializeMyTimer()
            // Set the interval for the timer.
            time.Interval = 1000;
            // Connect the Tick event of the timer to its event handler.
            time.Tick += new EventHandler(IncreaseProgressBar);
            // Start the timer.

        //The following codes will make the progressbar increase the step one per time.

        void IncreaseProgressBar(Object sender, EventArgs e)

            // Increment the value of the ProgressBar a value of one each time.

            if (progressBar1.Value == progressBar1.Maximum)
                // Stop the timer.

About the playList. You have to get the files from specified directory and show only their Name.
Use a FileInto[] array to get and use them to play.

DirectoryInfo taskDirectory = new DirectoryInfo("specify full path to the directory with mp3 files");
FileInfo[] taskFiles = taskDirectory.GetFiles("*.mp3");

Edited 5 Years Ago by Mitja Bonca: n/a

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QuartzTypeLib;
using System.Runtime.InteropServices;
using System.IO;

namespace trying
    public partial class Form1 : Form
        public static extern int waveOutGetVolume(IntPtr hwo, out uint dwVolume);

        public static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);

        public Form1()
        // Define constants used for specifying the window style.
        private const int WS_CHILD = 0x40000000;
        private const int WS_CLIPCHILDREN = 0x2000000;
        // Hold a form-level reference to the media control interface,
        // so the code can control playback of the currently loaded
        // movie.
        public IMediaControl mc = null;

        // Hold a form-level reference to the video window in case it
        // needs to be resized.
        public IVideoWindow videoWindow = null;


        private void button1_Click(object sender, EventArgs e)
            if (mc != null)


        private void button2_Click(object sender, EventArgs e)
            FilgraphManager graphManager = new FilgraphManager();

            videoWindow = (IVideoWindow)graphManager;
            // Start the playback (asynchronously).
            mc = (IMediaControl)graphManager;

        private void button3_Click(object sender, EventArgs e)


        private void trackBar1_Scroll(object sender, EventArgs e)
            //Calculate the volume that's being set
            int NewVolume = ((ushort.MaxValue / 10) * trackBar1.Value);
            // Set the same volume for both the left and the right channels
            uint NewVolumeAllChannels = (((uint)NewVolume & 0x0000ffff) | ((uint)NewVolume << 16));
            // Set the volume
            waveOutSetVolume(IntPtr.Zero, NewVolumeAllChannels);

        private void newFileToolStripMenuItem_Click(object sender, EventArgs e)
            // Allow the user to choose a file.
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter =
            "Media Files|*.mpg;*.avi;*.wma;*.mov;*.wav;*.mp2;*.mp3|" +
            "All Files|*.*";
            if (DialogResult.OK == openFileDialog.ShowDialog())
                // Stop the playback for the current movie, if it exists.
                if (mc != null) mc.Stop();
                // Load the movie file.
                FilgraphManager graphManager = new FilgraphManager();
                // Attach the view to a picture box on the form.
                    videoWindow = (IVideoWindow)graphManager;
                    videoWindow.Owner = (int)pictureBox1.Handle;
                    videoWindow.WindowStyle = WS_CHILD | WS_CLIPCHILDREN;
                    // An error can occur if the file does not have a video
                    // source (for example, an MP3 file).
                    // You can ignore this error and still allow playback to
                    // continue (without any visualization).



                // Start the playback (asynchronously).
                mc = (IMediaControl)graphManager;


this is my coding for a file..!! how can i get to knw the length of a file here??!!

This article has been dead for over six months. Start a new discussion instead.