-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Added support for AMD in build process #55
Conversation
Change-Id: I0053bf7a15250667ccd14de35b79d35c1dda6dd6
Change-Id: Ice22380ebe823955824b25bfb59de18bfad8b9dc
Continuing the discussion from #35 . There I said that I had no problem running @palmerj3's solution but was getting errors when trying to load shaka as an AMD module inside our project. I realized that the working solution loads and Http video source whereas we are loading a Dash video source. If you modify the solution to be this: require(['./amd.js'], function(shaka) {
then it fails. It gives me that 'cannot read addEventListener of undefined' error that I was getting before. So it appears that it's not an issue with our source but that exporting shaka as an AMD module and trying to load a Dash source is not working at the moment. Is a module export something that you'd like to support officially? Is it worth registering this as a bug? |
@sanbornhnewyyz so in my project I am actually utilizing both the HTTP source and the DASH source but switching them based on the content. Both are working fine for me in a CommonJS environment. I'll do a bit more testing to see if there are any obvious issues in a AMD environment but from my local testing I don't see any of the errors you mention when playing back Dash content. However that content I'm playing is not DRM'd so perhaps that's a code path I haven't tested yet in AMD or CommonJS. Is that a requirement for your project? At this point I'm wondering if perhaps shaka is being garbage collected in your environment... Are you able to create an outside-the-closure reference to test this out? I'll do some more testing later and see if I see any issues myself. |
It appears that the TypeError is caused by a bug in the master branch. EWMABandwidthEstimator should be exported, but is being stripped as dead code since it is now only referenced at the application level. |
@sanbornhnewyyz: TypeError fixed in 4571061. |
Rather than building amd.js/index.js/index2.js, etc., I've put together a new wrapper template that works for commonJS in node, requireJS in node, requireJS in a browser, and direct use in a browser. I've tested in those 4 scenarios and everything seems to be working. Should have the change up on github soon. |
Great. Thanks for moving so quickly on this. Importing as an AMD module works fine now. Though shaka is still getting attached to the window as far as I can see. Is there any way around that? |
I have a solution in review internally which does not attach to the window when using commonJS or requireJS. |
Just tried out the latest master with these MPD samples: And it doesn't seem to be working. Works fine with HttpVideoSource however the DashVideoSource is giving me a few errors:
Any ideas? |
I'm not getting this TypeError. Can you please get the value of shaka.player.Player.version when one of these errors occurs? |
@joeyparrish: v1.2.0-156-ga1c0e44 |
@sanbornhnewyyz, what's the most recent commit you have from me? I'm unable to reproduce this in the test app in compiled mode, nor in a separate app using requireJS. Can either of you provide me a sample which reproduces this problem? Here's the source to my working requireJS sample: https://gist.github.com/joeyparrish/64e3f0a1231f3ea382b9 I tried all of the YouTube test content @palmerj3 linked to. The manifest for oops_cenc is a 404, but all of the others play in the gist linked above. |
Okay, looking @joeyparrish's gist, I think the cause of the problem is that I am not passing an estimator into the source constructor. I suspect that this is why @palmerj3 is getting the same errors, because the basic test app I was using was based on the one he posted above. If I pass null in @joeyparrish's gist instead of an estimator, then I get the same errors. So can you just clarify that? Now we have to explicitly create and pass an estimator? |
Yes, that is new for v1.3.0, introduced in 9c0d2db. The purpose is two-fold. For one, passing an estimator lets you inject your own implementation of IBandwidthEstimator without modifying the library. For another, it makes it possible to persist bandwidth information across playbacks, which means that the second video you stream can start in HD if you have enough bandwidth for it. |
Ok will try that. In the future would be good to increment the major version for breaking API changes. Until now I've passed null in as the second param and it worked fine - perhaps that wasn't supposed to be the case? |
Well, v1.3.0 isn't complete yet. I did not intend to break compatibility quite so hard. :-) I will make the parameter optional, and if null, we will create an instance of the default implementation. |
After 44b975d, defaults to a new instance of EWMABandwidthEstimator() if not supplied by the caller. |
This is great, thanks! |
If there are no objections, I am going to consider this resolved. Please feel free to open a new issue if there are any remaining issues with module support. And thanks again for helping get commonJS and requireJS supported. |
Build process now supports AMD.
Example usage: