YouTube Integration with CQ5

31 / Jul / 2014 by Vivek Dhiman 1 comments

Managing multimedia content to any large scale website is much complicated if the content is dynamic and needs to be changed at regular intervals. Integration of YouTube with CQ5 is one of the use case which can help authors to manage the channel specific videos for particular page related with particular channel.

Below is the snapshot how this solution will work:


1)      Create the configuration page for specific channel under the cloud service page of  Youtube .


2)      Create a dialog which will accept Channel ID, API Key & Target Path (Store location in DAM) & link this to the YouTube cloud service. This will validate the Google Key/ Channel Id. On success it will configure the cloud service with that channel.


3)      Our dialog is configured with some hidden widgets which cause the creation of polling node just below the jcr:content of cloud service page. This binds our cloud service with one channel correspond to polling node which will invoke the generic importer.


Listener will set values of polling node when we click OK.


4)       Now the polling node will poll the youtube service

[html]”+ key+ “
&channelId=”+ channelId + “&pageToken=” + pageToken


via importers (A custom servlet

5)     Our importer is responsible for storing videos in DAM at target path which we have specified in step 2

6)      After execution of importer, we can check the nodes under target path which are assets that refer to YouTube videos for specific channel.


7) Now we need to customize the content finder to create a new tab which will show the YouTube videos stored under DAM.

How to create new contentfiner tab in CQ5.

8)  Create a servlet AssetViewHandler which render the videos from DAM to content finder tab on the request basis for particular page. We can use OOTB servlet available in package with some changes as we are fetching assets on page basis.

9) Now click on the page properties and select the cloud service for specific channel & save.


10) Open the en.html page, you can find the new tab in content finder with YouTube icon. And here all the videos are populated from DAM. Add the component YouTube to parsys which use the iframe, it uses the YouTube video’s id.


11) Just drag and drop the video on the Youtube component.


GitHub link :

Hope this helps!!!
Vivek Dhiman


comments (1 “YouTube Integration with CQ5”)

  1. housing housingnew

    Vivek – I need to pick the top posted videos from a page and do not have to bring them to DAM. If show the snippet on a page, user clicks and go to youtube. What would be the best way?


Leave a Reply

Your email address will not be published. Required fields are marked *