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

    How to use slots on qmediaplayer?

    [v1] App Extensions
    3
    5
    612
    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.
    • S
      steveleeroberts last edited by

      I’ve searched for Vue slots and everything I’ve tried doesn’t seem to work. I’m using it to play live audio so I want to replace the duration slot with the word “Live”?

      I have tried different combinations like:

      <q-media-player type="audio">
      <span slot="duration-time">Live</span>
      </q-media-player>
      
      1 Reply Last reply Reply Quote 0
      • s.molinari
        s.molinari last edited by

        https://github.com/quasarframework/app-extension-qmediaplayer/blob/397d91d133b02e3b911bed10433acc7666224368/src/component/QMediaPlayer.js#L1305

        Try slot="durationTime".

        Scott

        1 Reply Last reply Reply Quote 0
        • S
          steveleeroberts last edited by

          Thanks, I’ve tried that. I tried the other slots and they didn’t work either. I think I have found the issue. The function h() inside of __renderDurationTime(h)

          __renderDurationTime(h) {
                  return h('span', {
                    staticClass: 'q-media__controls--video-time-text' + ' text-' + this.color
                  }, this.state.durationTime, slot(this, 'durationTime'))
                  // TODO: syntax on above line??
           },
          

          refers to the function createElement()

          function createElement (
            context,
            tag,
            data,
            children,
            normalizationType,
            alwaysNormalize
          ) {
            if (Array.isArray(data) || isPrimitive(data)) {
              normalizationType = children;
              children = data;
              data = undefined;
            }
            if (isTrue(alwaysNormalize)) {
              normalizationType = ALWAYS_NORMALIZE;
            }
            return _createElement(context, tag, data, children, normalizationType)
          }
          

          As you can see in createElement() if data is an array then children is overwritten. As the slot is in the var children it is overwritten so ignored. I have tested with the following and it works as it should:

                __renderDurationTime(h) {
                  let a = 'span'
                  let b = {
                    staticClass: 'q-media__controls--video-time-text' + ' text-' + this.color
                  }
                  let c = this.state.durationTime
                  let d = slot(this, 'durationTime')
                  c = d ? d : c
          
                  return h(a, b, c)
                  // TODO: syntax on above line??
                },
          

          Then

                    <q-media-player
                      type="audio"
                    >
                      <template>
                        <div slot="durationTime"><b>Live</b></div>
                      </template>
                    </q-media-player>
          
          1 Reply Last reply Reply Quote 0
          • Hawkeye64
            Hawkeye64 last edited by

            I’ll be fixing the slots in QMediaPlayer. It seems some are working and some not. Stay tuned for an announcement today or tomorrow. Thanks.

            1 Reply Last reply Reply Quote 1
            • Hawkeye64
              Hawkeye64 last edited by

              v1.0.5 has been released
              https://github.com/quasarframework/app-extension-qmediaplayer/releases/tag/v1.0.5

              1 Reply Last reply Reply Quote 0
              • First post
                Last post