Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Embed Youtube Autoplay



  • Hi Everyone,

    I was trying to embed a youtube video with autoplay, the video gets loaded, but does not autoplay.

    Could someone help me out?

    Here is my code:-

    main.qml

     WebView {
                id: webOutput
                anchors.fill: parent
    
                Component.onCompleted: {
                    var request = new XMLHttpRequest()
                    request.open('GET',  "qrc:/player1.html")
    
                    request.onreadystatechange = function(event) {
                        if (request.readyState === XMLHttpRequest.DONE) {
                            var response = request.responseText
                            console.log("##")
                            console.log(response)
                            webOutput.loadHtml(response)
                        }
                    }
                    request.send()
                }
            }
    

    player1.html

    <iframe width="560" height="315"
    src="https://www.youtube.com/embed/7ZW8hthGL0U?autoplay=1">
    </iframe>

  • Lifetime Qt Champion

    Hi,

    What if you load that page direct in your view ?



  • Hi @SGaist , if load it directly the video plays on mute.


Log in to reply