Creating a Filtered Dynamic Playlist for the Dash Media Player

The Dash Media Player has the ability to filter your videos into categories using the Views Arguments in combination with Drupal Taxonomy. Also with a small amount of coding, the player provides tabs for users to easily navigate to the video category that they wish to view.

Step 1: Setting up the Taxonomy

  • Go to Administer >> Taxonomy and click on Add vocabulary.
  • Give the vocabulary a name and make sure you check the Video content type.
  • Now click Add term and enter a Term name. Here is where you will define your categories of video; you could use terms such as HD or Standard. You don’t need to add a description, but you can if you like, then click save.
  • Add a few terms just to get things set up and for testing purposes, you can always add more later.

Step 2: Modifying the View

  • Once you have a list of terms, go to Administer >> Views and select Edit for the Video view that you created earlier.
  • Click the + sign next the where the Arguments are displayed to add a new Argument to the View.
  • Add the Argument Taxonomy: Term.
  • Click Add and you will be given a lot of extra options for this argument. These can be modified, but the default settings work well.
  • Click Update, then don’t forget to save your view.

Step 3: Create content

Go to Create Content and select Video to make a couple of video pages to use to test with.

If you already have video content on your site, go to Administer >> Content and click edit. You should now see a drop down box that will have a list of the Taxonomy terms that you created. Select one and click save.

Step 4: Adding the code

  • Once you have some content with Taxonomy terms assigned, go to the area where you have the Dash Media Player and playlist displayed.
  • You should already have this code to display the playlist and Dash Media Player:
    <?php
    $params
    [‘playlist’] = ‘videos’; print dashplayer_get_player($params);
    ?>

    Add these parameters to the code, where # is the tab number in order of how you would like the tabs to be displayed:

    $params[‘linkarg#’] = “term”;

    In this line, “term” is the taxonomy term that you would like to display under this tab.

    $params[‘linkindex#’] = “0”;

    This is the number of the argument used by the view. 0 is the first arument listed in the view. However, if there are multiple arguments, list the Taxonomy: Term argument here.

    For example:

    In this picture “User: Uid” would be Argument 0 and “Taxonomy: Term” would be Argument 1. In this case you would use:

    $params[‘linkindex#’] = “1”;

    $params[‘linktext#’] = “Text”;

    Enter the text you want to be displayed on the tab when it shows to the user.

    If that was a bit confusing so here is an example of what the code should look like (in this example the two categories of video are “HD” and “Standard”):

    <?php
    $params
    [‘playlist’] = ‘videos’; //HD $params[‘linkarg1’] = ‘”HD”; $params[‘linkindex1’] = “0”; $params[‘linktext1’] = “HD”; print dashplayer_get_player($params); //Standard $params[‘linkarg2’] = ‘”Standard”; $params[‘linkindex2’] = “0”; $params[‘linktext2’] = “Standard”; print dashplayer_get_player($params);
    ?>

    Note: Adding php comments such as: //HD works well to separate each section of code and also help if you have multiple people working on the same site to be more clear which section the following code is affecting.

    This should now display tabs above your playlist so the user can toggle back and forth to which category of videos they want to view.

Step 5: Removing the “All” tab

You will notice that the first tab being displayed is an “all” tab which displays all of the videos that have been uploaded. To remove this tab set your first category to be the default by replacing the code for your first tab with this:

$params[‘linkalltext’] = “category one text”; $params[‘arg1’] = “category one text”;

Now you should see all of the tabs that were created and be able to toggle back and forth to the different categories.

Sponsors