Creating a playlist with Views
SWF Tools implements a style plug-in for Views. Using the plug-in fields retrieved in a Views query can be passed directly in to SWF Tools and formatted in to a playlist (or a series of players). The plug-in presents all the available SWF Tools formatters so different views can be styled with different players, or different player configurations.
By using Views it is possible to build pages and blocks that present playlists of media that are assembled from multiple nodes. For example, the five most recently created items, or the items from a particular user.
The plug-in also supports thumbnails, so if these are also available in the query then they can be added to the View.
There are three key things to note when building a View:
- SWF Object 2 embedding doesn't work in the live preview, so if you're testing your view use direct embedding. But you can go back to SWF Object once done.
- It won't work if you choose Group multiple values as the playlist is built wrongly.
- Set the formatter on the fields to "plain" as the plug-in needs modules like FileField to return the path to the file. Do NOT use an SWF Tools formatter as this will return formatted content.
The steps needed to create a basic View are as follows:
- Create a new view based on Node (since we are retrieving things based on the node table).
- Add the field that has the files to rendered. Make sure to pick the right one. E.g. for a filefield there are three entries - in this case it is the first one that is needed (not delta or data).
- Configure the field by making sure "Group multiple values" is not checked, and set the field format to a style that will return an unformatted path. In the case of a fieldfield that would be "Path to file". DO NOT select SWF Tools formatters here.
- Add additional fields as required. If the playlist is going to include thumbnail images then configure the field in the same was as the main playlist content (uncheck group multiple vales, and format to return a path to the file). It may also be necessary to add the CCK delta fields - see below for details.
- Click update, and a list of filepaths will be displayed. It will may include some blank files, so add additional filters to limit the query. For example, only retrieve nodes of a particular type where it is known that the fields will contain data, or add relationships to other tables to limit the query that way.
- When the list of files looks right change the View style to SWF Tools and click Update. The plug-in configuration options will now appear.
- Change the Playlist handler to the formatter that should be used for this View. If profiles are enabled then all the available SWF Tools profiles will be shown as well as the basic SWF Tools formatters. (These are the same formatters as are available in CCK itself).
- Map the fields from the query to the appropriate part of the playlist. As a minimum a field must be mapped to the File: element as this determines what is actually going to play. The other mappings are optional, and may not be supported in all players. Refer to the documentation for the player that is going to be used to check what it supports.
- Click update and the changes will be applied and, all being well, the player will appear with the playlist. If the configuration is not quite right click the gear icon next to the plug-in name to adjust the setting.
- Once the defaults are in place create pages or blocks as required to allow the View to be seen.
If the View is using CCK and includes both files AND thumbnails then multiple entries will be retrieved (each file paired with each thumbnail). To correct this the delta fields for each needs to be added to the query. The plug-in can then adapt the query to fetch only the proper file and thumbnail pairs.
More complex filtering can be added by creating relationships to other tables. For example, if a content type was using filefield to allow upload of audio, video and image content then a playlist that excludes the image content can be created. This requires a filter that is based on the mime-type, but that is not available unless a relationship the file is created first. So, add a relationship to the fid of the file, and then add the filter. With the relationship in place the mime-type (and other aspects of the file) are available as fields to filter on. To exclude images the filter would be based on the file mime-type not starting with image.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion