none
wpf webbrowser如果使用第三方播放器插件 RRS feed

  • 问题

  • wpf程序,我有个Html,内部使用的第三方播放器插件播放在线视频,放入浏览器时可以正常播放,但是使用webbrowser就无法正常播放。

    如上面所示,在浏览器中使用的是CyberPlayer,在webbrowser中使用的却是adobe flash player。

    如何解决在webbrowser中调用播放器的错误呢?谢谢


    • 已编辑 skczjun 2014年8月2日 5:54 修改
    2014年8月2日 3:10

答案

  • 使用了Host Winform的WebBrowser控件,仍然没能解决这个问题。
    <body>
    
    <div background-color=" #0000ff">
    <div id="playercontainer"></div>
    
        <script type="text/javascript" 
                src="js/cyberplayer.min.js"></script>
    
        <script type="text/javascript">
            var player = cyberplayer("playercontainer");
            player.setup({
                flashplayer: "player/cyberplayer.flash.swf",
                width: 640,
                height: 480,
                backcolor: "#00ff00",
                stretching: "uniform",
                file: "http://bcs.duapp.com/rhstest/media%2F43E7E9B718A94298B74161EA9AF2420C.mp4",
                image: "",
                autoStart: true,
                repeat: "always",
                volume: 100,
                controlbar: "over",
                // ak, sk 只需前16位
                ak: "VyEhRGbZcsgpGG2M",
                sk: "5uv85OO7qEUstQ4X"
            });
            
    </script> 
    </div>
    </body>
    这是我的html的主要组成,放到浏览器可以正常使用,使用webbrowser使用时采用的播放器组件就变成adobe flash player了

    你好,

    经过我的测试,我们需要在Head中添加以下Meta去开启WPF WebBrowser IE10模式:

    <meta http-equiv="X-UA-Compatible" content="IE=10" >

    以下是我的完整HTML代码:

    <!DOCTYPE html>
    <!-- saved from url=(0014)about:internet -->
    <html>
     <head>
      <meta charset="utf-8" />
                    <meta http-equiv="X-UA-Compatible" content="IE=10" >
     </head>
     <body>
    
    <div background-color=" #0000ff">
    <div id="playercontainer"></div>
    
        <script type="text/javascript" 
                src="js/cyberplayer.min.js"></script>
    
        <script type="text/javascript">
            var player = cyberplayer("playercontainer");
            player.setup({
                flashplayer: "player/cyberplayer.flash.swf",
                width: 640,
                height: 480,
                backcolor: "#00ff00",
                stretching: "uniform",
                file: "http://bcs.duapp.com/rhstest/media%2F43E7E9B718A94298B74161EA9AF2420C.mp4",
                image: "",
                autoStart: true,
                repeat: "always",
                volume: 100,
                controlbar: "over",
                // ak, sk 只需前16位
                ak: "VyEhRGbZcsgpGG2M",
                sk: "5uv85OO7qEUstQ4X"
            });
            
    </script> 
    </div>
    </body>
     
    </html>

    效果截图:

    左侧是你的原来的HTML,右侧可以正确显示。


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • 已标记为答案 skczjun 2014年8月6日 5:15
    2014年8月5日 10:13
    版主

全部回复

  • 你好,

    根据我的经验,WPF 的WebBrowser控件相对于Winform的WebBrowser控件精简了很多功能,你可以尝试我在之前回复中的修复函数,看是否有帮助:

    http://social.msdn.microsoft.com/Forums/en-US/311be0d2-854a-43cd-a73b-7f120f8c42f2/wpf-web-browser-control-and-javascripts?forum=wpf

    private void IEbrowserFix()
    {
                try
                {
                    Microsoft.Win32.RegistryKey regDM = default(Microsoft.Win32.RegistryKey);
                    bool is64 = Environment.Is64BitOperatingSystem;
                    string KeyPath = "";
                    if (is64)
                    {
                        KeyPath = "SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION";
                    }
                    else
                    {
                        KeyPath = "SOFTWARE\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION";
                    }
    
                    regDM = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(KeyPath, false);
                    if (regDM == null)
                    {
                        regDM = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(KeyPath);
                    }
    
                    object Sleutel = null;
                    if ((regDM != null))
                    {
                        string location = System.Environment.GetCommandLineArgs()[0];
                        string appName = System.IO.Path.GetFileName(location);
    
                        Sleutel = regDM.GetValue(appName);
                        if (Sleutel == null)
                        {
                            //Sleutel onbekend
                            regDM = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(KeyPath, true);
                            Sleutel = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(KeyPath, Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree);
    
                            //What OS are we using
                            Version OsVersion = System.Environment.OSVersion.Version;
    
                            if (OsVersion.Major == 6 & OsVersion.Minor == 1)
                            {
                                
                                //WIN 7
                                ((RegistryKey)Sleutel).SetValue(appName, 9000, Microsoft.Win32.RegistryValueKind.DWord);
                            }
                            else if (OsVersion.Major == 6 & OsVersion.Minor == 2)
                            {
                                //WIN 8
                                ((RegistryKey)Sleutel).SetValue(appName, 10000, Microsoft.Win32.RegistryValueKind.DWord);
                            }
                            else if (OsVersion.Major == 5 & OsVersion.Minor == 1)
                            {
                                //WIN xp
                                ((RegistryKey)Sleutel).SetValue(appName, 8000, Microsoft.Win32.RegistryValueKind.DWord);
                            }
    
                            ((RegistryKey)Sleutel).Close();
                        }
                    }
    
    
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
    }

    如果仍然不可以,可以尝试Host Winform的WebBrowser控件。


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年8月4日 7:30
    版主
  • 使用了Host Winform的WebBrowser控件,仍然没能解决这个问题。
    <body>
    
    <div background-color=" #0000ff">
    <div id="playercontainer"></div>
    
        <script type="text/javascript" 
                src="js/cyberplayer.min.js"></script>
    
        <script type="text/javascript">
            var player = cyberplayer("playercontainer");
            player.setup({
                flashplayer: "player/cyberplayer.flash.swf",
                width: 640,
                height: 480,
                backcolor: "#00ff00",
                stretching: "uniform",
                file: "http://bcs.duapp.com/rhstest/media%2F43E7E9B718A94298B74161EA9AF2420C.mp4",
                image: "",
                autoStart: true,
                repeat: "always",
                volume: 100,
                controlbar: "over",
                // ak, sk 只需前16位
                ak: "VyEhRGbZcsgpGG2M",
                sk: "5uv85OO7qEUstQ4X"
            });
            
    </script> 
    </div>
    </body>
    这是我的html的主要组成,放到浏览器可以正常使用,使用webbrowser使用时采用的播放器组件就变成adobe flash player了
    2014年8月4日 8:05
  • 使用了Host Winform的WebBrowser控件,仍然没能解决这个问题。
    <body>
    
    <div background-color=" #0000ff">
    <div id="playercontainer"></div>
    
        <script type="text/javascript" 
                src="js/cyberplayer.min.js"></script>
    
        <script type="text/javascript">
            var player = cyberplayer("playercontainer");
            player.setup({
                flashplayer: "player/cyberplayer.flash.swf",
                width: 640,
                height: 480,
                backcolor: "#00ff00",
                stretching: "uniform",
                file: "http://bcs.duapp.com/rhstest/media%2F43E7E9B718A94298B74161EA9AF2420C.mp4",
                image: "",
                autoStart: true,
                repeat: "always",
                volume: 100,
                controlbar: "over",
                // ak, sk 只需前16位
                ak: "VyEhRGbZcsgpGG2M",
                sk: "5uv85OO7qEUstQ4X"
            });
            
    </script> 
    </div>
    </body>
    这是我的html的主要组成,放到浏览器可以正常使用,使用webbrowser使用时采用的播放器组件就变成adobe flash player了

    你好,

    经过我的测试,我们需要在Head中添加以下Meta去开启WPF WebBrowser IE10模式:

    <meta http-equiv="X-UA-Compatible" content="IE=10" >

    以下是我的完整HTML代码:

    <!DOCTYPE html>
    <!-- saved from url=(0014)about:internet -->
    <html>
     <head>
      <meta charset="utf-8" />
                    <meta http-equiv="X-UA-Compatible" content="IE=10" >
     </head>
     <body>
    
    <div background-color=" #0000ff">
    <div id="playercontainer"></div>
    
        <script type="text/javascript" 
                src="js/cyberplayer.min.js"></script>
    
        <script type="text/javascript">
            var player = cyberplayer("playercontainer");
            player.setup({
                flashplayer: "player/cyberplayer.flash.swf",
                width: 640,
                height: 480,
                backcolor: "#00ff00",
                stretching: "uniform",
                file: "http://bcs.duapp.com/rhstest/media%2F43E7E9B718A94298B74161EA9AF2420C.mp4",
                image: "",
                autoStart: true,
                repeat: "always",
                volume: 100,
                controlbar: "over",
                // ak, sk 只需前16位
                ak: "VyEhRGbZcsgpGG2M",
                sk: "5uv85OO7qEUstQ4X"
            });
            
    </script> 
    </div>
    </body>
     
    </html>

    效果截图:

    左侧是你的原来的HTML,右侧可以正确显示。


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • 已标记为答案 skczjun 2014年8月6日 5:15
    2014年8月5日 10:13
    版主