Wildhoney / ngVideo

Modularised ~13KB HTML5 audio/video implementation using Angular.js
http://ng-video.herokuapp.com/
MIT License
227 stars 60 forks source link

Video update on location change #12

Closed farazhassan closed 10 years ago

farazhassan commented 10 years ago

I need to play a video depending on the URL. Like if it changes from .../video/1 to .../video/2, the player should play the video 2 instead of video one, in the controller, I update everything based on the $routeParams value, the view is changed, everything else works fine EXCEPT the video, it just doesn't load. Any ideas?

Wildhoney commented 10 years ago

How are you changing the video? I would invoke the open method with the videoModel, and then ensure the video is playing.

farazhassan commented 10 years ago

1) I can't find the documentation. This is the first time I'm looking at the open function. 2) I just added another video to the video service.

Wildhoney commented 10 years ago

Ah I see. Yes, you should add another video via the playlist, and then open it. Something like the following, where ngVideo is your context:

var videoModel = ngVideo.addSource('mp4', 'http://www.w3schools.com/html/mov_bbb.mp4');
ngVideo.open(videoModel);
farazhassan commented 10 years ago

Nope. Says that its not a function of the video service(If i understood the context right, that refers to the video service I'm using inside my controller?)

Wildhoney commented 10 years ago

I'll need to add a way to forcefully change the video to the recently added. Please leave it with me – I'll have you a release today to allow that.

farazhassan commented 10 years ago

Ohk sure. Thanks

Wildhoney commented 10 years ago

Please update ngVideo to 0.4.11 and try again by specifying the third parameter in your addSource method:

video.addSource('mp4', $scope.videos.second, true);

If you're using the MultiSource approach, then specify true in the save method.

farazhassan commented 10 years ago

Umm I'm not using the multisource approach right now. Im supposed to just replace the old addSource funciton with this? What does the third argument specify?

Wildhoney commented 10 years ago

Just set the third argument in your addSource method to true to force the change of the video.

farazhassan commented 10 years ago

It does change the video for some time but eventually it just stops responding, shouldn't there be helper functions like remove all videos or something?

Wildhoney commented 10 years ago

How do you mean it stops responding?

farazhassan commented 10 years ago

It forcefully changes the video exactly 5 times and then if you try to change it again, it stops responding, and the video wont change and the screen is black.

Wildhoney commented 10 years ago

Pushed ngVideo#4.12.0 and added an example for you.

farazhassan commented 10 years ago

I have done exactly the same thing, lets see. Will close the issue when i have a working version.

farazhassan commented 10 years ago

Its working fine now. But it takes at least a second to change the video. Thanks

Wildhoney commented 10 years ago

No problem! :beers: It will depend on your Internet connection, and you have to consider the time for the browser to load the video, and for it to buffer. Even cached videos will take a moment to load, depending on your connection.