Emily Connors
Emily Connors

Reputation: 11

magnific-popup generates "file not found" error for YouTube videos

I am trying to make a popup containing a YouTube video. The code I have is

$(document).ready(function() {
  $('#vid1').magnificPopup({
    items:{
      src: 'http://www.youtube.com/watch?v=0O2aH4XLbto'
    },
    type:'iframe'
  });
});

I get a popup that says The file or directory could not be found. What am I missing or doing wrong? I have tried multiple types of YouTube links; all result in the same error.

Upvotes: 1

Views: 1461

Answers (3)

Wahid Polin
Wahid Polin

Reputation: 101

For some reason u cant load youtube or vimeo video from localhost,use a code editor like brackets it has a built in server.You can see your video working if u use the "live preview".

Upvotes: 1

Chris Van Cleve
Chris Van Cleve

Reputation: 33

Are you trying to view the video from a local file? YouTube player blocks that. (file:///) You have to test their videos from a web server. (http(s)://)

Upvotes: 1

Tamil Selvan C
Tamil Selvan C

Reputation: 20219

Put type:'iframe' inside the items object.

try

$(document).ready(function() {
  $('#vid1').magnificPopup({
    items:{
      src: 'http://www.youtube.com/watch?v=0O2aH4XLbto',
      type:'iframe'
    },

  });
});

Upvotes: 0

Related Questions