Forums

OverviewFelgo 2 Support (Qt 5) › Bug : YouTubeWebPlayer – runPlayerScript TypeError: Type error

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #22235

    Barazi Ala

    Hi,

    I am getting error when usingĀ  runPlayerScript(“setVolume”, 20). The code below and the screen shoot on this link.

    import Felgo 3.0
    import QtQuick 2.0
    
    
    App {
      NavigationStack {
        Page {
          title: "YouTube Player"
    
    
          YouTubeWebPlayer {
            id: player
            videoId: "KQgqTYCfJjM"
            autoplay: true
    
    
            // hide player iframe and display message on error
            playerErrorScript: "
              player.getIframe().style.display='none';
              document.getElementById('videoIdError').style.display='block';
            "
    
    
            // show player iframe and hide message when new video has loaded
            playerStateChangeScript: "if(event.data == YT.PlayerState.PLAYING) {
              document.getElementById('videoIdError').style.display='none';
              player.getIframe().style.display='block';
            }"
    
    
            // add custom HTML for showing the error
            customHTML: '<style>
              .videoError {
                background-color: black;
                color: white;
                width: 100%;
                height: 100%;
                position: absolute;
                display: none;
              }
            </style >
            <div id="videoIdError" class="videoError">
              This video is not available.
            </div>'
    
    
          }
    
    
    
    
          Rectangle {
            anchors.top: player.bottom
            width: parent.width
            height: controls.height
            color: Theme.backgroundColor
    
    
            Row {
              id: controls
              anchors.horizontalCenter: parent.horizontalCenter
    
    
     anchors.top: player.bottom
              AppButton {
                text: "Change Video"
    
    
    //            anchors.horizontalCenter: parent.horizontalCenter
                onClicked: {
                  if(player.videoId == "KQgqTYCfJjM")
                    player.videoId = "*invalid!"
                  else
                    player.videoId = "KQgqTYCfJjM"
                }
                // controls
    
    
              }
              AppButton {
                text: "Play"
                onClicked: {
                    player.play()
    
    
    
    
                }
    
    
              }
    
    
              AppButton {
                text: "Pause"
                onClicked: player.pause()
              }
    
    
              AppButton {
                text: "Run Script"
                onClicked: {
                   player.runPlayerScript("setVolume", 20)
    //                player.seekTo(40)
                  }
              }
              AppButton {
                text: "Seek"
                onClicked: {
    //                player.seekTo(40)
                  }
              }
            }
          }
        }
      }
    }
    
    

     

     

    #22253

    Barazi Ala

    Any idea why this is happening ?

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support