Example: Custom playlist HTML

By default, Listy produces playlist HTML similiar to that produced by JW Player when rendering in HTML5 mode (with the addition of the "duration" label).

By including settings in the "list" configuration block this can be completely overridden.

The playlist HTML is made up using 3 configurable settings: "start_tpl", "item_tpl" and "end_tpl".

  • start_tpl - this is the template used to produce the starting block of HTML for the playlist. The default value is as follows: <div class="listy-playlistcontainer">
      <div class="listy-playlist">
        <div class="listy-listcontainer">
          <ul class="listy-pl">
  • item_tpl - this is the template used to produce an individual playlist item. It is repeated for each item in the playlist. The default value is as follows:         <li class="listy-item" data-mediaid="{{item.mediaid}}" tabindex="0">
              <div class="listy-playlistdivider"></div>
              <div class="listy-playlistimg listy-fill" {{(item.image&&item.image!=""?'style="background-image:url('+item.image+');"':'')}}></div>
              <div class="listy-textwrapper">
                <span class="listy-title">{{item.title}}
                  <span class="listy-duration">{{(item.duration?item.duration:'')}}</span>
                {{(item.description?'<span class="listy-description">'+item.description+'</span>':'')}}
  • end_tpl - this is the template used to produce the ending block of HTML for the playlist. The default value is as follows:       </ul>

There are a few important points to note when using these settings:

  • When used as part of the configuration block, they should resolve as plain JavaScript strings. As such, any delimiter quotes used within the string will need to be escaped. For example, 'item_tpl':'It's a single quote' would be written as 'item_tpl':'It\'s a single quote'
  • You can include any of the parameters associated with the playlist item by using the following notation: {{item.parameter}}
  • You can also include simple JavaScript if..then.. logic in order to conditionally include parameters as such: {{(item.parameter?item.parameter:'')}}

A final setting which needs to be included in order to enable interactions with the playlist items is the "current_selector" setting.

The default setting for this is "current_selector":"data-mediaid" and the value relates directly to the data-mediaid="{{item.mediaid}}" attribute definition included on the parent element in the "item_tpl" string.

Whilst this can be set to anything, the corresponding attribute needs to be included as part of the parent element within the "item_tpl" string, and the value of that attribute must be set to {{item.mediaid}}


The following example demonstrates how these settings can be used to produce an alternative playlist design



  <div id="player_wrapper">
    <div id="example"></div>
    <div id="detached_options"></div>
    <div id="detached_playlist"></div>

Setup code

    "plugins": {
          "label":"My playlist",
          "current_selector": "data-mediaid",
          "start_tpl":'<div class="custom-playlistcontainer">'+
            '<div class="custom-playlist">'+
            '<div class="custom-listcontainer">'+
            '<table class="custom-list"><tr>',
          "item_tpl": '<td><div class="custom-item" data-mediaid="{{item.mediaid}}" tabindex="0">'+
            '<div class="custom-playlistdivider"></div>'+
            '<div class="custom-playlistimg custom-fill" {{(item.image&&item.image!=""?\'style="background-image:url(\'+item.image+\');"\':\'\')}}></div>'+
            '<div class="custom-textwrapper">'+
            '<span class="custom-title">{{item.title}}</span>'+
            '<br/><span class="custom-duration">{{(item.duration?item.duration:\'\')}}</span>'+
            '<br/><span class="custom-category">{{(item.category?item.category.join(\', \'):\'\')}}</span>'+
          "end_tpl": '</tr></table>'+
          "edit":{"enabled":true, "buttons":{"move_up":{"label":"←"},"remove":{"label":"remove"},"move_down":{"label":"→"}}},
          "add":{ "enabled":true,
                  "mediaid":{"label":"Media ID:","type":"hidden"},
                  "title":{"label":"Title:","value":"Example: JW Player promo"},
                  "description":{"label":"Description:","type":"textarea","value":"Example: Your video solution starts with JW Player"},
                  "image":{"label":"Image URL:","value":"http://content.jwplatform.com/thumbs/HkauGhRi-640.jpg"},
                  "file":{"label":"File URL:","value":"http://content.jwplatform.com/videos/HkauGhRi-640.mp4"},
                      "hip_hop":{"label":"Hip Hop"},
                      "no_audio":{"label":"No Audio"},
                      "visual effects":{"label":"Visual effects"}