A Youtube Connector for Sitecore Media Framework Part 2 – Data Templates

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.

Sitecore Media Framework

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.

Sitecore Media Framework

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

Sitecore Media Framework

Following are Media Element template and corresponding child templates for Video and Playlist.

Sitecore Media Framework

Sitecore Media Framework

Sitecore Media Framework

 

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.

Sitecore Media Framework

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.

https://himadritechblog.files.wordpress.com/2014/06/youtube15.jpg

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.

Advertisements

About Himadri Chakrabarti

I am a software developer architect and a Sitecore MVP. My professional interest is everything and anything related to Software Architecture, .NET, Sitecore, Node.js, NoSQL etc. Outside of my profession, I am a hobbyist photographer. Link to my photography site http://himadriphotography.com/
This entry was posted in Media Framework, Sitecore and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s