Skip to main content

Adding a custom plugin

Lura Player is designed from the ground up to meet all of the customer's needs. Every customer might have needs out of our scope, or third party system integrations that we might not have access to and we're aware of it. Therefore we made it easy to implement your custom logic in our player. By adding custom or third-party plugins, you can produce unique user experiences, such as:

  • Create custom user interactions
  • Evaluate the actions of your viewer in your backend
  • Understand your customer better
  • Initiate bespoke behaviors
  • Authenticate users to view your content

And many more

Getting Started

To get started with a custom plugin, you need to create a specific class which gets player in its constructors param and a getName() method which returns the name of the plugin as a string.

Here is an example plugin class

Typescript
class myCustomPlugin {
private player: LuraPlayer;
...
constructor(player: LuraPlayer) {
// Required
this.player = player;
...
}
// Required
getName() {
return "myCustomPlugin";
}
...
}

After creating the plugin class, you can add the plugin to the Lura Player by

import React, { useRef, useEffect } from "react";
import { LuraPlayer, LuraPlayerProps } from "lura-react-native-core";

export default function MySampleComponent() {
const playerRef = useRef<LuraPlayer>(null);

const config = {
...
};

useEffect(() => {
if (!playerRef || !playerRef.current) {
return;
}
playerRef.current?.addPlugin(myCustomPlugin)
}, [playerRef])

return (
<View>
<LuraPlayer ref={playerRef} config={config} />
</View>
);
}

And now the plugin is ready to use. It's that easy.

To learn more about what can you do with Lura Player in your Plugin go to Player SDK Reference

Here is an example custom plugin to log play pause events and play the video on some condition.

Typescript
class myCustomPlugin {
private player: LuraPlayer;
...
constructor(player: LuraPlayer) {
// Required
this.player = player;
...
}
// Required
getName() {
return "myCustomPlugin";
}
...
// Example Method
play() {
if (someCondition) {
this.player.play();
}
}
...
}