在Web浏览器控件上播放本地文件中的视频 [英] playing videos from local files on web browser control

查看:767
本文介绍了在Web浏览器控件上播放本地文件中的视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道很少有玩家(wmp,vlc等)可以在表格上播放视频..但我很好奇媒体文件是否可以在网页浏览器控件上播放..我写了以下代码:

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:

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..

推荐答案

嗨ThePhantomUpvoter,

我不知道为什么你是直接给WebBrowser控件提供视频文件的路径吗?

而不是你可以准备一个带有视频标签和宽度,高度和源属性的html页面。

然后将此html页面的路径作为Url提供给WebBrowser控件。试试这个是否有效?

这样的东西

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
webBrowser1.Url = new Uri( @"D:\myfolder\MyHtmlPage.html");







-

Thnaks




--
Thnaks


这篇关于在Web浏览器控件上播放本地文件中的视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆