2015年11月20日金曜日

Youku の API

Youku の API

Player API です。 YouTube IFrame APIと似ってます。
client_id の項目はYoutube にはない。





2015年11月1日日曜日

Chrome insert_js.js

manifest.json
//////////////////////////////////////////////////////

{
  "name": "YouTools",
  "version": "1.1",
  "description": "Plsylist Tools",
  "manifest_version":2,
   "background": {
      "scripts": [ "background.js" ]
   },
  "browser_action": {
"default_icon": "icon_16.png",
"default_popup": "default_popup.html"
  },
 
  "icons":{"19":"GB-19.png",
"48":"GB-48.png",
"128":"GB-128.png"
},
 
 
   
   "permissions": ["bookmarks",
"tabs",
"activeTab",
"idle",
"cookies",
"*://*/*",
"system.cpu" ,
"system.memory",
"system.storage",
"downloads",
"storage"],

"content_scripts":[{
"matches":["*://*/*"],
"js":["insert_js.js"]
                       }
]

}








insert_js.js
/////////////////////////////////////////////////////////

function body_color(){
var jjj = document.getElementsByTagName('body');
jjj[0].style.backgroundColor="rgba(114, 174, 185, 0.26)";
}

function abc(){
var jt = document.getElementsByClassName('more-menu-wrapper');
if(jt.length > 0){
chk = "ok";
}

var you_dl = document.getElementsByClassName("yt-alert yt-alert-default yt-alert-info  playlist-cleared-of-deleted-videos-alert");
if(you_dl.length > 0){
chk = "ng";
}

for(var i in jt){
if(jt[i].childNodes){
if(jt[i].childNodes.length === 1){
jt[i].parentNode.parentNode.style.backgroundColor = 'red';
var tt = document.getElementById('pl-header')
tt.style.backgroundColor = 'red';
var ttt = document.getElementById('yt-masthead-container');
ttt.style.backgroundColor = 'red';
chk = "ng";
}else{
//console.clear();
}
}
}
}


// class="yt-alert yt-alert-default yt-alert-info  playlist-cleared-of-deleted-videos-alert"


function chk_my_item(){
var tag = document.getElementsByClassName('yt-uix-sessionlink g-hovercard      spf-link ');
if(tag.length > 0){
for(var i in tag){
if(tag[i].href == 'https://www.youtube.com/user/XXXXXID' ||
  tag[i].href == 'https://www.youtube.com/user/XXXXXID' ||
  tag[i].href == "https://www.youtube.com/channel/UCNSXxplP-UWcZFz3-wDM3RQ" ||
  tag[i].href == "https://www.youtube.com/channel/UCKWg8wctnd4q7z_5ojOclKA" ||
  tag[i].href == "https://www.youtube.com/channel/UCk0QT-xjO1y4gsa2bFyNDjQ" ){
  tag[i].parentNode.parentNode.parentNode.style.backgroundColor='Gold';
}
}
}

var tag2 = document.getElementsByClassName('g-hovercard');
if(tag2.length > 0){
for(var x  in tag2){
if(tag2[x].innerText == "XXXID" ||
  tag2[x].innerText == "XXXXID" ||
  tag2[x].innerText == "XXXXXID" ){
  tag2[x].parentNode.parentNode.parentNode.style.backgroundColor='Gold';
}
}
}
}


function chk_del_user(){
var tag = document.getElementsByClassName('yt-uix-sessionlink g-hovercard      spf-link ');
if(tag.length > 0){
for(var i in tag){
if(
tag[i].href == 'https://www.youtube.com/channel/UCPv4x_sLkl8tsBCS--aoASQ' ||
tag[i].href == 'https://www.youtube.com/channel/UC41FuIPvXyIYFjoGU-UCNSw' ||
tag[i].href == 'https://www.youtube.com/user/RyansLyfe' ||
tag[i].href == 'https://www.youtube.com/channel/UCQjh-JVPNWfY-KsZS3RgRHw' ||
tag[i].href == 'https://www.youtube.com/user/ClevverNews' ||
tag[i].href == 'https://www.youtube.com/channel/UCPOzcixjIIj-F7WxtFLoeWA' ||
tag[i].href == 'https://www.youtube.com/channel/UCvTDwUGW41jGzrKUrNAjW3w' ||
tag[i].href == 'https://www.youtube.com/channel/UCIrzk08B6OHq6CTEi5LTM-A' ||
tag[i].href == 'https://www.youtube.com/channel/UCiw-Il_jgZlDokbIXOBAwBw' ||
tag[i].href == 'https://www.youtube.com/channel/UCCwEw5ZlP3QmgISJplp4rNA' ||
tag[i].href == 'https://www.youtube.com/channel/UCj_TUjpxaS1iuK8roR7bB0w' ||
tag[i].href == 'https://www.youtube.com/channel/UCe9sr3nyVycsbXB1PlJQ63w' ||
tag[i].href == 'https://www.youtube.com/channel/UCarB6_K5Hy422asmDX9T1ew' ||
tag[i].href == 'https://www.youtube.com/channel/UCAuxXt4w3hAJJKA_Xy5mDZQ' ||
tag[i].href == 'https://www.youtube.com/channel/UCfG-I3AEbrxM0bp3xCJVk5g' ||
tag[i].href == 'https://www.youtube.com/channel/UC9a6e6Hd7ShWcnGkNVcomoA' ||
tag[i].href == 'https://www.youtube.com/channel/UCNwgG5F2W8OJ4G37WYh1RqA' ||
tag[i].href == 'https://www.youtube.com/channel/UCMbTe5JqeDWsEHcbIzapiAQ' ||
tag[i].href == 'https://www.youtube.com/channel/UC5S_v9ReRER5VHPciNPabQw'
  ){
  tag[i].parentNode.parentNode.parentNode.style.backgroundColor='red';
  chk = "ng";
}
}
}
}


function auto_link(){
var ja = document.getElementsByClassName('vm-video-title-text yt-uix-sessionlink');
var cont = ja.length;

function aut(){
cont = cont -1;
if(opener == null && location.pathname == "/view_all_playlists"){
document.title = cont;
}

if(ja[cont]){
oper = open(ja[cont].href);
if(oper.readyState = 4){
var scont = oper.document.getElementById("masthead-search-term");
console.log(scont);
}
}

if(cont < 0 ){
clearInterval(opentime);
if(opener == null && location.pathname == "/view_all_playlists"){
document.title = "end";
}
}
}

opentime = setInterval(aut,2500);
}

onchange = function(){
abc();
chk_my_item();
}

onmousemove = function(){
chk = "ng";
body_color();
chk_my_item();
if(typeof(opentime) != "undefined"){
clearInterval(opentime);
}
if(typeof(closetime) != "undefined"){
clearTimeout(closetime);
}
abc();
}

onmouseover = function(){
chk = "ng";
body_color();
chk_my_item();
if(typeof(opentime) != "undefined"){
clearInterval(opentime);
}
if(typeof(closetime) != "undefined"){
clearTimeout(closetime);
}
abc();
}

onload = (function(){
chk = "ng";
abc();
chk_my_item();
chk_del_user();
if(chk == "ok" && opener.location.hostname == "www.youtube.com"){
closetime = setTimeout(close,3000);
}
setTimeout(auto_link,6000);
})()





2015年10月31日土曜日

YouTube 埋め込みプレーヤー

YouTube 埋め込みプレーヤー

nextVideo

previousVideo

playVideo

stopVideo

pauseVideo

seekTo30

mute

volumeP

volumeM

2015年10月30日金曜日

日本の税金は高いですね

日本の税金は高いですね

ランクは下がるしかないですね。残念だね

www





2015年10月26日月曜日

YouTube Player API

YouTube Player API



class player{
public function player(){
if(array_key_exists('t',$_REQUEST)
  and array_key_exists('l',$_REQUEST)
      and array_key_exists('url',$_REQUEST)){
$this->urltime = $_GET['t'];
$this->playlist = $_GET['l'];
$this->yturl = $_GET['url'];
$this->yturl_3item = $this->para($_GET['url']);
$temp = array();
foreach ($this->yturl_3item as $val){
$temp[count($temp)] = sprintf("'%s'",$val);
}
$this->list_item = '['.implode(",",$temp ).']';
$this->you_player_api($this->playlist,$this->yturl_3item[0],$this->list_item);
}else{
$this->you_player_api('PLvswSo32Xlu_tBfEDzpuFQ-lUFP1_Aq5I','_sQSXwdtxlY','["GLyYUyVH2PI","RgKAFK5djSk"]');
}
}

public function player_area(){
$div_area = sprintf('<div id = "player_area" >
<div id = "player"></div>
</div>
');
echo $div_area;
}

public function debug_show(){
echo '<pre>';
echo $this->urltime;
echo '<br>';
echo $this->playlist;
echo '<br>';
echo $this->yturl;
echo '<br>';
print_r( $this->yturl_3item);
echo $this->yturl_3item[0];
}

public function para($url){
$temp=array();
$temp2=array();
$temp=explode('=',$url);
$temp2=explode('|',$temp['1']);
return $temp2;
}

public function you_player_api($playlist,$videoid,$array_list){
$player = sprintf("
<script>
var tag = document.createElement('script');
tag.src = 'https://www.youtube.com/iframe_api';
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
var playlist = '%s';
var videoid = '%s';
var array_list = %s;
var h = '240';
var w = '320'
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: h,
width: w,
videoId: 'CNNDRO3imrs',
playerVars:{
'controls':'1',
'disablekb':'0',
'playsinline':'0'
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange,
'onError':onPlayerError
}
});
}

   function onPlayerReady(event) {
//event.target.cuePlaylist({list:'PLvswSo32Xlu9BOn94xy-Xd_mTsMIny639'});
var j = event.target.cuePlaylist({list:playlist});
console.log (j.length);
if(j.length == 0){
one_list_play(event.target);
}
}

function onPlayerStateChange(event) {
console.log('onPlayerStateChange');
console.log(player.getAvailableQualityLevels());
console.log(player.getPlaybackQuality());
event.target.setPlaybackQuality('tiny');
if(event.target.getPlayerState() === 5 ){
event.target.setSize(w,h);
var list_items = event.target.getPlaylist();
var list_index = list_items.indexOf(videoid);
if(list_index >-1 ){
//event.target.loadPlaylist({list:playlist,index:list_index,startSeconds:3});
event.target.playVideoAt(list_index);
}
if(list_index == -1 ){
//event.target.loadPlaylist({playlist:array_list});
one_list_play(event.target);
}
}
}

function one_list_play(event){
console.log('000111');
event.loadPlaylist({playlist:array_list});
}

function onPlayerError(event){
event.target.nextVideo();
console.log('onPlayerError');
}

</script>"
,$playlist,$videoid,$array_list);
echo $player;
}
}








2015年10月24日土曜日

indexOf で配列に要素が含まれるか判定

indexOf で配列に要素が含まれるか判定

function onPlayerStateChange(event) {
                   if(event.target.getPlayerState() === 5 ){
                           var list_items = event.target.getPlaylist();
                           var list_index = list_items.indexOf(videoid);
                           event.target.cuePlaylist({list:playlist,index:list_index});
                     }
           }

要素が含まれない場合 -1







2015年10月21日水曜日

cuePlaylist loadPlaylist 動画 ID と配列の利用について

cuePlaylist  loadPlaylist  動画 ID と配列の利用について

function onPlayerReady(event)
        event.target.loadPlaylist({playlist:['0rSPuLyKSGc','hXI8RQYC36Q','xxsDx55Nqfc']});
        event.target.loadPlaylist({list:'PL5l9iRZwq9Ul6s-10DMgPoc8sY3ukgbFz'});

    }



複数動画のIDでの配列を利用する場合、 パラメータは playlist を利用します。

動画リストのIDを利用する場合、 パラメータは list を利用します。

微妙に違いますが間違えると動画が再生されません。要注意です。