How Kaltura video integration is done in confluence?

Shankar Murthy Pokala September 10, 2017

As the user gives the kaltura video url , i have written the code to auto convert the url to Widgetconnector macro. Can anyone help me on framing the iframe tag which is to be displayed in UI with thumbnail.

3 answers

1 accepted

0 votes
Answer accepted
Shankar Murthy Pokala November 6, 2017

this was my java code and am rendering the velocity params to the vm.

public class KalturaWidgetRenderer implements WidgetRenderer {

private final VelocityRenderService renderer;

/**
* Constructor. Used primarily to auto-wire dependencies.
*
* @param renderer
* Velocity rendering service used to render our custom template.
*/
public KalturaWidgetRenderer(
final VelocityRenderService renderer) {
this.renderer = renderer;
}

/**
* Returns the HTML to embed on the Confluence page.
*
* @param url
* Incoming URL for the Kaltura video
* @param params
* Velocity parameters (pre-populated with standard Confluence variables)
*/
@Override
public String getEmbeddedHtml(
final String url,
final Map<String, String> params) {

String[] urlSegments = url.split("/");
String videoId = "";
if (urlSegments.length > 1) {
videoId = urlSegments[(urlSegments.length - 1)];
} else {
params.put("error", "Invalid source URL: " + url);
}
for(int i=0;i<urlSegments.length;i++){
System.out.println("url "+i+urlSegments[i]);
}
params.put(VelocityRenderService.TEMPLATE_PARAM, "templates/kaltura.vm");
params.put("videoId", videoId);
params.put("playerId", "kaltura_player_" + UUID.randomUUID().toString());
params.put("videoSrcId", "1_swpunaa5");

// For preview without width/height specified, default to 320x200
if (params.get("width") == null) {
params.put("width", "320");
}
if (params.get("height") == null) {
params.put("height", "200");
}
System.out.println("render "+renderer.render(url, params));
return renderer.render(url, params);
}

/**
* @returns 'true if the incoming URL matches 'kaltura.com'
* (anywhere in it).
*/
@Override
public boolean matches(
final String url) {
return url.contains("kaltura.com");
}

my kaltura.vm is

<iframe id="$playerId"
src="https://cdnapisec.kaltura.com/p/2286491/sp/228649100/embedIframeJs/uiconf_id/39478542/partner_id/2286491?iframeembed=true&playerId=$playerId&entry_id=$videoId&flashvars[streamerType]=auto&amp;flashvars[localizationCode]=en&amp;flashvars[leadWithHTML5]=true&amp;flashvars[sideBarContainer.plugin]=true&amp;flashvars[sideBarContainer.position]=left&amp;flashvars[sideBarContainer.clickToClose]=true&amp;flashvars[chapters.plugin]=true&amp;flashvars[chapters.layout]=vertical&amp;flashvars[chapters.thumbnailRotator]=false&amp;flashvars[streamSelector.plugin]=true&amp;flashvars[EmbedPlayer.SpinnerTarget]=videoHolder&amp;flashvars[dualScreen.plugin]=true&amp;&wid=$videoSrcId" width=$width height=$height allowfullscreen webkitallowfullscreen mozAllowFullScreen frameborder="0" title="Kaltura Player">
</iframe>

 With this code am able to play few kaltura videos.

1 vote
Jens Kasperek March 19, 2018

It would be great to have a Kaltura macro / plugin available...!

0 votes
Shannon S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 11, 2017

Hi Shankar,

I'm not clear on what it is you're asking.

Are you asking how to add an iFrame into a Confluence page? Or do you require something more specific? 

Please elaborate on what we can help you with and we'll be happy to assist.

Kind Regards,
Shannon

Shankar Murthy Pokala September 11, 2017

Hi Shannon,

I pasted the kaltura url in the confluence, my code is able to auto convert that url into widget macro.

When I publish the page, i cant view the thumbnail of the video. It looks like below.

kaltura1.PNG

I observed the code on the UI, the div tag is formed as 

<div class="widget-error">    <span class="widget-link">rcsaas.mediaspace.kaltura.com</span></div></div>

When I edit the html on UI to the below format, am able to see the kaltura thumbnail and able to play the video.

<iframe class="conf-macro output-block" type="text/html" style="width: 400px; height: 300px" src="https://rcsaas.mediaspace.kaltura.com/media/Summer+Roses/0_t4ba0g3c/75994502" frameborder="0" data-hasbody="false" data-macro-name="widget"></iframe>

I dont want to use available html macro plugin to be enabled manually. I want to handle this framing the div tag in java code.

I found ViewMacroErrorPlaceholderImpl.java class, from confluence source code, which forms the "widget-error" class.

Similarly, I am looking for a java class which can render the above iframe tag as response.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events