Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugins): add p2p-media-loader options filter #5318

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(plugins): add p2p-media-loader options filter
closes #5317
  • Loading branch information
kontrollanten committed Oct 1, 2022
commit 0981079e464bcd10b685b8d853fd591e94570842
2 changes: 1 addition & 1 deletion client/src/assets/player/peertube-player-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class PeertubePlayerManager {

const videojsOptions = await this.pluginsManager.runHook(
'filter:internal.player.videojs.options.result',
videojsOptionsBuilder.getVideojsOptions(this.alreadyPlayed)
await videojsOptionsBuilder.getVideojsOptions(this.alreadyPlayed)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need the await since the runHook function will automatically handle the result appropriately if it's a promise

)

const self = this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ export class HLSOptionsBuilder {

}

getPluginOptions () {
async getPluginOptions () {
const commonOptions = this.options.common

const redundancyUrlManager = new RedundancyUrlManager(this.options.p2pMediaLoader.redundancyBaseUrls)

const p2pMediaLoaderConfig = this.getP2PMediaLoaderOptions(redundancyUrlManager)
const p2pMediaLoaderConfig = await this.options.pluginsManager.runHook(
'filter:internal.player.p2p-media-loader.options.result',
this.getP2PMediaLoaderOptions(redundancyUrlManager)
)
const loader = new this.p2pMediaLoaderModule.Engine(p2pMediaLoaderConfig).createLoaderClass() as P2PMediaLoader

const p2pMediaLoader: P2PMediaLoaderPluginOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class ManagerOptionsBuilder {

}

getVideojsOptions (alreadyPlayed: boolean): videojs.PlayerOptions {
async getVideojsOptions (alreadyPlayed: boolean): Promise<videojs.PlayerOptions> {
const commonOptions = this.options.common

let autoplay = this.getAutoPlayValue(commonOptions.autoplay, alreadyPlayed)
Expand Down Expand Up @@ -61,7 +61,7 @@ export class ManagerOptionsBuilder {

if (this.mode === 'p2p-media-loader') {
const hlsOptionsBuilder = new HLSOptionsBuilder(this.options, this.p2pMediaLoaderModule)
const options = hlsOptionsBuilder.getPluginOptions()
const options = await hlsOptionsBuilder.getPluginOptions()

Object.assign(plugins, pick(options, [ 'hlsjs', 'p2pMediaLoader' ]))
Object.assign(html5, options.html5)
Expand Down
5 changes: 4 additions & 1 deletion shared/models/plugins/client/client-hook.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ export const clientFilterHookObject = {
'filter:share.video-playlist-url.build.result': true,

// Filter videojs options built for PeerTube player
'filter:internal.player.videojs.options.result': true
'filter:internal.player.videojs.options.result': true,

// Filter p2p media loader options built for PeerTube player
'filter:internal.player.p2p-media-loader.options.result': true
}

export type ClientFilterHookName = keyof typeof clientFilterHookObject
Expand Down