Report any technical problems you discover and discuss solutions.

v3: Bug: Playing youtu.be video fails

  • jayaich
  • Onderwerp Auteur
  • Offline
  • Premium lid
  • Premium lid
Meer
10 jaren 10 maanden geleden #3151 door jayaich
v3: Bug: Playing youtu.be video fails werd gestart door jayaich
Hello,

It seems that when using a 'youtu.be' URL link directly in a page via 'Navigators->Embed Content' (when editing the project), the video does not play. For our user they get an 'Error loading' displayed, but in my test (running preview) I just got a blank page.

The problem seems to be that 'youtu.be' is not converted to a full 'youtube.com/embed' link in all cases. Although the code changed ' youtu.be/ ', it did not cater for 'https'.

Below are a couple of patches which worked for us. I think though that a more correct and fuller patch would be to more generically cater for http/https, and, secondly, to cater for the fact that the DNS domain in a URL can be case-independent.
Code:
diff -u ./modules/xerte/parent_templates/Nottingham/models_html5/embedDiv.html.orig ./modules/xerte/parent_templates/Nottingham/models_html5/embedDiv.html --- ./modules/xerte/parent_templates/Nottingham/models_html5/embedDiv.html.orig 2015-07-29 23:17:23.000000000 +0100 +++ ./modules/xerte/parent_templates/Nottingham/models_html5/embedDiv.html 2015-09-18 16:29:23.250016761 +0100 @@ -63,6 +63,9 @@ $iFrameHolder.html(pageSrc); } else { // use iframe to load web page var iFrameTag = '<iframe id="iFrame" src="' + pageSrc + '" width="100%" height="' + embedDiv.calcHeight() + '"></iframe>'; + if (pageSrc.indexOf("youtu.be/") != -1) { + iFrameTag = iFrameTag.replace("youtu.be/", "www.youtube.com/embed/"); + } $iFrameHolder.html(iFrameTag); $iFrameHolder.addClass("centerAlign"); }
Code:
diff ./modules/xerte/parent_templates/Nottingham/models_html5/youtube.html.orig ./modules/xerte/parent_templates/Nottingham/models_html5/youtube.html 66c66,67 < else if (youtubeCode.substring(0, 16) == "http://youtu.be/") { --- > else if (youtubeCode.indexOf("youtu.be/") != -1) { > var idx = youtubeCode.indexOf("youtu.be/"); 76c77 < iframe.code = youtubeCode.substring(16, finish); --- > iframe.code = youtubeCode.substring(idx + 9, finish);


John.

Graag Inloggen of een account aanmaken deelnemen aan het gesprek.

Moderators: ronmjultenJohnSmith
Tijd voor maken pagina: 0.133 seconden
Copyright © 2026 The Xerte Project.
Xerte logo Apereo logo OSI Logo