No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Shaka player

    Help
    1
    2
    211
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      gs86 last edited by

      Hello all

      Has anyone tried integrating shaka-player in quasar…

      If yes, can you please share a sample version of code?

      Thanks

      1 Reply Last reply Reply Quote 0
      • G
        gs86 last edited by gs86

        Nevermind, i have figured out and developed my own component in case someone needs below is the code…

        Install: npm i shaka-player

        
        <template>
          <video
            ref="shakaVideo"
            :width="width"
            :height="height"
            poster="//shaka-player-demo.appspot.com/assets/poster.jpg"
            controls
          ></video>
        </template>
        
        <script>
        import * as shaka from "shaka-player";
        
        export default {
          name: "ShakaPlayer",
          props: {
            manifestUri: {
              type: String
            },
            width: {
              type: String,
              default: "200px"
            },
            height: {
              type: String,
              default: "100%"
            }
          },
          data() {
            return {};
          },
        
          mounted() {
            // Install built-in polyfills to patch browser incompatibilities.
            shaka.polyfill.installAll();
        
            // Check to see if the browser supports the basic APIs Shaka needs.
            if (shaka.Player.isBrowserSupported()) {
              // Everything looks good!
              // Create a Player instance.
              var video = this.$refs.shakaVideo;
              var player = new shaka.Player(video);
        
              // Attach player to the window to make it easy to access in the JS console.
              window.player = player;
        
              // Listen for error events.
              player.addEventListener("error", onErrorEvent);
        
              // Try to load a manifest.
              // This is an asynchronous process.
              player
                .load(this.manifestUri)
                .then(function() {
                  // This runs if the asynchronous load is successful.
                  console.log("The video has now been loaded!");
                })
                .catch(onError); // onError is executed if the asynchronous load fails.
            } else {
              // This browser does not have the minimum set of APIs we need.
              alert("Browser not supported!");
            }
        
            function onErrorEvent(event) {
              // Extract the shaka.util.Error object from the event.
              onError(event.detail);
            }
        
            function onError(error) {
              // Log the error.
              console.log("Error code: ", error.code, ", object: ", error);
            }
          }
        };
        </script>
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post