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

How to extend HTTPLoader? #4424

Open
snowinszu opened this issue Mar 17, 2024 · 4 comments
Open

How to extend HTTPLoader? #4424

snowinszu opened this issue Mar 17, 2024 · 4 comments

Comments

@snowinszu
Copy link

snowinszu commented Mar 17, 2024

My code is like below:

function CustomLoader() {
    const parent = this.parent;
    function load(config) {
        parent.load(config);
    }

    function abort() {}

    return {
        load: load,
        abort: abort
    }
}
player.extend("HTTPLoader", CustomLoader);

But it got recursive call, any help?

@dsilhavy
Copy link
Collaborator

What do you mean exactly by " it got recursive call"? Please provide more information on what you are seeing and what you expect to see.

@snowinszu
Copy link
Author

I want to hook the HTTPLoader to add some custom logic, in my custom loader it can call the original HTTPLoader function like .load() and .abort()

@snowinszu
Copy link
Author

@dsilhavy

@dsilhavy
Copy link
Collaborator

I dont think it is possible that way. From the API defintion

If you set override to true any public method or property in your custom object will
override the dash.js parent object's property(ies) and will be used instead but the
dash.js parent module will still be created.

This means you are recursively calling load. I understand your use case but the current implementation is too limited to support this.

As a workaround you might be able to use this for v4 https://reference.dashif.org/dash.js/v4_nightly/samples/advanced/extend.html or this for v5 https://reference.dashif.org/dash.js/nightly/samples/network-interceptor/index.html to change the requests.

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

No branches or pull requests

2 participants