Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I know there are few players (wmp,vlc etc) to play videos on form.. But i am curious that whether the media files can be played on a web browser control.. i have wrote following piece of code:
C#
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;

namespace webBrowser
{
    public partial class Form1 : Form
    {
        WebBrowser webBrowser1;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            webBrowser1 = new WebBrowser();
            webBrowser1.Size = new System.Drawing.Size(578, 446);
            webBrowser1.Dock = System.Windows.Forms.DockStyle.Top;
            panel1.Controls.Add(webBrowser1);
            //webBrowser1.Navigate("https://www.google.co.in/");
            webBrowser1.Url = new Uri( @"D:\myfolder\game.avi");
        }
    }
}

here when i run my code A download pop up comes and the file will be downloaded.. and the form shows web page not available .. Any help would be appreciated..
Posted
Comments
[no name] 21-Sep-13 8:15am    
Probably because "D:\myfolder\game.avi" is not a valid URL. Try file://D:\myfolder\game.avi
Sachin Athrady 21-Sep-13 8:22am    
same result bro
Sachin Athrady 21-Sep-13 8:18am    
thx fr ur reply.. But tht gives some error ... i ve tried this ( "D:\\myfolder\\game.avi");
but still no change :(

1 solution

Hi ThePhantomUpvoter ,
I don't know why you are directly giving path of video file to WebBrowser control?
Instead of that you can prepare a html page with video tag and width , height and source attribute specified for it.
Then give this html page's path as Url to your WebBrowser control. Try this whether it is working or not?
Something like this
C#
webBrowser1.Url = new Uri( @"D:\myfolder\MyHtmlPage.html");



--
Thnaks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900