brandly / angular-youtube-embed

:tv: Embed a YouTube player with a simple directive
http://brandly.github.io/angular-youtube-embed/
MIT License
508 stars 147 forks source link

Multiple players across multiple controllers and multiple ionic views? #115

Open AtomSub opened 8 years ago

AtomSub commented 8 years ago

Sorry in advance for the long explanation.

I have an ionic project that uses the side menu starter template.

One of the "views" has a page that watches a video while information is displayed from a firebase based on current time.

I load the player using: <youtube-video video-url="anotherGoodOne" player-vars="playerVars" player-width="'200px'" player-height="'200px'"></youtube-video>

Another view has a different interface that allows the user to edit which information is displayed at different times. I've added fine and coarse controls that allow the user to rewind or seek.

I load the player using: <youtube-video class="embed-responsive-item" video-url="anotherGoodOne" player="custom.player" player-vars="playerVars"></youtube-video>

If I play the video in the player 2 and then open the other view with player 1, the $scope.currentTime being displayed in {{currentTime}} matches player 2 until I press play.

Ideally I'd like to separate the "now playing" associated functions and the "editor" functions into two controllers, since that seems to be the angular way. However, I can't figure out how to do that with this youtube wrapper.

Any advice in general for the direction I should go? Thanks!

venigo commented 8 years ago

I am wondering this to..

` var current = $('#youtube .slick-current.slick-slide').hasClass('slick-active'); if(current){

                //console.log(player);

                var getid = $('#youtube .slick-current.slick-slide.slick-active iframe').attr('id');

                $scope.$on('youtube.player.ready', function ($event, player) {

                    var videoid = $('#youtube .slick-current.slick-slide.slick-active iframe').attr('id');
                    //var execute = videoid+'.playVideo();';
                    Function (u1.playVideo());
                    console.log (execute);

                    $timeout(function(){
                        console.log(Function(execute));
                        Function(execute)
                    },0);
                });

            }`

I can't manage to get it working inside a slider, if I run player.playVideo();, it runs all slides..