Play youtube video's in Una.

Before it was possible in Dolphin to let people look ti Youtube video's inside my website.

Now i can't find it... How to let people look the video in my website?

  • 331
  • More
Replies (12)
    • Use embedded link in video module is the quickest and easiest.

      • I will try, just paste the link is not working.

        It shows the link.

        • New Video -> Video Type select Embed

          Box changes from uploads to a input box (Video Embed Link)

          Paste the share video link from YouTube.

          • I don't see video :/

            image_transcoder.php?o=sys_images_editor&h=2082&dpx=1&t=1717982027

            • Install it my friend, use studio app store. Search -> Video

              image_transcoder.php?o=sys_images_editor&h=2083&dpx=1&t=1717982356

              • Seems it is a pro app.

                • Yep, the video module is a Pro app (https://unacms.com/pro). However Youtube videos can seamlessly be played using embed providers packed with UNA: Embed.ly, Iframely and oEmbed.

                  Just paste your Youtube link into any text area in UNA (Timeline, comments etc) and it will be converted to an embedded video.

                  You need to enable that feature here:

                  UNA Studio > Settings > General > Embeds provider

                  Both Embed.ly and Iframely offer free and paid plans. oEmbed is an open source script. It's free but a bit limited.

                  • In case it still doesn't work for you or you prefer some other setting, here's JavaScript you may add where you add your body injections. This is pretty robust and should work without issues.

                    <script>
                    // This is for YouTube video auto embed
                    (function() {
                        const youtubeRegex = /^(https?:\/\/(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]{11}))/gm;
                    
                    
                        function createEmbedHTML(videoId) {
                            return `
                                <iframe class="ql-video" src="https://www.youtube.com/embed/${videoId}" frameborder="0" allowfullscreen loading="lazy"></iframe>
                            `;
                        }
                    
                    
                        function isIgnoredElement(node) {
                            return node.tagName === 'TEXTAREA' || node.tagName === 'INPUT' || hasAncestorWithClass(node, 'ql-editor');
                        }
                    
                    
                        function hasAncestorWithClass(node, className) {
                            while (node) {
                                if (node.classList && node.classList.contains(className)) {
                                    return true;
                                }
                                node = node.parentNode;
                            }
                            return false;
                        }
                    
                    
                        function processTextNode(node) {
                            if (isIgnoredElement(node)) return;
                    
                    
                            const text = node.textContent;
                            const fragment = document.createDocumentFragment();
                            let lastIndex = 0;
                    
                    
                            text.replace(youtubeRegex, (match, url, videoId, offset) => {
                                // Append text before the match
                                fragment.appendChild(document.createTextNode(text.slice(lastIndex, offset)));
                                // Append the iframe
                                const iframe = document.createElement('div');
                                iframe.innerHTML = createEmbedHTML(videoId);
                                fragment.appendChild(iframe.firstElementChild);
                                lastIndex = offset + match.length;
                            });
                    
                    
                            // Append remaining text
                            if (lastIndex < text.length) {
                                fragment.appendChild(document.createTextNode(text.slice(lastIndex)));
                            }
                    
                    
                            if (node.parentNode) {
                                node.parentNode.replaceChild(fragment, node);
                            }
                        }
                    
                    
                        function processElementNode(node) {
                            if (isIgnoredElement(node)) return;
                    
                    
                            if (node.tagName === 'P') {
                                // Process only `p` elements
                                Array.from(node.childNodes).forEach(child => processNode(child));
                            }
                        }
                    
                    
                        function processNode(node) {
                            if (node.processed || isIgnoredElement(node)) return;
                            node.processed = true;
                    
                    
                            try {
                                if (node.nodeType === Node.TEXT_NODE) {
                                    processTextNode(node);
                                } else if (node.nodeType === Node.ELEMENT_NODE) {
                                    processElementNode(node);
                                }
                            } catch (error) {
                                // No need for console error logging
                            }
                        }
                    
                    
                        function throttle(fn, limit) {
                            let lastCall = 0;
                            return function(...args) {
                                const now = Date.now();
                                if (now - lastCall >= limit) {
                                    lastCall = now;
                                    fn(...args);
                                }
                            };
                        }
                    
                    
                        const processContent = throttle(function() {
                            document.querySelectorAll('.bx-db-content p').forEach(p => {
                                Array.from(p.childNodes).forEach(child => processNode(child));
                            });
                        }, 100);
                    
                    
                        const observer = new MutationObserver(mutations => {
                            observer.disconnect(); // Temporarily disconnect observer to prevent re-triggering
                            mutations.forEach(mutation => {
                                mutation.addedNodes.forEach(node => {
                                    if (!isIgnoredElement(node) && node.tagName === 'P') {
                                        processNode(node);
                                    }
                                });
                            });
                            document.querySelectorAll('.bx-db-content').forEach(container => {
                                observer.observe(container, { childList: true, subtree: true });
                            });
                        });
                    
                    
                        document.querySelectorAll('.bx-db-content').forEach(container => {
                            observer.observe(container, { childList: true, subtree: true });
                        });
                    
                    
                        processContent();
                    })();
                    </script>
                    
                    • Also, this might be preferred because when I change from "System" to "oEmbed" my pretty link previews go away. I like those a lot. So, it seems like I need to stick with my embed setting being set to "System." Which means in order to get pretty link previews AND YouTube embeds, you need some workaround like the above JavaScript.

                      • Can someone help me with this?

                        Do i have to instell a new module?

                        • 100$ a year? lol

                          • Before it was free, why i do have to pay now. So much things to make me feel robbed here. I have 4 lisences. Paid more than 5000$ for Dolphin plugins and now i have to pay more and more. This is not right.

                            Login or Join to comment.