Code Monkey home page Code Monkey logo

angular-youtube-embed's People

Contributors

acorbel avatar brandly avatar cwspear avatar hinok avatar jpiasetz avatar juhq avatar konradhalas avatar konsumer avatar okhomenko avatar rushdykamel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-youtube-embed's Issues

infinite $digest loop

Hi matt,

I really like your angular youtube player directive!
I am relatively new to angular. I dont really know if it is a bug or whatever.

I realised that the following function produces an infinite $digest loop:

            function applyBroadcast () {
                var args = Array.prototype.slice.call(arguments);
                scope.$apply(function () {
                    scope.$emit.apply(scope, args);
                });
            }

Do you know a way to fix this issue?

Autoplay does not work on chrome in android

When passing player vars

$scope.playerVars = {
        controls: 1,
        autoplay: 1
    };

The video does not auto play on chrome in android. It works on desktop though.

Though this may be a limit of chrome in android.

How to use this too for a ng-repeat.

Hi,
I got a problem when I try to list some video from ng-repeat, here is the code
video-url="'{{video.url}}'"
I checked the compiled page, I found it didn't parse url for src code, so do you have any idea how to solve it.

Thanks
Peter

Use existing player on video change

You're currently destroying the player and calling createPlayer every time the video id (or url/play list) is being changed. I think YouTube just updated their API's to stop this as my site started breaking.

Not sure if there are other use cases that might break this, but my current work around is to modify your loadPlayer function to check if the player exists, and instead of creating a new one, use player.loadVideoById to update the id. There are similar calls for load by url and for playlists.

src: https://developers.google.com/youtube/iframe_api_reference#loadVideoById

Getting an ng-if bug

Hi there,

If the youtube directive is removed via ng-if and then reintroduced later to play something, it errors out. The error I get is the following:

TypeError: Cannot read property 'id' of null
at O.g.destroy (https://s.ytimg.com/yts/jsbin/www-widgetapi-vfle2r0X0/www-widgetapi.js:21:28)
at loadPlayer (http://localhost:3000/lib/angular-youtube-mb/src/angular-youtube-embed.js:193:38)
at Object. (http://localhost:3000/lib/angular-youtube-mb/src/angular-youtube-embed.js:224:33)
at Object.applyFunction as fn
at Scope.$digest (http://localhost:3000/lib/angular/angular.js:12512:29)
at Scope.$delegate.proto.$digest (:844:31)
at Scope.$apply (http://localhost:3000/lib/angular/angular.js:12777:24)
at Scope.$delegate.proto.$apply (:855:30)
at HTMLButtonElement. (http://localhost:3000/lib/angular-touch/angular touch.js:440:13)
at HTMLButtonElement.n.event.dispatch (http://code.jquery.com/jquery-2.1.1.min.js:3:6404)

Thanks for making the ng-if changes so far!

Audio volume on iOS

This may not be related to your plugin, but perhaps you know a solution.

When having the phone muted on iOS (hardware button) the audio of a video in a PhoneGap app is not being played. When opening a video in the Youtube app or in mobile Safari, the audio is playing.

Remain in fullscreen when playing next video

Thanks for the great directive. I'm building an app that will load a new video when the current video ends. If I'm watching a video in fullscreen on a desktop, the fullscreen is exited when the next video is played. This is the behavior on Chrome, Firefox, and IE from what I've tested.

Any idea how to keep the player in fullscreen so its a continuous fullscreen experience? I've got my own internal playlist system, so I'd rather not make use of YouTube's playlist system.

Here's my setup:

app.html

<div class="embed-responsive embed-responsive-16by9">
  <youtube-video class="embed-responsive-item" video-id="myVideo" player-vars="playerVars">  </youtube-video>
</div>

app.js

scope.playerVars = {
  modestbranding: 1,
  autohide: 1,
  showinfo: 0,
  controls: 1,
  // note: autoplay does not work on most mobile browsers
  autoplay: 1,
  fs: 1,
  allowfullscreen: 1
};

scope.$on('youtube.player.ended', function (event, player) {
  scope.playNext();
});

scope.playNext = function() {
  scope.myVideo = scope.next_youtube_video_id;                                              
}

This is probably more of a general youtube API or browser question, but figured you all would have some ideas.

player attribute isn't populated when ng-if is used

I have several posters that, when clicked, replace themselves with a youtube-video directives. It uses an ng-if to prevent any unnecessary player initialization on page load. The problem is, the player attribute remains undefined once the ng-if condition becomes true and is digested.

<youtube-video video-id="..." player="player" ng-if="started">

Control player state via attributes

The player attribute is good for very precise control from the controller. However, it would be nice to be able to declaratively control the state of the player via attributes. This way, template expressions can toggle playback:

<youtube-video playing="x + y > 10">
<youtube-video playing="playback">

Additionally, playhead position could be two-way bound to get and set playback position.

<youtube-video position="pos">

TypeError: Cannot read property 'childNodes' of undefined

not sure from where the issue is coming from.
the strange thing is that there's no error in Firefox & Safari but only in Chrome (v39) - and the video doesn't load.

Your demo does works on Chrome, so I'm guessing something in the code bothering it, I'm just not sure from where to start, because the error points only to Angular

TypeError: Cannot read property 'childNodes' of undefined
    at g (http://domain.com/js/angular.min.js:51:321)
    at g (http://domain.com/js/angular.min.js:51:316)
    at g (http://domain.com/js/angular.min.js:51:316)
    at http://domain.com/js/angular.min.js:50:414
    at http://domain.com/js/angular.min.js:18:8
    at k.$eval (http://domain.com/js/angular.min.js:124:325)
    at k.$apply (http://domain.com/js/angular.min.js:125:6)
    at http://domain.com/js/angular.min.js:17:479
    at Object.e [as invoke] (http://domain.com/js/angular.min.js:36:365)
    at d (http://domain.com/js/angular.min.js:17:400)

When I remove the <youtube tag - the error goes away.
I'm also using ng-facebook, so I'm using Angular 1.2.27

Just wanted to know if you have something in mind, it will take me a while to debug it...

`playVideo()` doesn't work as expected on android chrome 38.0.2125.114

I use external button to play video and it works well on all desktop browsers (safari, chrome, firefox), and it works on mobile firefox. Here's a jsfiddle: http://jsfiddle.net/saczk32v/15/

it doesn't work very well on mobile chrome of my Android device. when using the button with ng-click="player1.playVideo()", it has to click the button at least twice to play video.

when inspecting the player object, the currentState property value becomes buffering when running player.playVideo() for the first time, when run it again, the video plays.

Is there anything special for mobile chrome?

same video buffers longer than window.open

same video, same network environment, the one with youtube directive loads/buffers so much longer than window.open("https://www.youtube.com/embed/xxx");
the youtube directive takes 2-3 mins buffering time while at the same time the same video in my same app plays immediately using window.open, i tried different orders with different videos, still behave the same.

Angular 1.4.2 nothing happens

Nothing happens using:

<youtube-video video-id="sMKoNBRZM1M"></youtube-video>

and using video-url occurs an error

<youtube-video video-url="anotherGoodOne"></youtube-video>

Push to NPM 1.1.0

Looks like latest on NPM is 1.0.3.

Could you please push 1.1.0 to NPM?

Thanks, Alex

Would like to use a width of 100%

But trying to do so I get

Syntax Error: Token 'undefined' not a primary expression at column null of the expression [100%] starting at [100%].

How to control the player from another controller ?

I currently have a YouTubeCtrl controller
And the player controllers are on a different part of the screen, so I couldn't use the same ng-controller
so I created a new controller, something like YouTubeSideCtrl
But how do I control it from there ?

This doesn't work:

<span ng-click="MainYouTube.playVideo()"> play button </span>

Obviously ...

Any idea ?

switch between ui-router state causing error

the ui-router configuration:

$stateProvider.state("a")
$stateProvider.state("b") //abstract
$stateProvider.state("b.c")

if state transition from "b.c" to "a" then it will causing the error

TypeError: Cannot read property 'id' of null at O.g.destroy (https://s.ytimg.com/yts/jsbin/www-widgetapi-vflfilDmc/www-widgetapi.js:21:28)

after this error, if I continue to change(or refill) the video-id then

TypeError: Cannot read property 'src' of null at O.g.J (https://s.ytimg.com/yts/jsbin/www-widgetapi-vflfilDmc/www-widgetapi.js:26:91)

Any ideas?

Webpack integration

Package doesn't work with webpack.
On build it throws

WARNING in ./~/angular-youtube-embed/src/angular-youtube-embed.js
Critical dependencies:
1:16-23 require function is used in a way in which dependencies cannot be statically extracted

Videos repeat on ng-repeat.

I have a json file where I save my videos when I execute a ng-repeat I'd which each one of his videos have a different scope of player-vars. Is that possible?

Json files :
[
{
"id": "0",
"title": "Lorem ipsum torem tapusm ipsum",
"date": "19 juillet 2015",
"videosUrl": "zFXpNT-Tse0",
"startTimes": "40",
"endTimes": "45",
"herosId": "5",
"likes": "45",
"comments" : "384"
},
{
"id": "1",
"title": "Lorem ipsum torem tapusm ipsum",
"date": "19 juillet 2015",
"videosUrl": "zFXpNT-Tse0",
"startTimes": "5",
"endTimes": "10",
"herosId": "5",
"likes": "45",
"comments" : "384"
}
]

Turning off related videos.

I've tried to concatenate video-id with a variable that contains the string "?rel=0" so as to turn off the related videos (e.g. "http://youtube.com/embed/NVl_IFepdLQ?rel=0") , but "?enablejsapi=1&origin=http%3A%2F%2Flocalhost%3A3000" gets appended to the url causing the related videos to fire. Is there another way to turn off the related videos?

Embedding Playlists

Hi! Thanks a lot for the great project, wondering if you have any plans of including the playlists support?

Question: how can I detect when the timeline is manipulated?

Given this scenario:

  • Player is complety loaded (100% of the video is already loaded)
  • Player is in state "playing" (it already fired that event some time ago)

If the user clicks in the timeline (eg: in the middle, or 3/4 of it), the player will skip to that part without firing any events (no buffering because its already buffered, not playing because it is already playing).

How can I detect this situation?
Is "watching" the only way?

timeupdate Event

Hi there, would you be interested in merging a timeupdate pseudo-event implementation based on setInterval? This is a big gap when compared to most HTML5 video players out there.

wired "&amp" generated

Hi,
Your Library looks very nice, but it renders thinks like this:

<iframe video-id="tupeuxfaire" class="ng-isolate-scope" id="unique-youtube-embed-id-1" frameborder="0" allowfullscreen="1" title="YouTube video player" width="640" height="390" src="https://www.youtube.com/embed/yxki-YmJyyw&?enablejsapi=1&origin=http%3A%2F%2Fmystiquerie.dev%3A8000"></iframe>

Which does not work.

ADD:
If I use the video-url strategy, everything works perfectly!

It would be perfect without the "amp;" string beeing added everywhere. Do you have an idea about what I did wrong?

here is the corresponding html:

<div ng-controller="YouTubeCtrl">
  <youtube-video video-id="theBestVideo"></youtube-video>
</div>

and here is the controller:

angular.module('my_app').controller('YouTubeCtrl', function ($scope) {
  // have a video id
  $scope.theBestVideo = 'yxki-YmJyyw';
});

iOS home screen web app

If I make a homescreen bookmark from the webapp (which will open my app in a borderless web window) when the video is loaded, it spawns the youtube app to play it.

this is related.

If I manually make an embed that looks like this, using $sce.trustAsResourceUrl($scope.videoURL), it works:

<iframe width="100%" height="300" src="{{videoURL}}" frameborder="0" allowfullscreen></iframe>

but I must use https://www.youtube-nocookie.com/embed/VIDEOID and I don't get any of the event callbacks.

to reproduce:

  • visit this demo on an iOS device
  • Add to home screen (under the bookmark menu)
  • open link from homescreen

Maybe there isn't a fix, but it seems like it should work if the youtube iframe API allows -nocookie domain.

Invalid isolate scope definition

Hello,

I tried to use the module inside a chrome extension using angular and got this error:
"Error: Invalid isolate scope definition for directive youtubeVideo: =? at Error (native)"

Also, "Refused to load the script 'https://www.youtube.com/iframe_api' because it violates the following Content Security Policy directive: "script-src 'self' chrome-extension-resource:" gets printed, but not sure if it is related.

Any idea ?

Call fullscreen video

I make custom controller and want to add method fullscreen video in my fullscreen button. How can I make method to full screen it ? Thanks a lot.

still error dependency injection

I am still getting error on script.js 1 line

var app = angular.module('myApp', ['ngRoute','youtube-embed']);
app.controller('ServicesCtrl',['$scope', function($scope){
  $scope.theBestVideo = 'sMKoNBRZM1M';
}]);

services.html

<div class="row">
  <div class="col-lg-12">
    <h2>Services</h2>


    <youtube-video video-id="theBestVideo"></youtube-video>
</div>
</div>

index.html

  <script src="https://www.youtube.com/iframe_api"></script>
    <script src="angular-youtube-embed.js"></script>

Does anybody have any idea how to solve this?

Directive doesn't work in angular bootstrap.

Hey Brandly, I had this directive working without any issue in a different project (which is why I stuck with it through this incredibly difficult bug to find).

Basically, I tried to use the youtube-video directive on the index.html (served right away) and it kills all directives on the page and throws this exception:

TypeError: Cannot read property 'nodeName' of undefined
at Function.jQuery.acceptData (http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js:3618:35)
at internalData (http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js:3682:15)
at Function.jQuery.extend.data (http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js:3878:10)
at compositeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js:6052:22)
at nodeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js:6670:24)
at compositeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js:6070:13)
at compositeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js:6073:13)
at publicLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js:5966:30)
at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js:1440:27
at Scope.$eval (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.js:12632:28) 

I went into the angular-youtube-embed source code and discovered that issue is in this block of code:

(function () {
    var validProtocols = ['http:', 'https:'];
    var url = '//www.youtube.com/iframe_api';

    // We'd prefer a protocol relative url, but let's
    // fallback to `http:` for invalid protocols
    if (validProtocols.indexOf(window.location.protocol) < 0) {
        url = 'http:' + url;
    }
    var tag = document.createElement('script');
    tag.src = url;
    var firstScriptTag = document.getElementsByTagName('script')[0];
    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
}());

If you put this code into a setTimeout, however, all the issues go away.

So I crafted a directive to fix this issue as a temporary workaround for myself:

.directive('video', ['$timeout', '$compile', function($timeout, $compile) {
  return {
    template: '',
    link: function(scope, elem, attr) {
      // HACK: for some reason the youtube directive causes an error 'undefined doesn't have property nodeName' or something
      // unless we put it in a timeout and it doesn't run during the angular bootstrap.
      $timeout(function() {
        elem.append('<div youtube-video class="embed-responsive-item" video-id="videoId" player-height="360" player-width="640"></div>');
        $compile(elem.contents())(scope);
      });
    }
  };
}]); 

cast_sender.js error

I'm using it and sice i inserted in my webapp i got this error:
GET chrome-extension://boadgeojelhgndaghljhdicfkmllpafd/cast_sender.js

It appears a couple of times and i've included both files, youtube and the directive, just like the example. I'm using a video-url with AngularJs 1.4.3.

What may be wrong?

_index_

<!-- Youtube -->
<script src="https://www.youtube.com/iframe_api"></script>
<script type="text/javascript" src="dist/lib/ngYoutube.min.js"></script>

_html_

<div class="embed-responsive embed-responsive-16by9">
    <youtube-video class="embed-responsive-item" video-url="lookVideo"></youtube-video>
</div>

_ctrl_

$scope.lookVideo = 'https://www.youtube.com/watch?v=[myvideocode]'; //I'm using a correct url, but i changed because of client restrictions

Edit: Everything is working fine. But i have this error showing up a couple of times, and only in the page where the video appears.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.