2017-09-12 27 views
19

यूट्यूब ने हाल ही में प्रारूप www.youtube.com/v/{key} में एम्बेड किए गए वीडियो का समर्थन करना बंद कर दिया है। इसलिए मैं वीडियो को "/ v /" से "/ embed /" में बदलने की कोशिश कर रहा था। लेकिन जब मैं वीडियो पर नेविगेट करने की कोशिश निम्न त्रुटियों तो पॉप अप:वेबब्रोसर में यूट्यूब वीडियो एम्बेड करना। ऑब्जेक्ट संपत्ति या विधि का समर्थन नहीं करता

WPF:

enter image description here

enter image description here

enter image description here

मैं निम्नलिखित का उपयोग कर वेबपृष्ठ से नेविगेट कर रहा हूँ

<WebBrowser x:Name="trailer" Margin="655,308,30,135"/> 

C#

trailer.Navigate("https://www.youtube.com/embed/v2fDTOdWuQQ?rel=0&amp;showinfo=0"); 

क्यों इस "/ वी /" से "/ एम्बेड /" से स्विच करके बस काम करने में असमर्थ है? और मैं इस मुद्दे को हल करने के बारे में कैसे जा सकता हूं?

+2

बस फोन है कि इससे पहले कि आप नेविगेट करें: https://stackoverflow.com/a/34267121/403671 –

+0

@SimonMourier मैं सही है एक ही मुद्दा और ऐसा प्रतीत होता है कि आपके लिंक पर रुईविली का जवाब मेरी स्थिति के लिए काम करता है। –

+0

@ जॉन ओडम हाँ, यह उस धागे में सबसे अच्छा जवाब है, लेकिन, हे, यह 500 रुपये के लायक नहीं है :-) –

उत्तर

12

यह एक मौजूदा अतः थ्रेड

Use latest version of Internet Explorer in the webbrowser control

धागे की डुप्लिकेट वास्तविक कोड उसके साथ कार्य करने के साथ उस में जवाब के बहुत सारे है।

ही में सबसे अच्छा सुझाव HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

में अपने app.exe के लिए एक बहुत ही उच्च संख्या निर्धारित करने के लिए है मैं इसे 20000 करने के लिए सेट है, जो संस्करण आ रहा है और नवीनतम संस्करण का उपयोग करने का बहुत में काम करने के लिए मान के लिए सुरक्षित है जैसे की। इस मामले को आसानी से आपके exe के सेटअप के दौरान किया जा सकता है। तो आपको चिंता करने की ज़रूरत नहीं होगी कि कौन सा संस्करण मौजूद है और कौन सा नहीं है। काम करने के लिए एम्बेड करने के लिए आपको आवश्यक न्यूनतम संस्करण आईई 9 है।

एक और विकल्प वास्तव में एंबेडेड आईई का उपयोग नहीं करना है। इसके बजाय क्रोमियम का उपयोग करें। वहाँ

https://cefsharp.github.io/

पर उसी के लिए CefSharp परियोजना इस परियोजना आप अपने WinForms या WPF अनुप्रयोग में क्रोमियम ब्राउज़र एम्बेड करने के लिए अनुमति देता है। ऐप काफी सरल है

using System.Windows.Forms; 
using CefSharp; 
using CefSharp.WinForms; 

namespace WindowsFormsApp2 
{ 
    public partial class Form1 : Form 
    { 
     ChromiumWebBrowser chrome; 

     private void InitChrome() 
     { 
      CefSettings settings = new CefSettings(); 
      Cef.Initialize(settings); 
      chrome = new ChromiumWebBrowser("https://www.youtube.com/embed/v2fDTOdWuQQ?rel=0&amp;showinfo=0"); 
      this.Controls.Add(chrome); 
      chrome.Dock = DockStyle.Fill; 
     } 
     public Form1() 
     { 
      InitializeComponent(); 
      InitChrome(); 
      //this.webBrowser1.Navigate("https://www.youtube.com/embed/v2fDTOdWuQQ?rel=0&amp;showinfo=0"); 
     } 

    } 
} 

और बहुत अच्छा काम करता है। यह आपके ऐप को निर्भर नहीं करेगा कि लक्ष्य मशीन पर कौन सा ब्राउज़र स्थापित है।

Youtube Chromium

0

अपने वेब ब्राउजर को "मूक मोड" (इन स्क्रिप्ट त्रुटियों को अनदेखा करने) में सेट करने का प्रयास करें। इसे कुछ काले आईई/कॉम जादू की आवश्यकता है, लेकिन यह काम करता है।

https://stackoverflow.com/a/6198700/3629903 इसे कैसे करें पर देखें।

+1

मूक मोड सिर्फ त्रुटियों को अनदेखा करता है और मुझे एक ब्लैक बॉक्स के साथ छोड़ दिया जाता है। – difurious

0

उपयोग WebBrowser.NavigateToString बजाय WebBrowser.Navigate और बदले एचटीएमएल का उपयोग यूआरएल के।अपने आसान संदर्भ

enter image description here

+0

आप नीचे दिए गए लिंक से पूर्ण कार्य कोड डाउनलोड कर सकते हैं https://www.dropbox.com/s/peuep22qqy200ot/YoutubeIssue.zip?dl=0 –

1

WPF के लिए इस स्क्रीनशॉट की जाँच एक विशेषता "ब्राउज़र अनुकरण" इस प्रकार की समस्या को हल करने के लिए है।

नीचे enumaration

public enum BrowserEmulationVersion 
{ 
    Default = 0, 
    Version7 = 7000, 
    Version8 = 8000, 
    Version8Standards = 8888, 
    Version9 = 9000, 
    Version9Standards = 9999, 
    Version10 = 10000, 
    Version10Standards = 10001, 
    Version11 = 11000, 
    Version11Edge = 11001 
} 

एक नया वर्ग बनाएँ "InternetExplorerBrowserEmulation" जोड़ें और उसमें नीचे कोड जोड़ें।

public class InternetExplorerBrowserEmulation 
{ 
    private const string InternetExplorerRootKey = @"Software\Microsoft\Internet Explorer"; 
    private const string BrowserEmulationKey = InternetExplorerRootKey + @"\Main\FeatureControl\FEATURE_BROWSER_EMULATION"; 


    public static int GetInternetExplorerMajorVersion() 
    { 
     int result; 

     result = 0; 

     try 
     { 
      RegistryKey key; 

      key = Registry.LocalMachine.OpenSubKey(InternetExplorerRootKey); 

      if (key != null) 
      { 
       object value; 

       value = key.GetValue("svcVersion", null) ?? key.GetValue("Version", null); 

       if (value != null) 
       { 
        string version; 
        int separator; 

        version = value.ToString(); 
        separator = version.IndexOf('.'); 
        if (separator != -1) 
        { 
         int.TryParse(version.Substring(0, separator), out result); 
        } 
       } 
      } 
     } 
     catch (SecurityException) 
     { 
      // The user does not have the permissions required to read from the registry key. 
     } 
     catch (UnauthorizedAccessException) 
     { 
      // The user does not have the necessary registry rights. 
     } 

     return result; 
    } 

    public static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEmulationVersion) 
    { 
     bool result; 

     result = false; 

     try 
     { 
      RegistryKey key; 

      key = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true); 

      if (key != null) 
      { 
       string programName; 

       programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]); 

       if (browserEmulationVersion != BrowserEmulationVersion.Default) 
       { 
        // if it's a valid value, update or create the value 
        key.SetValue(programName, (int)browserEmulationVersion, RegistryValueKind.DWord); 
       } 
       else 
       { 
        // otherwise, remove the existing value 
        key.DeleteValue(programName, false); 
       } 

       result = true; 
      } 
     } 
     catch (SecurityException) 
     { 
      // The user does not have the permissions required to read from the registry key. 
     } 
     catch (UnauthorizedAccessException) 
     { 
      // The user does not have the necessary registry rights. 
     } 

     return result; 
    } 

    public static bool SetBrowserEmulationVersion() 
    { 
     int ieVersion; 
     BrowserEmulationVersion emulationCode; 

     ieVersion = GetInternetExplorerMajorVersion(); 

     if (ieVersion >= 11) 
     { 
      emulationCode = BrowserEmulationVersion.Version11; 
     } 
     else 
     { 
      switch (ieVersion) 
      { 
       case 10: 
        emulationCode = BrowserEmulationVersion.Version10; 
        break; 
       case 9: 
        emulationCode = BrowserEmulationVersion.Version9; 
        break; 
       case 8: 
        emulationCode = BrowserEmulationVersion.Version8; 
        break; 
       default: 
        emulationCode = BrowserEmulationVersion.Version7; 
        break; 
      } 
     } 

     return SetBrowserEmulationVersion(emulationCode); 
    } 

    public static BrowserEmulationVersion GetBrowserEmulationVersion() 
    { 
     BrowserEmulationVersion result; 

     result = BrowserEmulationVersion.Default; 

     try 
     { 
      RegistryKey key; 

      key = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true); 
      if (key != null) 
      { 
       string programName; 
       object value; 

       programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]); 
       value = key.GetValue(programName, null); 

       if (value != null) 
       { 
        result = (BrowserEmulationVersion)Convert.ToInt32(value); 
       } 
      } 
     } 
     catch (SecurityException) 
     { 
      // The user does not have the permissions required to read from the registry key. 
     } 
     catch (UnauthorizedAccessException) 
     { 
      // The user does not have the necessary registry rights. 
     } 

     return result; 
    } 


    public static bool IsBrowserEmulationSet() 
    { 
     return GetBrowserEmulationVersion() != BrowserEmulationVersion.Default; 
    } 
} 

URL सेट करने से पहले, हमें नीचे दिए गए कोड जोड़ना होगा।

if (!InternetExplorerBrowserEmulation.IsBrowserEmulationSet()) 
{ 
    InternetExplorerBrowserEmulation.SetBrowserEmulationVersion(); 
} 

यह WPF में WebBrowser नियंत्रण का उपयोग कर आप ट्यूब वीडियो चलेंगे

संबंधित मुद्दे

 संबंधित मुद्दे