Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. how to create js object in qml ?
Forum Update on Tuesday, May 27th 2025

how to create js object in qml ?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 772 Views
  • 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.
  • O Offline
    O Offline
    Oussama Kh - IPeculiar
    wrote on 11 May 2017, 19:09 last edited by
    #1

    How to create an object from this js file
    https://cdn.jsdelivr.net/hls.js/latest/hls.min.js

    it should work like this

    import "hls.min.js" as HLSPlayer
    .
    .
    .
    Component.onCompleted: {
       var hls = new HLSPlayer();
       hls.loadSource(streamUrl);
       hls.attachMedia(player);
       hls.on(HLSPlayer.Events.MANIFEST_PARSED,function() { player.play() });
    }
    

    but it says "TypeError: Type error" in this line "var hls = new HLSPlayer();"

    is there any solution ?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Madhu M S
      wrote on 26 May 2017, 10:01 last edited by
      #2

      Hello,

      If you want to create an object of JS file in QML, you need to do like this

      import "hls.min.js" as HLSPlayer
      .
      .
      .
      Component.onCompleted: {

      HLSPlayer.loadSource(streamUrl);
      HLSPlayer.attachMedia(player);

      }

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved