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

NR-320035- Updating Video-Shaka-Js #10

Merged

Conversation

rajeevkumar-nr
Copy link
Contributor

@rajeevkumar-nr rajeevkumar-nr commented Oct 3, 2024

Jira Link - https://new-relic.atlassian.net/browse/NR-320035

This pull request updates the Shaka Tracker, Babel, and Webpack versions. It also upgrades the Shaka Player version from 2.2.1 to 4.11.2 and adds support for the MSS format, which is supported by Shaka Player.

@CLAassistant
Copy link

CLAassistant commented Oct 3, 2024

CLA assistant check
All committers have signed the CLA.

<script>
function initPlayer() {

Choose a reason for hiding this comment

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

move the functions to separate js file


this.tag.addEventListener('loadstart', this.onDownload.bind(this))

Choose a reason for hiding this comment

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

Look for a better way to bind these events, we can prevent the repetition.

Example: we can move the event and function mapping to a separate (js/json) file and in JS file just run a loop to bind, unbind the events, that way maintain the mapping as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

@bhansa-nr This code is pretty clear as it is now, one single line per event added. I could understand a factorization in case of multiple lines of code repeated for each event handler, but it's not the case. In my opinion a different approach, like the ones you mentioned, will just make the code unnecessary cumbersome, with no clear gain in readability, compactness or maintainability.

Choose a reason for hiding this comment

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

I slightly agree, but still I think we can find a better way to keep the events lists separate somewhere. It will increase the readability of the code.

}

unregisterListeners () {
this.tag.removeEventListener('loadstart', this.onDownload)

Choose a reason for hiding this comment

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

Same thing here, try to use the same mapping defined for events.


export default class ShakaTracker extends nrvideo.VideoTracker {
setPlayer (player, tag) {
if (!tag && player.getMediaElement) tag = player.getMediaElement()
Copy link
Contributor

@asllop asllop Oct 4, 2024

Choose a reason for hiding this comment

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

My comment here is the same I did for the dash.js tracker: newrelic/video-dash-js#1 (comment) I know this is not something you created, but something the tracker had already. But maybe we should change it (check my other comment here).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For shaka player, Not all events are directly coming from shaka Api. Once we load the Shaka player, then we can use
method getMediaElement(), by which all html5 events can be tracked. What We are trying to do is tracking some event which is coming from Shaka from player object and rest from tag object.

this.tag.addEventListener("playing", this.onPlaying.bind(this));
this.tag.addEventListener("seeking", this.onSeeking.bind(this));
this.tag.addEventListener("seeked", this.onSeeked.bind(this));
this.tag.addEventListener("error", this.onError.bind(this));

Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't checked the documentation of Shaka, but is it possible to register all elements in the player directly or do we really need to use the media element (stored in the tag)? If we can rely only in the player, I think we should avoid storing and using the media element.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can be achieved but by doing this.player.getMediaElement().addEventlistner(). Because all events are not coming directly from player object.

asllop
asllop previously approved these changes Oct 4, 2024
@asllop
Copy link
Contributor

asllop commented Oct 7, 2024

@rajeevkumar-nr before merging, could you please bump the version number (to 0.3.0) and update the changelog?

CHANGELOG.md Outdated
@@ -2,6 +2,10 @@

## Unreleased
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be deleted.

CHANGELOG.md Outdated
@@ -2,6 +2,10 @@

## Unreleased

## [0.2.0] - 2024/10/07
Copy link
Contributor

Choose a reason for hiding this comment

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

The version must be 0.3.0

CHANGELOG.md Outdated
@@ -2,6 +2,10 @@

## Unreleased

## [0.2.0] - 2024/10/07
### Lib
Copy link
Contributor

Choose a reason for hiding this comment

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

For some reason the previous entry in the changelog used the Lib label, which is wrong. We should use the standard semantic commit labels: "add", "update", etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

If in doubt, check the changelog of video-core: https://github.com/newrelic/video-core-js/blob/master/CHANGELOG.md

@rajeevkumar-nr rajeevkumar-nr requested a review from asllop October 7, 2024 11:18
@asllop asllop merged commit 0341b50 into newrelic:master Oct 7, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants