Merge branch 'feature/video-frame' into 'build/node-server'
Feature/video frame See merge request !2
Showing
2 changed files
with
77 additions
and
0 deletions
Frame.html
0 → 100644
1 | +<!DOCTYPE html> | ||
2 | +<html> | ||
3 | + <body> | ||
4 | + <div id="player0"></div> | ||
5 | + <div id="player1"></div> | ||
6 | + <div id="player2"></div> | ||
7 | + | ||
8 | + <script> | ||
9 | + var tag = document.createElement('script'); | ||
10 | + | ||
11 | + tag.src = "https://www.youtube.com/iframe_api"; | ||
12 | + var firstScriptTag = document.getElementsByTagName('script')[0]; | ||
13 | + firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); | ||
14 | + | ||
15 | + var player; | ||
16 | + var players = []; | ||
17 | + players.push('player0'); | ||
18 | + players.push('player1'); | ||
19 | + players.push('player2'); | ||
20 | + var videoIds = []; | ||
21 | + videoIds.push('037o6vxm0es'); | ||
22 | + videoIds.push('kR77WlHRZrs'); | ||
23 | + videoIds.push('R6IT_f0XPT8'); | ||
24 | + | ||
25 | + function onYouTubeIframeAPIReady() | ||
26 | + { | ||
27 | + for(var i = 0; i < videoIds.length; i++) | ||
28 | + { | ||
29 | + player = new YT.Player(players[i], { | ||
30 | + height: '360', | ||
31 | + width: '640', | ||
32 | + videoId: videoIds[i], | ||
33 | + events: { | ||
34 | + // 'onReady': onPlayerReady, | ||
35 | + // 'onStateChange': onPlayerStateChange | ||
36 | + } | ||
37 | + }); | ||
38 | + } | ||
39 | + } | ||
40 | + | ||
41 | + // function onPlayerReady(event) { | ||
42 | + // } | ||
43 | + // function onPlayerStateChange(event) { | ||
44 | + // } | ||
45 | + // function stopVideo() { | ||
46 | + // } | ||
47 | + </script> | ||
48 | + </body> | ||
49 | +</html> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
Search.js
0 → 100644
1 | +var Youtube = require('youtube-node'); | ||
2 | +var youtube = new Youtube(); | ||
3 | + | ||
4 | +var word = '백종원 레시피'; // 검색어 지정 | ||
5 | +var limit = 10; // 출력 갯수 | ||
6 | + | ||
7 | +youtube.setKey('AIzaSyAsKr_oWGZIBbL5tLdIl98Lf9Pzqj8jX4o'); // API 키 입력 | ||
8 | + | ||
9 | +youtube.addParam('order', 'rating'); // 평점 순으로 정렬 | ||
10 | +youtube.addParam('type', 'video'); // 타입 지정 | ||
11 | +youtube.addParam('videoLicense', 'creativeCommon'); // 크리에이티브 커먼즈 아이템만 불러옴 | ||
12 | + | ||
13 | +youtube.search(word, limit, function (err, result) { // 검색 실행 | ||
14 | + if (err) { console.log(err); return; } // 에러일 경우 에러공지하고 빠져나감 | ||
15 | + | ||
16 | + console.log(JSON.stringify(result, null, 2)); // 받아온 전체 리스트 출력 | ||
17 | + | ||
18 | + var items = result["items"]; // 결과 중 items 항목만 가져옴 | ||
19 | + for (var i in items) { | ||
20 | + var it = items[i]; | ||
21 | + var title = it["snippet"]["title"]; | ||
22 | + var video_id = it["id"]["videoId"]; | ||
23 | + var url = "https://www.youtube.com/watch?v=" + video_id; | ||
24 | + console.log("제목 : " + title); | ||
25 | + console.log("URL : " + url); | ||
26 | + console.log("-----------"); | ||
27 | + } | ||
28 | +}); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment