// ... 코드 주요 내용
var playerID = 'youtube_video';
//------------------
// IFrame 설정
//------------------
(function (){
// ID 설정: ID는 속성창에 아이디 입력란에 작성해도 됨
var $player = $self.children('element-69d1db71-5a09-486f-bb96-e01b2ce20556');
$player.dom.id = playerID;
// console.error('$player : ', $player);
})();
//------------------
// Player 설정
//------------------
var option = {
videoId: 'M7lc1UVf-VE'
}
var player;
window.youtube_in_element(playerID, option, function (playerInterface){
player = playerInterface;
});
// ...나머지 코드는 예제 참고
// ... 코드 주요 내용
var playerID = 'youtube_video';
//------------------
// IFrame 설정
//------------------
(function (){
// http://www.youtube.com/embed/M7lc1UVf-VE?enablejsapi=1&origin=http://localhost:5301
var $player = $self.children('element-3b9d2eb3-7db1-451a-b6a5-a8d71593c374', true);
var iframe = $($player.dom).find('iframe')[0];
iframe.id = playerID;
iframe.setAttribute('sandbox', 'allow-forms allow-scripts allow-pointer-lock allow-same-origin allow-top-navigation allow-presentation allow-popups allow-popups-to-escape-sandbox');
iframe.setAttribute('allow', 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture');
iframe.setAttribute('allowfullscreen', true);
// console.error('iframe : ', iframe);
// console.error('$player : ', $player);
})();
var player;
window.youtube_in_element(playerID, null, function (playerInterface){
player = playerInterface;
});
// ...나머지 코드는 예제 참고
<div id="youtube_video"></div>
<!-- button -->
<div id="play">재생</div>
<div id="pause">일시정지</div>
// 본 콘텐츠는 IFrame에서 동작하므로 별도로 로드해야함
<script src="./유튜브API.js"></script>
// ... 코드 주요 내용
var playerID = 'youtube_video';
//------------------
// Player 설정
//------------------
// $self 객체는 저작도구에서는 지원 안됨 (미리보기에서는 동작함)
//console.error('$self.height(): ', $self.width(), $self.height());
var option = {
width: window.innerWidth,
height: (window.innerHeight - 100),
videoId: 'M7lc1UVf-VE',
}
var player;
window.youtube_in_element(playerID, option, function (playerInterface){
player = playerInterface;
});
// ...나머지 코드는 예제 참고