Jump to content


These Forums Are Now Read-Only


For TubePress support, please post a question here or open a support ticket and we will be glad to assist.


Photo

Duration Of Video


Best Answer envidea, 04 June 2015 - 03:19 AM

A lot of thanks, you solved my problem perfectly  :)

Go to the full post


  • This topic is locked This topic is locked
11 replies to this topic

#1 envidea

envidea

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 21 May 2015 - 05:46 AM

How can I obtain in twig the duration of video?

 

I have this template for main player and I want to show the duration of the video

 

This is my code:

 

<div class="tubepress-normal-player js-tubepress-player-normal" style="width: {% if responsiveEmbeds %}100%{% else %}{{ embeddedWidthPx }}px{% endif %}">
 
    {% block normalPlayerTitle %}
 
        {#
         # <div class="tubepress-big-title">
         #
         # A <div> to hold the media items's title.
         #}
        <span class="tubepress-big-title">
            {{- mediaItem.title -}}
        </span>
 
    {% endblock %}
 
{% block normalPlayerDuration %}
 
<span class="tubepress_iconos">
<span><i class="icon-hd"></i></span>
  <span><i class="icon-duration"></i>{{- mediaItem.duration-}}</span>
</span>
 
{% endblock %}
 
    {% block normalPlayerEmbeddedSource %}
        {{ embeddedSource|raw }}
    {% endblock %}
 
</div>


#2 eric

eric

    Lead Developer

  • TubePress Staff
  • 2787 posts

Posted 22 May 2015 - 01:43 AM

Hi,

 

This snippet:

{{ mediaItem.duration }}

should output the duration of the video. I see you have that already in the template. Is it not showing up as expected? Are you using TubePress for WordPress or standalone PHP?

 

Let us know and we'll get things fixed up for you. Thanks!



#3 envidea

envidea

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 22 May 2015 - 04:22 AM

I use TB for Wordpress

 

Does the part of "{% block normalPlayerDuration %}" good? I invented it :P

 

Thank you!



#4 envidea

envidea

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 22 May 2015 - 04:30 AM

Another question, how can I obtain the id of the video that is active in the player?

 

Where I can see all the vars that I can use in twig?

 

Thx



#5 eric

eric

    Lead Developer

  • TubePress Staff
  • 2787 posts

Posted 27 May 2015 - 01:58 AM

Apologies for the delay in response - we were out of the office for the Memorial Day holiday here in the US.

 

Before I can help you further, I'll need to know the logical name of the template you're trying to edit. Once I know that I'll be able to provide you with lots more info.

 

Thanks!



#6 envidea

envidea

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 01 June 2015 - 04:01 AM

Hi eric, no problem for the delay

 

the logical name is: /wp-content/tubepress-content/themes/starter/templates/gallery/players/normal/ajax.html.twig

 

I need to know the duration of the video in player and its ID

 

Thank you



#7 eric

eric

    Lead Developer

  • TubePress Staff
  • 2787 posts

Posted 01 June 2015 - 04:04 PM

Thanks. The following template should do the job. I simply formatted your HTML a little and added a space:

<div class="tubepress-normal-player js-tubepress-player-normal" style="width: {% if responsiveEmbeds %}100%{% else %}{{ embeddedWidthPx }}px{% endif %}">

    {% block normalPlayerTitle %}

        {#
         # <div class="tubepress-big-title">
         #
         # A <div> to hold the media items's title.
         #}
        <span class="tubepress-big-title">
            {{- mediaItem.title -}}
        </span>

    {% endblock %}

    {% block normalPlayerDuration %}

        <span class="tubepress_iconos">
            <span>
                <i class="icon-hd"></i>
            </span>
            <span>
                <i class="icon-duration"></i>
                {{- mediaItem.duration -}}
            </span>
        </span>

    {% endblock %}

    {% block normalPlayerEmbeddedSource %}
        {{ embeddedSource|raw }}
    {% endblock %}

</div>

You'll want to make sure that you're editing the template in your own, custom theme. Based on the path from your last post (/wp-content/tubepress-content/themes/starter/templates/gallery/players/normal/ajax.html.twig), I'm concerned that you're making changes to the "starter" theme. Please ensure that you have carefully followed the quick theme tutorial to make sure you're editing the right files.

 

Lastly, you'll need to clear your TubePress system cache anytime you make an edit to a template file.

 

Give that a try?



#8 eric

eric

    Lead Developer

  • TubePress Staff
  • 2787 posts

Posted 01 June 2015 - 04:05 PM

Also, to get the video's ID you can use:

{{ mediaItem.id }}


#9 envidea

envidea

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 02 June 2015 - 03:08 AM

Thank a lot, Eric!

 

The id works perfectly! but I can't show the duration :/

 

Can I send you a PM with my web's data so you can look inside?



#10 eric

eric

    Lead Developer

  • TubePress Staff
  • 2787 posts

Posted 02 June 2015 - 03:17 PM

Glad to hear we're making progress! Better than a PM, could you send credentials to me via a new ticket? It's just as secure as sending a PM and is easier for us to stay on top of things. Of course, a PM is fine too if you'd prefer for any reason.

 

Thanks



#11 envidea

envidea

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 03 June 2015 - 05:01 AM

Perfect, I sent you a ticket

 

Thx



#12 envidea

envidea

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 04 June 2015 - 03:19 AM   Best Answer

A lot of thanks, you solved my problem perfectly  :)