Question : How can i make my pictures display in sequence along with my videos?

I'm trying to create a windows form that would allow me to display my pictures and video in sequence.  Please look at the following code and let me know how i could restructure this code to do what i am trying to do:

 private void button2_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dlg = new FolderBrowserDialog();
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                filemax = 0;
                panel1.Controls.Clear();
                foreach (string files in Directory.GetFiles(dlg.SelectedPath))
                {
                    if (files.EndsWith(".jpg") || files.EndsWith(".jpeg") || files.EndsWith(".avi") || files.EndsWith(".mpeg"))
                    {
                        //PictureBox pb = new PictureBox();
                        //Image img = Image.FromFile(files);
                        //pb.Image = img;
                        //panel1.Controls.Add(pb);
                        listView1.Items.Add(files);
                    }
                    //else
                    //{
                    //    if (()
                    //    {
                    //        axWindowsMediaPlayer1.URL = files;
                    //    }
                    //}
                    filemax++;
                }
                timer1.Enabled = true;
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
           
            if (filecount == filemax)
            {
                filecount = 0;
            }
            PictureBox p = (PictureBox)panel1.Controls[filecount];

            pictureBox1.Image = p.Image;

            filecount++;
        }

Answer : How can i make my pictures display in sequence along with my videos?

Hi,

You need to add new control in Toolbox. Right Click in ToolBox and select Choose Items. In COM Components Tab -->select Windows Media Player (wmp.dll). --> Drag and Drop the same on Window Form. Also add a button on Form name as btnPlay

And then apply code as shown in attach code.

Regards,
V.S.Saini
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using System.Threading;

namespace EE_Test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            axWindowsMediaPlayer1.StatusChange += new EventHandler(axWindowsMediaPlayer1_StatusChange);
        }

        void axWindowsMediaPlayer1_StatusChange(object sender, EventArgs e)
        {
            // Restart playing all items in playlist
            axWindowsMediaPlayer1.Ctlcontrols.play();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //ProcessStartInfo startInfo = new ProcessStartInfo();
            //startInfo.FileName = "CCleaner.EXE";
            ////startInfo.Arguments = f;
            //Process.Start(startInfo);
        }

        private void btnPlay_Click(object sender, EventArgs e)
        {
            // Creating PlayList
            WMPLib.IWMPPlaylist plist = axWindowsMediaPlayer1.newPlaylist("MyPlayList", "");
            DirectoryInfo di = new DirectoryInfo(@"D:\Zodes");

            foreach (FileInfo file in di.GetFiles("*", SearchOption.AllDirectories))
            {
                if (file.Extension.Equals(".bmp") || file.Extension.Equals(".jpg") ||
                    file.Extension.Equals(".mpeg") || file.Extension.Equals(".wmv") || file.Extension.Equals(".avi"))
                {
                    plist.appendItem(axWindowsMediaPlayer1.newMedia(file.FullName));
                    axWindowsMediaPlayer1.currentPlaylist = plist;              
                }
                if (axWindowsMediaPlayer1.currentPlaylist.count > 0)
                {
                    axWindowsMediaPlayer1.Ctlcontrols.playItem(axWindowsMediaPlayer1.currentPlaylist.get_Item(0));
                }
            }
        }
    }
}
Random Solutions  
 
programming4us programming4us