Comments (4)
:( this is true.
do you have any suggestions of how this should look? since there's only a single $youtube
service for your entire app, instead of a single $youtube.player
reference, it could be like $youtube.getPlayer(id)
, where id
is the DOM id. that way, you can control multiple players.
for events, listeners could be passed something telling them the DOM id of the player, so you can distinguish like which one just paused
or whatever it may be.
let me know if you've got advice.
from angular-youtube-embed.
I hacked together a messy solution to make it work for my basic use case, but reading your comment I realized theres probably issues related to the onPlayerStateChange
event.
I'm just getting familiar with Angular directives so this probably isn't the ideal implementation but what I did was take everything that was in the service and move it into the link function of the directive. That way each instance of the directive had it's own youtube object to control. To make stuff work I also had to change $window.onYouTubeIframeAPIReady
to use a global flag rather than a per instance boolean ready
and look for that flag in stopWatchingReady
.
I hope this helps! If I was more comfortable working with directives I'd fork and fix it for you, but I don't want to muck things up. :)
from angular-youtube-embed.
I'd have to dig closer into the code, but it by far makes the most sense to me to pass the player in from the events:
$scope.$on('youtube.player.ready', function (player) {
player.playVideo();
});
and/or you could expose the player to the directive:
<youtube-video id="best-vid" video-url="theBestVideo" player="bestVideoPlayer"></youtube-video>
// $scope.bestVideoPlayer may not be available right away. This is not something that
// should be done in a controller callback, but maybe in an ng-click, etc.
$scope.playVideo = function () {
if ($scope.bestVideoPlayer)
$scope.bestVideoPlayer.playVideo();
};
I feel like you shouldn't have to expose the $youtube
service at all.
from angular-youtube-embed.
fixed with b0c0083
from angular-youtube-embed.
Related Issues (20)
- Safari Downloads YouTube Hex on Init
- [Question] Ioinic HOT 3
- npm WARN [email protected] No repository field HOT 1
- Plugin throws error when used with ionic {{}} HOT 3
- Append a div to the player when player goes fullscreen HOT 1
- Show time of video in real time HOT 3
- Getting SecurityError from youtube API
- Youtube embed problem with ui-bootstrap modal
- [Question] Does modestbranding parameter work? HOT 2
- Cant link after install.
- Inline video and autoplay on iOS10 HOT 1
- youtube.player.playing returns only once HOT 1
- Adjust the plugin for AngularJS 2 HOT 1
- Memory Leak - Chrome
- Include YouTube library in main lib
- White background on full-screen HOT 3
- iOS video going full screen on click to play. Playsinline parameter not working.
- playVideo is not working in ionic v1 HOT 1
- demo page doesn't support https
- API event messages are not received HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-youtube-embed.