CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Apr 2013
    Posts
    5

    C# using windows forms how can I make media player to play MPEG2 files ?

    Hello, I am trying to make a media player that can play MPEG2 files. I already made one using windows media player tool from .COM components of C# in .NET4.5 how can I make it support MPEG2 files for playing. This is my code :

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;

    namespace Media_Player_Basic
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    private void openToolStripMenuItem_Click(object sender, EventArgs e)
    {
    OpenFileDialog open = new OpenFileDialog();
    open.Title = "Open";
    open.Filter = "All Files|*.*";
    try
    {
    if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    {
    BasicWindowsMediaPlayer.URL = (open.FileName);
    }
    }
    catch (ArgumentException ex) {
    MessageBox.Show(ex.Message.ToString(),"Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message.ToString(), "Massive Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    }
    }
    }

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: C# using windows forms how can I make media player to play MPEG2 files ?

    What version of WindowsMediaPlayer are you using? Can you play the mpeg2 files in the media player application (outside of your code)?

  3. #3
    Join Date
    Apr 2013
    Posts
    5

    Re: C# using windows forms how can I make media player to play MPEG2 files ?

    Quote Originally Posted by Arjay View Post
    What version of WindowsMediaPlayer are you using? Can you play the mpeg2 files in the media player application (outside of your code)?
    What I am seeing from COM components Windows Media Player its using the version 1.0
    I am using visual studio 2012.

    I cannot play it inside or outside of code.

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: C# using windows forms how can I make media player to play MPEG2 files ?

    Quote Originally Posted by rumman0786 View Post
    What I am seeing from COM components Windows Media Player its using the version 1.0
    I am using visual studio 2012.

    I cannot play it inside or outside of code.
    Because you can't play the file outside the code, it tells me that the version you are using is either too old or you need to have the correct codec to play the file.

  5. #5
    Join Date
    Apr 2013
    Posts
    5

    Re: C# using windows forms how can I make media player to play MPEG2 files ?

    Quote Originally Posted by Arjay View Post
    Because you can't play the file outside the code, it tells me that the version you are using is either too old or you need to have the correct codec to play the file.
    I thats what I am trying to learn. How do I include a codec in WMP with code. Can you help me ?

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: C# using windows forms how can I make media player to play MPEG2 files ?

    Quote Originally Posted by rumman0786 View Post
    I thats what I am trying to learn. How do I include a codec in WMP with code. Can you help me ?
    How do you know your problem is because of a missing codec? At any rate, if it is the problem, you will have to detect the presence of the codec you need, and install it if necessary in your app's setup program.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured