Example: Add new item - Advanced configuration

Demonstrates how to further configure the "Add item" tab. Introduces the "list" configuration block where list settings are managed.

Key features

  • Customisable button labels - rename "Playlist" tab, "Add item > New item", "Add item > New item > Preview item", "Add item > New item > Add as last" and "Add item > New item > Add as next" to whatever you like.
  • Customise the "New item" form - modify the field order, labels and default values
  • Override the default "Type" field behaviour - allow custom types
  • Add additional fields to the "New item" form


CSS

HTML

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

Setup code

  jwplayer("example").setup({
    "playlist":[{...}],
    "width":"100%",
    "aspectratio":"16:9",
    "plugins": {
      "listy.js":{
        "list":{
          "label":"My playlist"
        },
        "features":{
          "shuffle":{"enabled":true,"label":"Mix it up!"},
          "search":{"enabled":true},
          "edit":{
            "enabled":true,
            "label":"Edit",
            "buttons":{
              "move_up":{"enabled":true},
              "remove":{"enabled":true,"label":"REMOVE"},
              "move_down":{"enabled":true}
            }
          },
          "add":{
            "enabled":true,
            "label":"Add item",
            "options":{
              "form":{
                "label":"New item",
                "fields":{
                  "mediaid":{"label":"Media ID:","type":"hidden"},
                  "title":{"label":"Title:","value":"Example: JW Player promo"},
                  "description":{"label":"Description:","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"},
                  "type":{
                    "label":"Type:",
                    "type":"radio",
                    "options":{
                      "mp4":{"label":"MP4","checked":true},
                      "rtmp":{"label":"RTMP","checked":false},
                      "youtube":{"label":"YouTube","checked":false}
                    }
                  },
                  "duration":{"label":"Duration:","value":"mm:ss"},
                  "custom_field":{
                    "label":"Custom:",
                    "type":"checkbox",
                    "options":{
                      "custom_1":{"label":"Custom value 1","checked":true},
                      "custom_2":{"label":"Custom value 2","checked":false},
                      "custom_3":{"label":"Custom value 3","checked":true}
                    }
                  }
                },
                "buttons":{
                  "next":{"enabled":true,"label":"Add as next"},
                  "last":{"enabled":true,"label":"Add as last"},
                  "preview":{"enabled":true,"label":"Preview item"},
                  "custom_button":{"enabled":true,"label":"Custom button","action":function(a,b){
                      if(top.console){
                        console.info(jwplayer().plugins.listy.buildCustomItem());
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  });