Skip to content

feat: custom media data support and tracker control#33

Merged
amtins merged 8 commits into
mainfrom
feat/32-custom-media-data-support-and-tracker-control
Oct 6, 2023
Merged

feat: custom media data support and tracker control#33
amtins merged 8 commits into
mainfrom
feat/32-custom-media-data-support-and-tracker-control

Conversation

@amtins
Copy link
Copy Markdown
Member

@amtins amtins commented Sep 24, 2023

Description

Add support for custom media data when provided via the mediaData property to
the player.src. Allow mediaComposition properties to be added or
overwritten when loading a new source.

// custom media data
player.src({
  src : 'urn:xyz',
  type: 'srgssr/urn',
  mediaData : {
    // custom properties
  }
})

Store the DataProvider in the player's srgOptions, allowing it to be changed
on the fly. This means it's no longer needed to extend the SrgSsr class to
redefine the default DataProvider. The only requirement is that the new
DataProvider implements the getMediaCompositionByUrn function and returns an
object of type MediaComposition.

// custom data provider
player.options({
  srgOptions : {
    dataProvider : {
      getMediaCompositionByUrn(urn) {
        // ... body of the function
      }
    }
  }
})

Add support for the trackers property to the player.options in order to
store tracker instances. This makes it easier to access trackers directly from
the player. Use of this feature remains optional.

// add custom tracker
const player = new Pillarbox('my-player', {
  trackers: {
    customTracker: new CustomTracker(player),
    anotherTracker: new AnotherTracker(player),
  }
})

Add the ability to disable trackers per playback session by introducing the
disableTrackers property provided directly to the player.src. As most trackers
take an instance of the player as a parameter. This will make it easier to access
the disableTrackers property to determine whether or not the tracker should be
disabled for the current playback session.

// disable a tracker for the playback session
player.src({
  src : 'urn:xyz',
  type: 'srgssr/urn',
  disableTrackers : ['anotherTracker']
});

// disable all trackers for the playback session
player.src({
  src : 'urn:xyz',
  type: 'srgssr/urn',
  disableTrackers : true
})

Add support for SRG SSR-compliant media playback tracking.

Changes made

  • add srgOptions to Pillarbox default options
  • rename DataProviderService to DataProvider
  • move DataProvider from middleware functions parameter to its own function
  • handle srcOptions enabling customized mediaData to be provided to the player
  • add srcOptions to the composeSrcMediaData function parameters
  • update srgssr unit tests
    • add srgOptions to the options in the mock player
    • rename DataProviderService to DataProvider
    • remove DataProvider from middleware function parameters
    • update some middleware test cases description
  • add trackers to Pillarbox default options
  • add the SRGAnalytics class and unit tests
  • add PlayerEvents that contains all mediaElement events
  • srgssr middleware
    • add a function to handle SRG SSR analytics
    • update composeSrcMediaData to handle disableTrackers
    • move the construction of the main resources array into its own function
    • update unit tests
  • update baseUrl property to use IL 2.1
  • handle disabled titleBar
  • replace bu by vendor
  • update video.js to version 8.5.3
  • add script to check for outdated packages
  • update eslint allow unused vars prefixed by _

Resolves #32

@amtins amtins changed the title Feat/32 custom media data support and tracker control Feat custom media data support and tracker control Sep 24, 2023
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Sep 24, 2023

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements
98.89% (-1.11% 🔻)
444/449
🟢 Branches
94.14% (-5.86% 🔻)
209/222
🟢 Functions 100% 127/127
🟢 Lines 100% 433/433
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / PlayerEvents.js
100% 100% 100% 100%
🟢
... / SRGAnalytics.js
98.79% 93.02% 100% 100%
🟢
... / DataProvider.js
100% 100% 100% 100%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / srgssr.js
95.35% (-4.65% 🔻)
83.33% (-16.67% 🔻)
100% 100%

Test suite run success

127 tests passing in 8 suites.

Report generated by 🧪jest coverage report action from 997dad2

@amtins amtins changed the title Feat custom media data support and tracker control feat: custom media data support and tracker control Sep 25, 2023
@amtins amtins force-pushed the feat/32-custom-media-data-support-and-tracker-control branch from 0d5cc5f to 17ddabf Compare September 25, 2023 11:23
Allow to use the latest state-of-the-art IL features.

- update `baseUrl` property
Add support for custom media data when provided via the `mediaData` property to
the `player.src`. Allow `mediaComposition` properties to be added or
overwritten when loading a new source.

```javascript
// custom media data
player.src({
  src : 'urn:xyz',
  type: 'srgssr/urn',
  mediaData : {
    // custom properties
  }
})
```

Store the `DataProvider` in the player's `srgOptions`, allowing it to be changed
on the fly. This means it's no longer needed to extend the `SrgSsr` class to
redefine the default `DataProvider`. The only requirement is that the new
`DataProvider` implements the `getMediaCompositionByUrn` function and returns an
object of type `MediaComposition`.

```javascript
// custom data provider
player.options({
  srgOptions : {
    dataProvider : {
      getMediaCompositionByUrn(urn) {
        // ... body of the function
      }
    }
  }
})
```

- add `srgOptions` to Pillarbox default options
- rename `DataProviderService` to `DataProvider`
- move `DataProvider` from middleware functions parameter to its own function
- handle `srcOptions` enabling customized `mediaData` to be provided to the player
- add `srcOptions` to the `composeSrcMediaData` function parameters
- update `srgssr` unit tests
  - add `srgOptions` to the options in the mock player
  - rename `DataProviderService` to `DataProvider`
  - remove `DataProvider` from `middleware` function parameters
  - update some `middleware` test cases description

Refers to issue #32
`Video.js` allows components to be activated or deactivated via `options`.
Avoids breaking the compatibility offered by this feature.
@amtins amtins force-pushed the feat/32-custom-media-data-support-and-tracker-control branch from 17ddabf to d98b95c Compare September 25, 2023 11:42
Comment thread src/analytics/SRGAnalytics.js Outdated
Comment thread src/analytics/SRGAnalytics.js Outdated
Comment thread src/analytics/SRGAnalytics.js Outdated
Comment thread src/analytics/SRGAnalytics.js Outdated
Comment thread src/analytics/SRGAnalytics.js Outdated
Comment thread src/analytics/SRGAnalytics.js Outdated
Comment thread src/analytics/SRGAnalytics.js Outdated
Comment thread src/analytics/SRGAnalytics.js Outdated
Comment thread src/analytics/SRGAnalytics.js Outdated
Comment thread src/middleware/srgssr.js
static async composeAkamaiResources(resources = []) {
if (!AkamaiTokenService.hasToken(resources)) Promise.resolve(resources);

// TODO allow to modify the Akamai URL
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

TODO?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes 😅

@amtins amtins force-pushed the feat/32-custom-media-data-support-and-tracker-control branch 2 times, most recently from 2846752 to 8143dd7 Compare September 27, 2023 18:00
@amtins amtins force-pushed the feat/32-custom-media-data-support-and-tracker-control branch from 8143dd7 to 0a197b9 Compare October 6, 2023 10:21
Add support for the `trackers` property to the `player.options` in order to
store tracker instances. This makes it easier to access trackers directly from
the player. Use of this feature remains optional.

```javascript
// add custom tracker
const player = new Pillarbox('my-player', {
  trackers: {
    customTracker: new CustomTracker(player),
    anotherTracker: new AnotherTracker(player),
  }
})
```

Add the ability to disable trackers per playback session by introducing the
`disableTrackers` property provided directly to the `player.src`. As most trackers
take an instance of the player as a parameter. This will make it easier to access
the disableTrackers property to determine whether or not the tracker should be
disabled for the current playback session.

```javascript
// disable a tracker for the playback session
player.src({
  src : 'urn:xyz',
  type: 'srgssr/urn',
  disableTrackers : ['anotherTracker']
});

// disable all trackers for the playback session
player.src({
  src : 'urn:xyz',
  type: 'srgssr/urn',
  disableTrackers : true
})
```

Add support for SRG SSR-compliant media playback tracking.

- add `trackers` to Pillarbox default options
- add the `SRGAnalytics` class and unit tests
- add `PlayerEvents` that contains all `mediaElement` events
- srgssr middleware
  - add a function to handle SRG SSR analytics
  - update `composeSrcMediaData` to handle `disableTrackers`
  - move the construction of the main resources array into its own function
  - update unit tests

Refers to issue #32
@amtins amtins force-pushed the feat/32-custom-media-data-support-and-tracker-control branch from 0a197b9 to 997dad2 Compare October 6, 2023 12:50
@amtins amtins merged commit 548be84 into main Oct 6, 2023
@amtins amtins deleted the feat/32-custom-media-data-support-and-tracker-control branch October 6, 2023 13:07
@amtins amtins added the enhancement New feature or request label Nov 8, 2023
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 9, 2024

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request released on @main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom media data support and tracker control

2 participants