Skip to content

Commit c8389da

Browse files
committed
Fix youtube video api call
1 parent 15e921d commit c8389da

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/resources/views/crud/fields/video.blade.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,26 @@
163163
url: null
164164
};
165165
166-
$.getJSON(api, function( data ){
166+
$.ajax({
167+
dataType: "jsonp",
168+
url: api,
169+
crossDomain: true,
170+
success: function (data) {
171+
if (typeof(data.items[0]) != "undefined") {
172+
var v = data.items[0].snippet;
173+
174+
video.id = videoId;
175+
video.title = v.title;
176+
video.image = v.thumbnails.maxres ? v.thumbnails.maxres.url : v.thumbnails.default.url;
177+
video.url = 'https://www.youtube.com/watch?v=' + video.id;
178+
179+
callback(video);
180+
}
181+
}
182+
});
183+
};
184+
185+
/* $.getJSON(api, function( data ){
167186
168187
if (typeof(data.items[0]) != "undefined") {
169188
var v = data.items[0].snippet;
@@ -176,7 +195,7 @@
176195
callback(video);
177196
}
178197
});
179-
};
198+
}; */
180199
181200
var fetchVimeo = function( videoId, callback ){
182201

0 commit comments

Comments
 (0)