In the first part of this multi part blog, I installed the Sitecore Media Framework package in my MyYoutubeVideos Sitecore application. Also, I created the command button for Import as well as the menu items for Importing individual item type (videos and playlists). These all were done in the Core database.
In this part we will create data templates to represent my youtube data in the application. The great benefit of importing and managing external system (Youtube) data as Sitecore items is that, I will be able to use them in my application and manipulate them too. I can also use DMS to track users video playing behavior and use personalization to show them videos that they might be interested to watch.
All Media Framework templates are located in /sitecore/templates/MediaFramework. I need to create a folder under this for the data templates for my Youtube Vidoe Connector. The folder name is same as my application name, MyYoutubeVideos. First I need a data template for Account. The account template contains the fields for storing credentials. For authenticating with my Youtube account, I will be using Google OAuth2 authentication and that requires two fields ClientId and Client Secret. We will discuss more about Google OAuth authentication in later blog post. Here is my Account data template.
The next data template we need to create is Account Settings template. This template is used to define the behavior of an Account Item. For example, I want to use a video player with certain characteristic as the default video player for my Youtube videos. Account Settings should contain that kind of information.
I will be storing two types Youtube items in Sitecore, Videos and Playlists. For these two types of item, I need two templates. But, there are some common fields in these two types. I will first create base template that contains the common fields. This base template is called ‘MyYoutubeVideos Media Element’ and this template will be derived from the ‘Media Element’ template located in /sitecore/templates/MediaFramework/Common. The ‘Media Element’ template contains the Playback Event list, which the child templates can subscribe. Following are available Playback Events
Following are Media Element template and corresponding child templates for Video and Playlist.
One more data template I need to create, that is the Player template. This template defines the Video Player configuration. At this time I am not sure what fields I need for the Player. I will just add three fields , id, Window Mode and Background Color.
That’s all the data templates I need. One more thing I will add before I end this part of the blog. It is possible to integrate more than one Youtube account with Sitecore. Each of this account can choose to use an account setting. For simplicity, I will just create one default account setting and assume only that account setting will be used by all accounts. I will create this account setting in the location /sitecore/system/Modules/Media Framework/Settings as follows.
The important thing pay attention in the Account Setting item is that, the analytics event rules are available because ‘MyYoutubeVideos Account Settings’ template was derived from ‘Account Settings’ template. I set a simple rule that, when account is in use, Sitecore will trigger ‘Playback Started’ event and ‘Playback Completed’ event for the video. This will allow us to capture the data for DMS.
Well, that’s enough for this part. In the next part, I will talk about branch template and command templates.