locked
http and https can not mixed in Windows 8.1?

    Question

  • Hi,

    Please be patient of my question, because it may be a little long.

      Couple months ago, I embed YouTube video in my app (Windows 8 version) using <iframe> and YouTube iframe/js API . And my local code communicates with the content in iframe through 'postMessage'.  It runs well.  

      Now my app need to update to Windows 8.1 version. I replace <iframe> with x-ms-webview. And I add YouTube API domain in my app's Content URIs rules so that my local code can communicate with the content in webview through 'invokeScriptAsync'/'notify' APIs. The scheme to import YouTube API must change to 'https'. The problem coming, the video player can be loaded, but if click play button, the video can not buffering and play.  

      YouTube has mentioned that if using https to import YouTube API, the video stream still transmitted with http (HTTPS Support for YouTube Embeds). I think the problem is that http and https were mixed in webview page.

    And then, I do some tests:

    1, I try to import YouTube API by https in Windows 8, like this:

    var tag = document.createElement('script');
    tag.src = "https://www.youtube.com/iframe_api";
    var firstScriptTag = document.getElementsByTagName('script')[0];
    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

    the video can be loaded, buffering and play normally. I notice an error in js console:

     

    The domain in the error is the YouTube video source address. And I think the error is occurred when mixed http and https content in iframe. But the video stream is not blocked(in Windows 8.1, the stream is blocked, so the video can not buffering).

    2, I change the scheme to http in Windows 8.1 app, The video can be loaded, buffering and play normally:

    But I cannot call any YouTube API from local code because 'invokeScriptAsync'/'notify' APIs does not work. 

    So I meet a contradict problem in my Windows 8.1 version app. If I embed YouTube video with scheme http, the video can work but I can not call any YouTube API from local code. If I use https, I can call YouTube API but the video can not buffering and play.

    Tuesday, January 21, 2014 3:54 AM

All replies

  • I see your issue, but are you able to continue with iframe API?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, January 21, 2014 1:11 PM
    Moderator
  • Hi, 

    I tried iframe on Windows 8.1, it didn't work, just same as webview.

    Wednesday, January 22, 2014 1:43 AM
  • Can you post an app for me to test?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, January 23, 2014 7:23 PM
    Moderator
  • Of course.

    And when I debug my code, I find an error may be useful:

    Some code of YouTube that throw the error:

    I think the error is occurred  when YouTube try to send a http 'GET' request under https content using XMLHttpRequest. Windows 8.1 does not allow this.

    The demo code I debugged can found in my skydrive: https://skydrive.live.com/redir?resid=1E8435D8F693840E!904&authkey=!AJU-I0cPJB1JnQk&ithint=file%2c.zip

    Friday, January 24, 2014 2:01 AM
  • Hi Matt,

    Is there any progress about the problem? Or any error in my demo code? Please tell me.

    Wednesday, February 12, 2014 12:27 AM
  • I can't find any way to make youtube content play right now. I'll be reaching out to the right people about this scenario.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, February 12, 2014 3:34 PM
    Moderator
  • <bump so this stays on my radar>

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, February 20, 2014 5:14 PM
    Moderator
  • I've got the same problem, only way of playing youtube videos is trough x-ms-webview using http protocol (https doesn't work). It wouldn't be an issues for me, but playing youtube in webview breaks playing animated gifs :( Iframe works fine, but needs use https, so I really can't provide good experience for my users right now :( Looking forward to see some fix for this
    Thursday, February 20, 2014 6:42 PM