locked
Windows media player RRS feed

  • Question

  • Dear Sir,

    1) How to do the replay part in windows media player?

    In the following code sample, we have tried to show the 3D images in the windows media player according to the characters written in the text file.Those 3D images are shown, reading a text file character by character.So those can be played only once.But we want to play those 3D images again and again using another button. 

    And also in following code sample there are two media players to show the 3D images.So we want to show in one media player and replay it. 

     

    public class Form1 : System.Windows.Forms.Form

    {

    private System.Windows.Forms.MainMenu mainMenu1;

    private System.Windows.Forms.MenuItem menuItem1;

    private System.Windows.Forms.MenuItem menuItem2;

    private System.Windows.Forms.MenuItem menuItem3;

    private System.Windows.Forms.MenuItem menuItem4;

    private System.Windows.Forms.MenuItem menuItem5;

    private System.Windows.Forms.MenuItem menuItem6;

    private AxWMPLib.AxWindowsMediaPlayer wmplayer2;

    private AxWMPLib.AxWindowsMediaPlayer wmplayer;

    private System.Windows.Forms.Button button1;

    private System.ComponentModel.IContainer components;

    private String Mpath=null;

    private static int count = 1;

    private static int count1 = 1;

    private string[] wmplist ;

    private string[] wmplist1 ;

    char x = 's';

    private System.Windows.Forms.ComboBox comboBox1;

    private System.Windows.Forms.Label label2;

    private System.Windows.Forms.MenuItem menuItem7;

    private System.Windows.Forms.MenuItem menuItem8;

    private System.Windows.Forms.MenuItem menuItem9;

    private System.Windows.Forms.GroupBox groupBox1;

    private System.Windows.Forms.MenuItem menuItem10;

    private System.Windows.Forms.PictureBox pictureBox1;

    private System.Windows.Forms.Label label3;

    private System.Windows.Forms.Panel panel1;

    private System.Windows.Forms.Panel panel2;

    private System.Windows.Forms.Label label4;

    private System.Windows.Forms.PictureBox pictureBox2;

    int i=0;

    public Form1()

    {

    InitializeComponent();

    }

    /// <summary>

    /// Clean up any resources being used.

    /// </summary>

    protected override void Dispose( bool disposing )

    {

    if( disposing )

    {

    if (components != null)

    {

    components.Dispose();

    }

    }

    base.Dispose( disposing );

    }

    #region Windows Form Designer generated code

    /// <summary>

    /// Required method for Designer support - do not modify

    /// the contents of this method with the code editor.

    /// </summary>

    private void InitializeComponent()

    {

    System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));

    this.mainMenu1 = new System.Windows.Forms.MainMenu();

    this.menuItem1 = new System.Windows.Forms.MenuItem();

    this.menuItem2 = new System.Windows.Forms.MenuItem();

    this.menuItem3 = new System.Windows.Forms.MenuItem();

    this.menuItem4 = new System.Windows.Forms.MenuItem();

    this.menuItem10 = new System.Windows.Forms.MenuItem();

    this.menuItem5 = new System.Windows.Forms.MenuItem();

    this.menuItem6 = new System.Windows.Forms.MenuItem();

    this.menuItem8 = new System.Windows.Forms.MenuItem();

    this.menuItem9 = new System.Windows.Forms.MenuItem();

    this.menuItem7 = new System.Windows.Forms.MenuItem();

    this.wmplayer2 = new AxWMPLib.AxWindowsMediaPlayer();

    this.wmplayer = new AxWMPLib.AxWindowsMediaPlayer();

    this.button1 = new System.Windows.Forms.Button();

    this.comboBox1 = new System.Windows.Forms.ComboBox();

    this.label2 = new System.Windows.Forms.Label();

    this.groupBox1 = new System.Windows.Forms.GroupBox();

    this.label3 = new System.Windows.Forms.Label();

    this.pictureBox1 = new System.Windows.Forms.PictureBox();

    this.panel1 = new System.Windows.Forms.Panel();

    this.panel2 = new System.Windows.Forms.Panel();

    this.label4 = new System.Windows.Forms.Label();

    this.pictureBox2 = new System.Windows.Forms.PictureBox();

    ((System.ComponentModel.ISupportInitialize)(this.wmplayer2)).BeginInit();

    ((System.ComponentModel.ISupportInitialize)(this.wmplayer)).BeginInit();

    this.groupBox1.SuspendLayout();

    this.panel1.SuspendLayout();

    this.panel2.SuspendLayout();

    this.SuspendLayout();

    //

    // mainMenu1

    //

    this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {

    this.menuItem1,

    this.menuItem5,

    this.menuItem6,

    this.menuItem7});

    //

    // menuItem1

    //

    this.menuItem1.Index = 0;

    this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {

    this.menuItem2,

    this.menuItem3,

    this.menuItem4,

    this.menuItem10});

    this.menuItem1.Text = "Help";

    //

    // menuItem2

    //

    this.menuItem2.Index = 0;

    this.menuItem2.Text = "What\'s Voice to Sign Language?";

    this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);

    //

    // menuItem3

    //

    this.menuItem3.Index = 1;

    this.menuItem3.Text = "What\'s Finger Spelling?";

    this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);

    //

    // menuItem4

    //

    this.menuItem4.Index = 2;

    this.menuItem4.Text = "Sample";

    this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);

    //

    // menuItem10

    //

    this.menuItem10.Index = 3;

    this.menuItem10.Text = "Training Section";

    this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click);

    //

    // menuItem5

    //

    this.menuItem5.Index = 1;

    this.menuItem5.Text = "Demo";

    this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);

    //

    // menuItem6

    //

    this.menuItem6.Index = 2;

    this.menuItem6.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {

    this.menuItem8,

    this.menuItem9});

    this.menuItem6.Text = "ASL Dictionary";

    this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);

    //

    // menuItem8

    //

    this.menuItem8.Index = 0;

    this.menuItem8.Text = "Slow Speed";

    this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);

    //

    // menuItem9

    //

    this.menuItem9.Index = 1;

    this.menuItem9.Text = "Fast Speed";

    this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);

    //

    // menuItem7

    //

    this.menuItem7.Index = 3;

    this.menuItem7.Text = "About Us";

    this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);

    //

    // wmplayer2

    //

    this.wmplayer2.ContainingControl = this;

    this.wmplayer2.Enabled = true;

    this.wmplayer2.Location = new System.Drawing.Point(24, 24);

    this.wmplayer2.Name = "wmplayer2";

    this.wmplayer2.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("wmplayer2.OcxState")));

    this.wmplayer2.Size = new System.Drawing.Size(448, 376);

    this.wmplayer2.TabIndex = 0;

    this.wmplayer2.PlayStateChange += new AxWMPLib._WMPOCXEvents_PlayStateChangeEventHandler(this.wmplayer2_PlayStateChange);

    this.wmplayer2.VisibleChanged += new System.EventHandler(this.wmplayer2_VisibleChanged);

    //

    // wmplayer

    //

    this.wmplayer.ContainingControl = this;

    this.wmplayer.Enabled = true;

    this.wmplayer.Location = new System.Drawing.Point(24, 24);

    this.wmplayer.Name = "wmplayer";

    this.wmplayer.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("wmplayer.OcxState")));

    this.wmplayer.Size = new System.Drawing.Size(448, 376);

    this.wmplayer.TabIndex = 1;

    this.wmplayer.PlayStateChange += new AxWMPLib._WMPOCXEvents_PlayStateChangeEventHandler(this.wmplayer_PlayStateChange);

    this.wmplayer.VisibleChanged += new System.EventHandler(this.wmplayer_VisibleChanged);

    this.wmplayer.PlaylistCollectionChange += new System.EventHandler(this.button2_Click);

    //

    // button1

    //

    this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

    this.button1.ForeColor = System.Drawing.Color.Black;

    this.button1.Location = new System.Drawing.Point(528, 368);

    this.button1.Name = "button1";

    this.button1.Size = new System.Drawing.Size(136, 32);

    this.button1.TabIndex = 2;

    this.button1.Text = "Play";

    this.button1.Click += new System.EventHandler(this.button1_Click);

    //

    // comboBox1

    //

    this.comboBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

    this.comboBox1.Items.AddRange(new object[] {

    "Fast",

    "Slow"});

    this.comboBox1.Location = new System.Drawing.Point(528, 312);

    this.comboBox1.Name = "comboBox1";

    this.comboBox1.Size = new System.Drawing.Size(136, 28);

    this.comboBox1.TabIndex = 5;

    this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);

    //

    // label2

    //

    this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

    this.label2.ForeColor = System.Drawing.Color.Black;

    this.label2.Location = new System.Drawing.Point(528, 288);

    this.label2.Name = "label2";

    this.label2.Size = new System.Drawing.Size(120, 24);

    this.label2.TabIndex = 6;

    this.label2.Text = "Select Speed";

    //

    // groupBox1

    //

    this.groupBox1.BackColor = System.Drawing.SystemColors.ActiveCaptionText;

    this.groupBox1.Controls.Add(this.wmplayer);

    this.groupBox1.Controls.Add(this.wmplayer2);

    this.groupBox1.Location = new System.Drawing.Point(8, 80);

    this.groupBox1.Name = "groupBox1";

    this.groupBox1.Size = new System.Drawing.Size(496, 424);

    this.groupBox1.TabIndex = 7;

    this.groupBox1.TabStop = false;

    //

    // label3

    //

    this.label3.BackColor = System.Drawing.Color.Transparent;

    this.label3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

    this.label3.ForeColor = System.Drawing.Color.Navy;

    this.label3.Location = new System.Drawing.Point(8, 8);

    this.label3.Name = "label3";

    this.label3.Size = new System.Drawing.Size(104, 32);

    this.label3.TabIndex = 12;

    this.label3.Click += new System.EventHandler(this.label3_Click);

    //

    // pictureBox1

    //

    this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

    this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));

    this.pictureBox1.Location = new System.Drawing.Point(520, 88);

    this.pictureBox1.Name = "pictureBox1";

    this.pictureBox1.Size = new System.Drawing.Size(152, 160);

    this.pictureBox1.TabIndex = 9;

    this.pictureBox1.TabStop = false;

    //

    // panel1

    //

    this.panel1.BackColor = System.Drawing.SystemColors.ControlText;

    this.panel1.Controls.Add(this.panel2);

    this.panel1.Location = new System.Drawing.Point(528, 424);

    this.panel1.Name = "panel1";

    this.panel1.Size = new System.Drawing.Size(136, 64);

    this.panel1.TabIndex = 13;

    this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);

    //

    // panel2

    //

    this.panel2.BackColor = System.Drawing.SystemColors.ActiveCaptionText;

    this.panel2.Controls.Add(this.label3);

    this.panel2.Location = new System.Drawing.Point(8, 8);

    this.panel2.Name = "panel2";

    this.panel2.Size = new System.Drawing.Size(120, 48);

    this.panel2.TabIndex = 14;

    this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);

    //

    // label4

    //

    this.label4.BackColor = System.Drawing.SystemColors.ControlText;

    this.label4.ForeColor = System.Drawing.Color.Snow;

    this.label4.Location = new System.Drawing.Point(120, 136);

    this.label4.Name = "label4";

    this.label4.Size = new System.Drawing.Size(272, 24);

    this.label4.TabIndex = 14;

    //

    // pictureBox2

    //

    this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));

    this.pictureBox2.Location = new System.Drawing.Point(96, -120);

    this.pictureBox2.Name = "pictureBox2";

    this.pictureBox2.Size = new System.Drawing.Size(408, 200);

    this.pictureBox2.TabIndex = 15;

    this.pictureBox2.TabStop = false;

    //

    // Form1

    //

    this.AutoScaleBaseSize = new System.Drawing.Size(10, 24);

    this.BackColor = System.Drawing.SystemColors.Control;

    this.ClientSize = new System.Drawing.Size(680, 521);

    this.Controls.Add(this.pictureBox2);

    this.Controls.Add(this.label4);

    this.Controls.Add(this.panel1);

    this.Controls.Add(this.pictureBox1);

    this.Controls.Add(this.groupBox1);

    this.Controls.Add(this.label2);

    this.Controls.Add(this.comboBox1);

    this.Controls.Add(this.button1);

    this.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

    this.ForeColor = System.Drawing.Color.RosyBrown;

    this.Menu = this.mainMenu1;

    this.Name = "Form1";

    this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

    this.Text = "Voice to Sign Language";

    this.Load += new System.EventHandler(this.Form1_Load);

    ((System.ComponentModel.ISupportInitialize)(this.wmplayer2)).EndInit();

    ((System.ComponentModel.ISupportInitialize)(this.wmplayer)).EndInit();

    this.groupBox1.ResumeLayout(false);

    this.panel1.ResumeLayout(false);

    this.panel2.ResumeLayout(false);

    this.ResumeLayout(false);

    }

    #endregion

    /// <summary>

    /// The main entry point for the application.

    /// </summary>

    [STAThread]

    static void Main()

    {

    Application.Run(new Form1());

    // The following line is ignored since

    // ApartmentState can only be set once.

    }

     

    private void Form1_Load(object sender, System.EventArgs e)

    {

    ProcessFile(path);

    }

    //public string path=null;

    public string line=null;

    public string str=null;

    public string path=null;

    private void ProcessFile(string fileName)

    {

    try

    {

    path=@" C:\Documents and Settings\home\Desktop\wordspot\0001.rec";

    using (StreamReader sr = new StreamReader(path))

    {

    while ((str = sr.ReadLine()) != null)

    {

     

    line+=str +" ";

    }

    }

    line.Trim();

    wmplist=new string[line.Length];

    for(i=0;i<line.Length-1;i++)

    {

    wmplistIdea=line.Substring(i,1);

    if(wmplistIdea==" ")

    {

     

     

    if(line.Substring(i+1,1)==" ")

    break;

    wmplistIdea="SPACE";

     

     

    }

    }

    }

    catch (Exception ex)

    {

    MessageBox.Show(ex.ToString());

    }

    }

    void PlayMedia(String str)

    {

    if (str!=null)

    wmplayer.URL = Mpath + str+".avi";

    else

    MessageBox.Show("No video Available");

     

    }

    private void menuItem5_Click(object sender, System.EventArgs e)

    {

    Form32 fr32=new Form32();

    fr32.Show();

    }

    private void menuItem2_Click(object sender, System.EventArgs e)

    {

    Form2 fr2=new Form2();

    fr2.Show();

    }

    private void menuItem3_Click(object sender, System.EventArgs e)

    {

    Form3 fr3=new Form3();

    fr3.Show();

    }

    private void menuItem4_Click(object sender, System.EventArgs e)

    {

    Find fd =new Find();

    fd.Show();

    }

    private void menuItem6_Click(object sender, System.EventArgs e)

    {

    }

    private void wmplayer_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)

    {

    if (wmplayer.playState == WMPLib.WMPPlayState.wmppsStopped)

    {

    wmplayer.Visible = false;

    wmplayer2.Visible = true;

    //call reading methode

    wmplayer2.URL = Mpath +wmplist[count]+".avi";

    label3.Text=wmplist[count];

    count++;

    wmplayer2.Ctlcontrols.play();

    }

    }

    private void wmplayer2_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)

    {

    if (wmplayer2.playState == WMPLib.WMPPlayState.wmppsStopped)

    {

    wmplayer.Visible = true;

    wmplayer2.Visible = false;

    //call reading methode

    wmplayer.URL = Mpath +wmplist[count]+".avi";

    //WMPLib.WMPPlaylist ;

    label3.Text=wmplist[count];

    count++;

    //lblcount.Text = count.ToString();

    wmplayer.Ctlcontrols.play();

    ;

    }

    }

    private void wmplayer2_VisibleChanged(object sender, System.EventArgs e)

    {

    wmplayer.Refresh();

    wmplayer2.Refresh();

    }

    private void wmplayer_VisibleChanged(object sender, System.EventArgs e)

    {

    wmplayer.Refresh();

    wmplayer2.Refresh();

    }

    private void button1_Click(object sender, System.EventArgs e)

    {

    SelectSpeed();

    wmplayer.URL=Mpath+wmplist[0]+".avi";

    label3.Text=wmplist[0];

    wmplayer.Ctlcontrols.play();

    }

    public void SelectSpeed()

    {

    if(comboBox1.SelectedItem.ToString()=="Slow")

    {

    Mpath=@"C:\Documents and Settings\home\Desktop\Last\new_du0.3\";

    }

    else if(comboBox1.SelectedItem.ToString()=="Fast")

    {

    Mpath=@"C:\Documents and Settings\home\Desktop\Last\new_du0\";

    }

    }

    private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)

    {

    }

    private void button2_Click(object sender, System.EventArgs e)

    {

    wmplayer.URL=Mpath+wmplist[0]+".avi";

    wmplayer.Ctlcontrols.play();

    SelectSpeed();

    fun();

    }

    private void menuItem7_Click(object sender, System.EventArgs e)

    {

    AboutUs ab=new AboutUs();

    ab.Show();

    }

    private void menuItem8_Click(object sender, System.EventArgs e)

    {

    Form31 fr31=new Form31();

    fr31.Show();

    }

    private void menuItem9_Click(object sender, System.EventArgs e)

    {

    Form30 fr30=new Form30();

    fr30.Show();

    }

    private void menuItem10_Click(object sender, System.EventArgs e)

    {

    search se=new search();

    se.Show();

    }

     

     

    public void fun()

    {

    while(line==null)

    {

    if (wmplayer.playState == WMPLib.WMPPlayState.wmppsStopped)

    {

    wmplayer.Visible = false;

    wmplayer2.Visible = true;

    //call reading methode

    wmplayer2.URL = Mpath +wmplist1[count1]+".avi";

    //wmplayer2.URL = Mpath +wmplist1[count]+".avi";

    wmplayer2.Ctlcontrols.play();

    count1++;

    wmplayer2.Ctlcontrols.play();

     

    }

     

    if (wmplayer2.playState == WMPLib.WMPPlayState.wmppsStopped)

    {

    wmplayer.Visible = true;

    wmplayer2.Visible = false;

    //call reading methode

    MessageBox.Show(count1.ToString());

    wmplayer.URL = Mpath +wmplist1[count1]+".avi";

    count1++;

    wmplayer.Ctlcontrols.play();

    }

    }//while

     

    }

     

    Thankyou verymuch.

    with regards Sachini.

     

     

    Monday, July 24, 2006 6:19 AM

Answers