Guest User

theater.lua

a guest
May 22nd, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 51.78 KB | None | 0 0
  1. local _ENV = require("castl.runtime");
  2. local livestreamPlayerCallback,onYouTubePlayerReady,registerPlayer,DefaultVideo,getPlayerByType,players,theater;
  3.  
  4. getPlayerByType = (function (this, type)
  5. do return players[type]; end
  6. end);
  7. registerPlayer = (function (this, type, object)
  8. object.prototype = _new(DefaultVideo);
  9. object.prototype.type = type;
  10. object.prototype.getType = (function (this)
  11. do return this.type; end
  12. end);
  13. players[type] = object;
  14. end);
  15. onYouTubePlayerReady = (function (this, playerId)
  16. local type,player;
  17. player = theater:getPlayer();
  18. type = ((function() if _bool(player) then return player:getType();  else return player;  end end)());
  19. if _bool(((function() if _bool(player) then return (((_eq(type,"youtube")) and (_eq(type,"youtube")) or (_eq(type,"youtubelive"))) and ((_eq(type,"youtube")) and (_eq(type,"youtube")) or (_eq(type,"youtubelive"))) or (_eq(type,"kissyoutube")));  else return player;  end end)())) then
  20. player:onReady();
  21. end
  22.  
  23. end);
  24. livestreamPlayerCallback = (function (this, event, data)
  25. local player;
  26. if (_eq(event,"ready")) then
  27. player = theater:getPlayer();
  28. if _bool(((function() if _bool(player) then return (_eq(player:getType(),"livestream"));  else return player;  end end)())) then
  29. player:onReady();
  30. end
  31.  
  32. end
  33.  
  34. end);
  35. if (_eq(window.swfobject,undefined)) then
  36. window.swfobject = null;
  37. end
  38.  
  39. window.open = (function (this)
  40. do return null; end
  41. end);
  42. theater = _obj({
  43. ["VERSION"] = "1.5.0-YukiTheater",
  44. ["playerContainer"] = null,
  45. ["playerContent"] = null,
  46. ["hdPlayback"] = false,
  47. ["player"] = null,
  48. ["volume"] = 25,
  49. ["syncMaxDiff"] = 10,
  50. ["getPlayerContainer"] = (function (this)
  51. if (_eq(this.playerContainer,null)) then
  52. this.playerContainer = (_bool(document:getElementById("player-container")) and document:getElementById("player-container") or document:createElement("div"));
  53. end
  54.  
  55. do return this.playerContainer; end
  56. end),
  57. ["getPlayerContent"] = (function (this)
  58. if (_eq(this.playerContent,null)) then
  59. this.playerContent = (_bool(document:getElementById("content")) and document:getElementById("content") or document:createElement("div"));
  60. end
  61.  
  62. do return this.playerContent; end
  63. end),
  64. ["resetPlayer"] = (function (this)
  65. if _bool(this.player) then
  66. this.player:onRemove();
  67. (function () local _r = false; local _g, _s = this["_g" .. "player"], this["_s" .. "player"]; this["_g" .. "player"], this["_s" .. "player"] = nil, nil; _r = _g ~= nil or _s ~= nil;
  68. local _v = this.player; this.player = nil; return _r or _v ~= nil; end)();
  69. end
  70.  
  71. this:getPlayerContainer().innerHTML = "<div id='player'></div>";
  72. end),
  73. ["enablePlayer"] = (function (this)
  74. local content,player;
  75. player = this:getPlayerContainer();
  76. player.style.display = "block";
  77. content = this:getPlayerContent();
  78. content.style.display = "none";
  79. end),
  80. ["disablePlayer"] = (function (this)
  81. local content,player;
  82. player = this:getPlayerContainer();
  83. player.style.display = "none";
  84. this:resetPlayer();
  85. content = this:getPlayerContent();
  86. content.style.display = "block";
  87. end),
  88. ["getPlayer"] = (function (this)
  89. do return this.player; end
  90. end),
  91. ["loadVideo"] = (function (this, type, data, startTime)
  92. local playerObject,player;
  93. if ((_eq(type,null)) and (_eq(type,null)) or (_eq(data,null))) then
  94. do return end
  95. end
  96.  
  97. if (_eq(type,"")) then
  98. this:disablePlayer();
  99. do return end
  100. end
  101.  
  102. startTime = Math:max(0,startTime);
  103. player = this:getPlayer();
  104. if ((_eq(player,null)) and (_eq(player,null)) or (not _eq(player:getType(),type))) then
  105. this:resetPlayer();
  106. this:enablePlayer();
  107. playerObject = getPlayerByType(_ENV,type);
  108. if (not _eq(playerObject,null)) then
  109. this.player = _new(playerObject);
  110. else
  111. this:getPlayerContainer().innerText = "ERROR: Video type not yet implemented.";
  112. this:getPlayerContainer().style.color = "red";
  113. do return end
  114. end
  115.  
  116. end
  117.  
  118. ga(_ENV,"send","event","services","load",type);
  119. this.player:setVolume((function() if (not _eq(this.volume,null)) then return this.volume; else return 25; end end)());
  120. this.player:setStartTime((_bool(startTime) and startTime or 0));
  121. this.player:setVideo(data);
  122. console:log(((_addStr1(((_addStr1("Initializing Player: ",type)) .. " at "),startTime)) .. " seconds..."));
  123. end),
  124. ["setVolume"] = (function (this, volume)
  125. this.volume = volume;
  126. if (not _eq(this.player,null)) then
  127. this.player:setVolume(volume);
  128. end
  129.  
  130. end),
  131. ["seek"] = (function (this, seconds)
  132. local player;
  133. player = this:getPlayer();
  134. if _bool(player) then
  135. player:seek(seconds);
  136. end
  137.  
  138. end),
  139. ["setForceVideoRes"] = (function (this, bool)
  140. if (not _eq(this.forceVideoRes,bool)) then
  141. this.forceVideoRes = bool;
  142. console:log(((_addStr1("forceVideoRes set to ",bool)) .. "!"));
  143. end
  144.  
  145. end),
  146. ["isForceVideoRes"] = (function (this)
  147. do return this.forceVideoRes; end
  148. end),
  149. ["sync"] = (function (this, time)
  150. local current;
  151. if (_eq(time,null)) then
  152. do return end
  153. end
  154.  
  155. if (not _eq(this.player,null)) then
  156. current = this.player:getCurrentTime();
  157. if ((function() if (not _eq(current,null)) then return (_gt(Math:abs((time - current)),this.syncMaxDiff));  else return (not _eq(current,null));  end end)()) then
  158. this.player:setStartTime(time);
  159. console:log(((_addStr1("Attempting to sync player to ",time)) .. " seconds..."));
  160. end
  161.  
  162. end
  163.  
  164. end),
  165. ["toggleControls"] = (function (this, enabled)
  166. if (not _eq(this.player,null)) then
  167. this.player:toggleControls(enabled);
  168. end
  169.  
  170. end),
  171. ["enableCC"] = (function (this)
  172. this.closedCaptions = true;
  173. end),
  174. ["isCCEnabled"] = (function (this)
  175. do return this.closedCaptions; end
  176. end)
  177. });
  178. players = _arr({},0);
  179. DefaultVideo = (function (this)
  180.  
  181. end);
  182. DefaultVideo.prototype = _obj({
  183. ["player"] = null,
  184. ["lastVideoId"] = null,
  185. ["videoId"] = null,
  186. ["lastVolume"] = null,
  187. ["volume"] = 0.123,
  188. ["currentTime"] = 0,
  189. ["getCurrentTime"] = (function (this)
  190. do return null; end
  191. end),
  192. ["lastStartTime"] = 0,
  193. ["startTime"] = 0,
  194. ["setVolume"] = (function (this, volume)
  195.  
  196. end),
  197. ["setStartTime"] = (function (this, seconds)
  198.  
  199. end),
  200. ["seek"] = (function (this, seconds)
  201.  
  202. end),
  203. ["onRemove"] = (function (this)
  204.  
  205. end),
  206. ["toggleControls"] = (function (this)
  207.  
  208. end)
  209. });
  210. (function (this)
  211. local Hitbox,HitboxLive,Dailymotion,KissYT,Kiss,YukiTheaterRTMP,UstreamLiveVideo,HtmlVideo,UrlVideo,TwitchStreamVideo,TwitchVideo,VimeoVideo,YouTubeLiveVideo,YouTubeVideo;
  212. YouTubeVideo = (function (this)
  213. local url,attributes,params;
  214. params = _obj({
  215. ["allowScriptAccess"] = "always",
  216. ["bgcolor"] = "#000000",
  217. ["wmode"] = "opaque"
  218. });
  219. attributes = _obj({
  220. ["id"] = "player"
  221. });
  222. url = "https://www.youtube.com/get_player?enablejsapi=1&modestbranding=1&autohide=1&controls=1&autoplay=1&iv_load_policy=3";
  223. if _bool(theater:isCCEnabled()) then
  224. url = (_addStr2(url,"&cc_load_policy=1"));
  225. url = (_addStr2(url,"&yt:cc=on"));
  226. end
  227.  
  228. swfobject:embedSWF(url,"player","100%","100%","9",null,null,params,attributes);
  229. this.setVideo = (function (this, id)
  230. this.lastStartTime = null;
  231. this.lastVideoId = null;
  232. this.videoId = id;
  233. end);
  234. this.setVolume = (function (this, volume)
  235. this.lastVolume = null;
  236. this.volume = volume;
  237. end);
  238. this.setStartTime = (function (this, seconds)
  239. this.lastStartTime = null;
  240. this.startTime = seconds;
  241. end);
  242. this.seek = (function (this, seconds)
  243. if (not _eq(this.player,null)) then
  244. this.player:seekTo(seconds,true);
  245. if (not _eq(this.player:getPlayerState(),1)) then
  246. this.player:playVideo();
  247. end
  248.  
  249. end
  250.  
  251. end);
  252. this.onRemove = (function (this)
  253. clearInterval(_ENV,this.interval);
  254. end);
  255. this.getCurrentTime = (function (this)
  256. if (not _eq(this.player,null)) then
  257. do return this.player:getCurrentTime(); end
  258. end
  259.  
  260. end);
  261. this.canChangeTime = (function (this)
  262. if (not _eq(this.player,null)) then
  263. do return ((function() if (not _eq(this.player:getVideoBytesTotal(),-1)) then return (not _eq(this.player:getPlayerState(),3));  else return (not _eq(this.player:getVideoBytesTotal(),-1));  end end)()); end
  264. end
  265.  
  266. end);
  267. this.think = (function (this)
  268. if (not _eq(this.player,null)) then
  269. if _bool(theater:isForceVideoRes()) then
  270. if (not _eq(this.lastWindowHeight,window.innerHeight)) then
  271. if ((function() if (_le(window.innerHeight,1536)) then return (_gt(window.innerHeight,1440));  else return (_le(window.innerHeight,1536));  end end)()) then
  272. this.ytforceres = "highres";
  273. end
  274.  
  275. if ((function() if (_le(window.innerHeight,1440)) then return (_gt(window.innerHeight,1080));  else return (_le(window.innerHeight,1440));  end end)()) then
  276. this.ytforceres = "highres";
  277. end
  278.  
  279. if ((function() if (_le(window.innerHeight,1080)) then return (_gt(window.innerHeight,720));  else return (_le(window.innerHeight,1080));  end end)()) then
  280. this.ytforceres = "hd1080";
  281. end
  282.  
  283. if ((function() if (_le(window.innerHeight,720)) then return (_gt(window.innerHeight,480));  else return (_le(window.innerHeight,720));  end end)()) then
  284. this.ytforceres = "hd720";
  285. end
  286.  
  287. if ((function() if (_le(window.innerHeight,480)) then return (_gt(window.innerHeight,360));  else return (_le(window.innerHeight,480));  end end)()) then
  288. this.ytforceres = "large";
  289. end
  290.  
  291. if ((function() if (_le(window.innerHeight,360)) then return (_gt(window.innerHeight,240));  else return (_le(window.innerHeight,360));  end end)()) then
  292. this.ytforceres = "medium";
  293. end
  294.  
  295. if (_le(window.innerHeight,240)) then
  296. this.ytforceres = "small";
  297. end
  298.  
  299. this.player:setPlaybackQuality(this.ytforceres);
  300. console:log((_addStr1("Forcing Quality Change to ",this.ytforceres)));
  301. this.lastWindowHeight = window.innerHeight;
  302. end
  303.  
  304. end
  305.  
  306. if (not _eq(this.videoId,this.lastVideoId)) then
  307. this.player:loadVideoById(this.videoId,this.startTime,(function() if _bool(this.ytforceres) then return this.ytforceres; else return "default"; end end)());
  308. this.lastVideoId = this.videoId;
  309. this.lastStartTime = this.startTime;
  310. end
  311.  
  312. if (not _eq(this.player:getPlayerState(),-1)) then
  313. if (not _eq(this.startTime,this.lastStartTime)) then
  314. this:seek(this.startTime);
  315. this.lastStartTime = this.startTime;
  316. end
  317.  
  318. if (not _eq(this.volume,this.lastVolume)) then
  319. this.player:setVolume(this.volume);
  320. this.lastVolume = this.volume;
  321. end
  322.  
  323. end
  324.  
  325. end
  326.  
  327. end);
  328. this.onReady = (function (this)
  329. this.player = document:getElementById("player");
  330. if _bool(theater:isForceVideoRes()) then
  331. if ((function() if (_le(window.innerHeight,1536)) then return (_gt(window.innerHeight,1440));  else return (_le(window.innerHeight,1536));  end end)()) then
  332. this.ytforceres = "highres";
  333. end
  334.  
  335. if ((function() if (_le(window.innerHeight,1440)) then return (_gt(window.innerHeight,1080));  else return (_le(window.innerHeight,1440));  end end)()) then
  336. this.ytforceres = "highres";
  337. end
  338.  
  339. if ((function() if (_le(window.innerHeight,1080)) then return (_gt(window.innerHeight,720));  else return (_le(window.innerHeight,1080));  end end)()) then
  340. this.ytforceres = "hd1080";
  341. end
  342.  
  343. if ((function() if (_le(window.innerHeight,720)) then return (_gt(window.innerHeight,480));  else return (_le(window.innerHeight,720));  end end)()) then
  344. this.ytforceres = "hd720";
  345. end
  346.  
  347. if ((function() if (_le(window.innerHeight,480)) then return (_gt(window.innerHeight,360));  else return (_le(window.innerHeight,480));  end end)()) then
  348. this.ytforceres = "large";
  349. end
  350.  
  351. if ((function() if (_le(window.innerHeight,360)) then return (_gt(window.innerHeight,240));  else return (_le(window.innerHeight,360));  end end)()) then
  352. this.ytforceres = "medium";
  353. end
  354.  
  355. if (_le(window.innerHeight,240)) then
  356. this.ytforceres = "small";
  357. end
  358.  
  359. this.player:setPlaybackQuality(this.ytforceres);
  360. console:log((_addStr1("Forcing Quality Change to ",this.ytforceres)));
  361. end
  362.  
  363. this.interval = setInterval(_ENV,this.think:bind(this),100);
  364. end);
  365. end);
  366. registerPlayer(_ENV,"youtube",YouTubeVideo);
  367. YouTubeLiveVideo = (function (this)
  368. local player;
  369. this.setVideo = (function (this, id)
  370. this.lastStartTime = null;
  371. this.lastVideoId = null;
  372. this.videoId = id;
  373. if _bool(player) then
  374. do return end
  375. end
  376.  
  377. player = _new(YT.Player,"player",_obj({
  378. ["height"] = "100%",
  379. ["width"] = "100%",
  380. ["videoId"] = id,
  381. ["playerVars"] = _obj({
  382. ["autoplay"] = 1,
  383. ["controls"] = 1,
  384. ["autohide"] = 1,
  385. ["iv_load_policy"] = 3,
  386. ["cc_load_policy"] = (function() if _bool(theater.closedCaptions) then return 1; else return 0; end end)()
  387. }),
  388. ["events"] = _obj({
  389. ["onReady"] = onYouTubePlayerReady
  390. })
  391. }));
  392. end);
  393. this.setVolume = (function (this, volume)
  394. this.lastVolume = null;
  395. this.volume = volume;
  396. end);
  397. this.setStartTime = (function (this, seconds)
  398. this.lastStartTime = null;
  399. this.startTime = seconds;
  400. end);
  401. this.seek = (function (this, seconds)
  402. if (this.player ~= null) then
  403. this.player:seekTo(seconds,true);
  404. if (not _eq(this.player:getPlayerState(),1)) then
  405. this.player:playVideo();
  406. end
  407.  
  408. end
  409.  
  410. end);
  411. this.onRemove = (function (this)
  412. clearInterval(_ENV,this.interval);
  413. end);
  414. this.getCurrentTime = (function (this)
  415. if (this.player ~= null) then
  416. do return this.player:getCurrentTime(); end
  417. end
  418.  
  419. end);
  420. this.canChangeTime = (function (this)
  421. if (this.player ~= null) then
  422. do return ((function() if (not _eq(this.player:getVideoBytesTotal(),-1)) then return (not _eq(this.player:getPlayerState(),3));  else return (not _eq(this.player:getVideoBytesTotal(),-1));  end end)()); end
  423. end
  424.  
  425. end);
  426. this.think = (function (this)
  427. if (this.player ~= null) then
  428. if _bool(theater:isForceVideoRes()) then
  429. if (not _eq(this.lastWindowHeight,window.innerHeight)) then
  430. if ((function() if (_le(window.innerHeight,1536)) then return (_gt(window.innerHeight,1440));  else return (_le(window.innerHeight,1536));  end end)()) then
  431. this.ytforceres = "highres";
  432. end
  433.  
  434. if ((function() if (_le(window.innerHeight,1440)) then return (_gt(window.innerHeight,1080));  else return (_le(window.innerHeight,1440));  end end)()) then
  435. this.ytforceres = "highres";
  436. end
  437.  
  438. if ((function() if (_le(window.innerHeight,1080)) then return (_gt(window.innerHeight,720));  else return (_le(window.innerHeight,1080));  end end)()) then
  439. this.ytforceres = "hd1080";
  440. end
  441.  
  442. if ((function() if (_le(window.innerHeight,720)) then return (_gt(window.innerHeight,480));  else return (_le(window.innerHeight,720));  end end)()) then
  443. this.ytforceres = "hd720";
  444. end
  445.  
  446. if ((function() if (_le(window.innerHeight,480)) then return (_gt(window.innerHeight,360));  else return (_le(window.innerHeight,480));  end end)()) then
  447. this.ytforceres = "large";
  448. end
  449.  
  450. if ((function() if (_le(window.innerHeight,360)) then return (_gt(window.innerHeight,240));  else return (_le(window.innerHeight,360));  end end)()) then
  451. this.ytforceres = "medium";
  452. end
  453.  
  454. if (_le(window.innerHeight,240)) then
  455. this.ytforceres = "small";
  456. end
  457.  
  458. this.player:setPlaybackQuality(this.ytforceres);
  459. console:log((_addStr1("Forcing Quality Change to ",this.ytforceres)));
  460. this.lastWindowHeight = window.innerHeight;
  461. end
  462.  
  463. end
  464.  
  465. if (not _eq(this.videoId,this.lastVideoId)) then
  466. this.player:loadVideoById(this.videoId,this.startTime,(function() if _bool(this.ytforceres) then return this.ytforceres; else return "default"; end end)());
  467. this.lastVideoId = this.videoId;
  468. this.lastStartTime = this.startTime;
  469. end
  470.  
  471. if (not _eq(this.player:getPlayerState(),-1)) then
  472. if (not _eq(this.startTime,this.lastStartTime)) then
  473. this:seek(this.startTime);
  474. this.lastStartTime = this.startTime;
  475. end
  476.  
  477. if (not _eq(this.volume,this.lastVolume)) then
  478. this.player:setVolume(this.volume);
  479. this.lastVolume = this.volume;
  480. end
  481.  
  482. end
  483.  
  484. end
  485.  
  486. end);
  487. this.onReady = (function (this)
  488. this.player = player;
  489. if _bool(theater:isForceVideoRes()) then
  490. if ((function() if (_le(window.innerHeight,1536)) then return (_gt(window.innerHeight,1440));  else return (_le(window.innerHeight,1536));  end end)()) then
  491. this.ytforceres = "highres";
  492. end
  493.  
  494. if ((function() if (_le(window.innerHeight,1440)) then return (_gt(window.innerHeight,1080));  else return (_le(window.innerHeight,1440));  end end)()) then
  495. this.ytforceres = "highres";
  496. end
  497.  
  498. if ((function() if (_le(window.innerHeight,1080)) then return (_gt(window.innerHeight,720));  else return (_le(window.innerHeight,1080));  end end)()) then
  499. this.ytforceres = "hd1080";
  500. end
  501.  
  502. if ((function() if (_le(window.innerHeight,720)) then return (_gt(window.innerHeight,480));  else return (_le(window.innerHeight,720));  end end)()) then
  503. this.ytforceres = "hd720";
  504. end
  505.  
  506. if ((function() if (_le(window.innerHeight,480)) then return (_gt(window.innerHeight,360));  else return (_le(window.innerHeight,480));  end end)()) then
  507. this.ytforceres = "large";
  508. end
  509.  
  510. if ((function() if (_le(window.innerHeight,360)) then return (_gt(window.innerHeight,240));  else return (_le(window.innerHeight,360));  end end)()) then
  511. this.ytforceres = "medium";
  512. end
  513.  
  514. if (_le(window.innerHeight,240)) then
  515. this.ytforceres = "small";
  516. end
  517.  
  518. this.player:setPlaybackQuality(this.ytforceres);
  519. console:log((_addStr1("Forcing Quality Change to ",this.ytforceres)));
  520. end
  521.  
  522. this.interval = setInterval(_ENV,this.think:bind(this),100);
  523. end);
  524. end);
  525. registerPlayer(_ENV,"youtubelive",YouTubeLiveVideo);
  526. VimeoVideo = (function (this)
  527. local self;
  528. self = this;
  529. this.froogaloop = null;
  530. this.setVideo = (function (this, id)
  531. local frame,url,elem;
  532. this.videoId = id;
  533. elem = document:getElementById("player1");
  534. if _bool(elem) then
  535. Sf(_ENV,elem):removeEvent("ready");
  536. this.froogaloop = null;
  537. elem.parentNode:removeChild(elem);
  538. end
  539.  
  540. url = ((_addStr1("https://player.vimeo.com/video/",id)) .. "?api=1&player_id=player1");
  541. frame = document:createElement("iframe");
  542. frame:setAttribute("id","player1");
  543. frame:setAttribute("src",url);
  544. frame:setAttribute("width","100%");
  545. frame:setAttribute("height","100%");
  546. frame:setAttribute("frameborder","0");
  547. document:getElementById("player"):appendChild(frame);
  548. Sf(_ENV,frame):addEvent("ready",this.onReady);
  549. end);
  550. this.setVolume = (function (this, volume)
  551. this.lastVolume = null;
  552. this.volume = (volume / 100);
  553. end);
  554. this.setStartTime = (function (this, seconds)
  555. this.lastStartTime = null;
  556. this.startTime = Math:max(1,seconds);
  557. end);
  558. this.seek = (function (this, seconds)
  559. if ((function() if (not _eq(this.froogaloop,null)) then return (_gt(seconds,1));  else return (not _eq(this.froogaloop,null));  end end)()) then
  560. this.froogaloop:api("pause");
  561. this.froogaloop:api("seekTo",seconds);
  562. this.froogaloop:api("play");
  563. end
  564.  
  565. end);
  566. this.onRemove = (function (this)
  567. this.froogaloop = null;
  568. clearInterval(_ENV,this.interval);
  569. end);
  570. this.getCurrentTime = (function (this)
  571. if (not _eq(this.froogaloop,null)) then
  572. do return (_bool(self.currentTime) and self.currentTime or 1); end
  573. end
  574.  
  575. end);
  576. this.think = (function (this)
  577. if (not _eq(this.froogaloop,null)) then
  578. if (not _eq(this.volume,this.lastVolume)) then
  579. this.froogaloop:api("setVolume",this.volume);
  580. this.lastVolume = this.volume;
  581. end
  582.  
  583. if (not _eq(this.startTime,this.lastStartTime)) then
  584. this:seek(this.startTime);
  585. this.lastStartTime = this.startTime;
  586. end
  587.  
  588. this.froogaloop:api("getVolume",(function (this, v)
  589. self.volume = parseFloat(_ENV,v);
  590. end));
  591. this.froogaloop:api("getCurrentTime",(function (this, v)
  592. self.currentTime = parseFloat(_ENV,v);
  593. end));
  594. end
  595.  
  596. end);
  597. this.onReady = (function (this, player__id)
  598. self.lastStartTime = null;
  599. self.froogaloop = Sf(_ENV,player__id);
  600. self.froogaloop:api("play");
  601. setTimeout(_ENV,(function (this)
  602. self.interval = setInterval(_ENV,(function (this)
  603. self:think(self);
  604. end),100);
  605. end),2500);
  606. end);
  607. end);
  608. registerPlayer(_ENV,"vimeo",VimeoVideo);
  609. TwitchVideo = (function (this)
  610. local self;
  611. self = this;
  612. this.videoInfo = _obj({});
  613. this.embed = (function (this)
  614. local params,swfurl,videoType,id,flashvars;
  615. if not _bool(this.videoInfo.channel) then
  616. do return end
  617. end
  618.  
  619. if not _bool(this.videoInfo["archive_id"]) then
  620. do return end
  621. end
  622.  
  623. flashvars = _obj({
  624. ["hostname"] = "www.twitch.tv",
  625. ["channel"] = this.videoInfo.channel,
  626. ["auto_play"] = true,
  627. ["start_volume"] = (_bool(this.videoInfo.volume) and this.videoInfo.volume or theater.volume),
  628. ["initial_time"] = (_bool(this.videoInfo["initial_time"]) and this.videoInfo["initial_time"] or 0)
  629. });
  630. id = this.videoInfo["archive_id"]:slice(1);
  631. videoType = this.videoInfo["archive_id"]:substr(0,1);
  632. flashvars.videoId = (_add(videoType,id));
  633. if (_eq(videoType,"c")) then
  634. flashvars["chapter_id"] = id;
  635. else
  636. flashvars["archive_id"] = id;
  637. end
  638.  
  639. swfurl = "https://www.twitch.tv/swflibs/TwitchPlayer.swf";
  640. params = _obj({
  641. ["allowFullScreen"] = "true",
  642. ["allowNetworking"] = "all",
  643. ["allowScriptAccess"] = "always",
  644. ["movie"] = swfurl,
  645. ["wmode"] = "opaque",
  646. ["bgcolor"] = "#000000"
  647. });
  648. swfobject:embedSWF(swfurl,"player","100%","104%","9.0.0",false,flashvars,params);
  649. end);
  650. this.setVideo = (function (this, id)
  651. local interval,i,info;
  652. this.lastVideoId = null;
  653. this.videoId = id;
  654. info = id:split(",");
  655. this.videoInfo.channel = info[0];
  656. this.videoInfo["archive_id"] = info[1];
  657. if (_eq(this.player,null)) then
  658. this.lastVideoId = this.videoId;
  659. this:embed();
  660. i = 0;
  661. interval = setInterval(_ENV,(function (this)
  662. local el;
  663. el = document:getElementById("player");
  664. if _bool(el.mute) then
  665. clearInterval(_ENV,interval);
  666. self:onReady();
  667. end
  668.  
  669. i = _inc(i);
  670. if (_gt(i,100)) then
  671. console:log("Error waiting for player to load");
  672. clearInterval(_ENV,interval);
  673. end
  674.  
  675. end),33);
  676. end
  677.  
  678. end);
  679. this.setVolume = (function (this, volume)
  680. this.lastVolume = null;
  681. this.volume = volume;
  682. this.videoInfo.volume = volume;
  683. end);
  684. this.setStartTime = (function (this, seconds)
  685. this.lastStartTime = null;
  686. this.startTime = seconds;
  687. this.videoInfo["initial_time"] = seconds;
  688. end);
  689. this.seek = (function (this, seconds)
  690. this:setStartTime(seconds);
  691. end);
  692. this.onRemove = (function (this)
  693. clearInterval(_ENV,this.interval);
  694. end);
  695. this.think = (function (this)
  696. if _bool(this.player) then
  697. if (not _eq(this.videoId,this.lastVideoId)) then
  698. this:embed();
  699. this.lastVideoId = this.videoId;
  700. end
  701.  
  702. if (not _eq(this.startTime,this.lastStartTime)) then
  703. this:embed();
  704. this.lastStartTime = this.startTime;
  705. end
  706.  
  707. if (not _eq(this.volume,this.lastVolume)) then
  708. this.lastVolume = this.volume;
  709. end
  710.  
  711. end
  712.  
  713. end);
  714. this.onReady = (function (this)
  715. this.player = document:getElementById("player");
  716. this.interval = setInterval(_ENV,(function (this)
  717. self:think(self);
  718. end),100);
  719. end);
  720. this.toggleControls = (function (this, enabled)
  721. this.player.height = (function() if _bool(enabled) then return "100%"; else return "104%"; end end)();
  722. end);
  723. end);
  724. registerPlayer(_ENV,"twitch",TwitchVideo);
  725. TwitchStreamVideo = (function (this)
  726. local self;
  727. self = this;
  728. this.embed = (function (this)
  729. local params,swfurl,flashvars;
  730. flashvars = _obj({
  731. ["hostname"] = "www.twitch.tv",
  732. ["hide_chat"] = true,
  733. ["channel"] = this.videoId,
  734. ["embed"] = 0,
  735. ["auto_play"] = true,
  736. ["start_volume"] = (_bool((_bool(this.volume) and this.volume or theater.volume)) and (_bool(this.volume) and this.volume or theater.volume) or 25)
  737. });
  738. swfurl = "https://www.twitch.tv/swflibs/TwitchPlayer.swf";
  739. params = _obj({
  740. ["allowFullScreen"] = "true",
  741. ["allowNetworking"] = "all",
  742. ["allowScriptAccess"] = "always",
  743. ["movie"] = swfurl,
  744. ["wmode"] = "opaque",
  745. ["bgcolor"] = "#000000"
  746. });
  747. swfobject:embedSWF(swfurl,"player","100%","104%","9.0.0",false,flashvars,params);
  748. end);
  749. this.setVideo = (function (this, id)
  750. local interval,i;
  751. this.lastVideoId = null;
  752. this.videoId = id;
  753. if (_eq(this.player,null)) then
  754. this.lastVideoId = this.videoId;
  755. this:embed();
  756. i = 0;
  757. interval = setInterval(_ENV,(function (this)
  758. local el;
  759. el = document:getElementById("player");
  760. if _bool(el.mute) then
  761. clearInterval(_ENV,interval);
  762. self:onReady();
  763. end
  764.  
  765. i = _inc(i);
  766. if (_gt(i,100)) then
  767. console:log("Error waiting for player to load");
  768. clearInterval(_ENV,interval);
  769. end
  770.  
  771. end),33);
  772. end
  773.  
  774. end);
  775. this.setVolume = (function (this, volume)
  776. this.lastVolume = null;
  777. this.volume = volume;
  778. end);
  779. this.onRemove = (function (this)
  780. clearInterval(_ENV,this.interval);
  781. end);
  782. this.think = (function (this)
  783. if _bool(this.player) then
  784. if (not _eq(this.videoId,this.lastVideoId)) then
  785. this:embed();
  786. this.lastVideoId = this.videoId;
  787. end
  788.  
  789. if (not _eq(this.volume,this.lastVolume)) then
  790. this.lastVolume = this.volume;
  791. end
  792.  
  793. end
  794.  
  795. end);
  796. this.onReady = (function (this)
  797. this.player = document:getElementById("player");
  798. this.interval = setInterval(_ENV,(function (this)
  799. self:think(self);
  800. end),100);
  801. end);
  802. this.toggleControls = (function (this, enabled)
  803. this.player.height = (function() if _bool(enabled) then return "100%"; else return "104%"; end end)();
  804. end);
  805. end);
  806. registerPlayer(_ENV,"twitchstream",TwitchStreamVideo);
  807. UrlVideo = (function (this)
  808. local self;
  809. self = this;
  810. this.embed = (function (this)
  811. local frame,elem;
  812. elem = document:getElementById("player1");
  813. if _bool(elem) then
  814. elem.parentNode:removeChild(elem);
  815. end
  816.  
  817. frame = document:createElement("iframe");
  818. frame:setAttribute("id","player1");
  819. frame:setAttribute("src",this.videoId);
  820. frame:setAttribute("width","100%");
  821. frame:setAttribute("height","100%");
  822. frame:setAttribute("frameborder","0");
  823. document:getElementById("player"):appendChild(frame);
  824. end);
  825. this.setVideo = (function (this, id)
  826. local interval,i;
  827. this.lastVideoId = null;
  828. this.videoId = id;
  829. if (_eq(this.player,null)) then
  830. this.lastVideoId = this.videoId;
  831. this:embed();
  832. i = 0;
  833. interval = setInterval(_ENV,(function (this)
  834. local el;
  835. el = document:getElementById("player");
  836. if _bool(el) then
  837. clearInterval(_ENV,interval);
  838. self:onReady();
  839. end
  840.  
  841. i = _inc(i);
  842. if (_gt(i,100)) then
  843. console:log("Error waiting for player to load");
  844. clearInterval(_ENV,interval);
  845. end
  846.  
  847. end),33);
  848. end
  849.  
  850. end);
  851. this.onRemove = (function (this)
  852. clearInterval(_ENV,this.interval);
  853. end);
  854. this.think = (function (this)
  855. if _bool(this.player) then
  856. if (not _eq(this.videoId,this.lastVideoId)) then
  857. this:embed();
  858. this.lastVideoId = this.videoId;
  859. end
  860.  
  861. end
  862.  
  863. end);
  864. this.onReady = (function (this)
  865. this.player = document:getElementById("player");
  866. this.interval = setInterval(_ENV,(function (this)
  867. self:think(self);
  868. end),100);
  869. end);
  870. end);
  871. registerPlayer(_ENV,"url",UrlVideo);
  872. HtmlVideo = (function (this)
  873. this.embed = (function (this)
  874. local content,elem;
  875. elem = document:getElementById("player1");
  876. if _bool(elem) then
  877. elem.parentNode:removeChild(elem);
  878. end
  879.  
  880. content = document:createElement("div");
  881. content:setAttribute("id","player1");
  882. content.style.width = "100%";
  883. content.style.height = "100%";
  884. content.innerHTML = this.videoId;
  885. document:getElementById("player"):appendChild(content);
  886. end);
  887. this.setVideo = (function (this, id)
  888. this.lastVideoId = null;
  889. this.videoId = id;
  890. this:embed();
  891. end);
  892. end);
  893. registerPlayer(_ENV,"html",HtmlVideo);
  894. UstreamLiveVideo = (function (this)
  895. local self,viewer,player__container,pre__player;
  896. pre__player = document:createElement("iframe");
  897. pre__player.src = "https://www.ustream.tv/embed/1?controls=false";
  898. pre__player.id = "player";
  899. pre__player.width = "100%";
  900. pre__player.height = "100%";
  901. player__container = document:getElementById("player").parentNode;
  902. player__container:removeChild(document:getElementById("player"));
  903. player__container:appendChild(pre__player);
  904. viewer = UstreamEmbed(_ENV,"player");
  905. this.setVideo = (function (this, id)
  906. this.lastVideoId = null;
  907. this.videoId = id;
  908. end);
  909. this.setVolume = (function (this, volume)
  910. this.lastVolume = null;
  911. this.volume = volume;
  912. end);
  913. this.onRemove = (function (this)
  914. clearInterval(_ENV,this.interval);
  915. end);
  916. this.think = (function (this)
  917. local self;
  918. if (not _eq(this.player,null)) then
  919. if (not _eq(this.videoId,this.lastVideoId)) then
  920. this.player:callMethod("load","channel",this.videoId);
  921. self = this;
  922. setTimeout(_ENV,(function (this)
  923. self.player:callMethod("play");
  924. end),3000);
  925. setTimeout(_ENV,(function (this)
  926. if _bool(theater:isForceVideoRes()) then
  927. if ((function() if (_le(window.innerHeight,1536)) then return (_gt(window.innerHeight,1440));  else return (_le(window.innerHeight,1536));  end end)()) then
  928. this.player:callMethod("quality",16);
  929. end
  930.  
  931. if ((function() if (_le(window.innerHeight,1440)) then return (_gt(window.innerHeight,1080));  else return (_le(window.innerHeight,1440));  end end)()) then
  932. this.player:callMethod("quality",16);
  933. end
  934.  
  935. if ((function() if (_le(window.innerHeight,1080)) then return (_gt(window.innerHeight,720));  else return (_le(window.innerHeight,1080));  end end)()) then
  936. this.player:callMethod("quality",16);
  937. end
  938.  
  939. if ((function() if (_le(window.innerHeight,720)) then return (_gt(window.innerHeight,480));  else return (_le(window.innerHeight,720));  end end)()) then
  940. this.player:callMethod("quality",16);
  941. end
  942.  
  943. if ((function() if (_le(window.innerHeight,480)) then return (_gt(window.innerHeight,360));  else return (_le(window.innerHeight,480));  end end)()) then
  944. this.player:callMethod("quality",2);
  945. end
  946.  
  947. if ((function() if (_le(window.innerHeight,360)) then return (_gt(window.innerHeight,240));  else return (_le(window.innerHeight,360));  end end)()) then
  948. this.player:callMethod("quality",1);
  949. end
  950.  
  951. if (_le(window.innerHeight,240)) then
  952. this.player:callMethod("quality",0);
  953. end
  954.  
  955. end
  956.  
  957. end),5000);
  958. this.lastVideoId = this.videoId;
  959. end
  960.  
  961. if (not _eq(this.volume,this.lastVolume)) then
  962. this.player:callMethod("volume",(function() if (_lt(this.volume,100)) then return this.volume; else return 99; end end)());
  963. this.lastVolume = this.volume;
  964. end
  965.  
  966. end
  967.  
  968. end);
  969. this.onReady = (function (this)
  970. local self;
  971. this.player = viewer;
  972. self = this;
  973. this.interval = setInterval(_ENV,(function (this)
  974. self:think(self);
  975. end),100);
  976. end);
  977. self = this;
  978. setTimeout(_ENV,(function (this)
  979. self:onReady();
  980. end),2000);
  981. end);
  982. registerPlayer(_ENV,"ustreamlive",UstreamLiveVideo);
  983. YukiTheaterRTMP = (function (this)
  984. local self,viewer,player__container,pre__player;
  985. videojs.options.flash.swf = "video-js-5.9.2/video-js.swf";
  986. pre__player = document:createElement("video");
  987. pre__player.className = "video-js vjs-default-skin";
  988. pre__player.id = "player";
  989. pre__player.preload = "auto";
  990. pre__player.autoplay = "true";
  991. player__container = document:getElementById("player").parentNode;
  992. player__container:removeChild(document:getElementById("player"));
  993. player__container:appendChild(pre__player);
  994. viewer = videojs(_ENV,"player");
  995. viewer:poster("http://www.yukitheater.org/theater/rtmp-thumbnail.png");
  996. this.setVideo = (function (this, id)
  997. this.lastVideoId = null;
  998. this.videoId = id;
  999. end);
  1000. this.setVolume = (function (this, volume)
  1001. this.lastVolume = null;
  1002. this.volume = (volume / 100);
  1003. end);
  1004. this.onRemove = (function (this)
  1005. clearInterval(_ENV,this.interval);
  1006. end);
  1007. this.think = (function (this)
  1008. local curTime;
  1009. if (not _eq(this.player,null)) then
  1010. if (not _eq(this.videoId,this.lastVideoId)) then
  1011. this.player:src(_obj({
  1012. ["type"] = "rtmp/mp4",
  1013. ["src"] = ((_addStr1("rtmp://rtmp.yukitheater.org/live/",this.videoId)) .. "/")
  1014. }));
  1015. this.lastVideoId = this.videoId;
  1016. this.lastSrcChange = (_addNum2(Math:round((Date:now() / 1000)),5));
  1017. end
  1018.  
  1019. if (not _eq(this.lastSrcChange,"undefined")) then
  1020. curTime = Math:round((Date:now() / 1000));
  1021. if ((function() if (_ge(curTime,this.lastSrcChange)) then return (this.player:readyState() == 0);  else return (_ge(curTime,this.lastSrcChange));  end end)()) then
  1022. console:log("Attempt to load RTMP Stream Failed! Retrying...");
  1023. this.player:src(_obj({
  1024. ["type"] = "rtmp/mp4",
  1025. ["src"] = ((_addStr1("rtmp://rtmp.yukitheater.org/live/",this.videoId)) .. "/")
  1026. }));
  1027. this.lastSrcChange = (_addNum2(Math:round((Date:now() / 1000)),5));
  1028. end
  1029.  
  1030. end
  1031.  
  1032. if (not _eq(this.volume,this.lastVolume)) then
  1033. this.player:volume(this.volume);
  1034. this.lastVolume = this.volume;
  1035. end
  1036.  
  1037. end
  1038.  
  1039. end);
  1040. this.onReady = (function (this)
  1041. local self;
  1042. this.player = viewer;
  1043. self = this;
  1044. this.interval = setInterval(_ENV,(function (this)
  1045. self:think(self);
  1046. end),100);
  1047. end);
  1048. this.toggleControls = (function (this, enabled)
  1049. this.player:controls(enabled);
  1050. end);
  1051. self = this;
  1052. viewer:ready((function (this)
  1053. self:onReady();
  1054. end));
  1055. end);
  1056. registerPlayer(_ENV,"yukirtmp",YukiTheaterRTMP);
  1057. Kiss = (function (this)
  1058. local self,viewer;
  1059. jwplayer.key = "GBbtI9R8M4R2gQOTSs7m7AdoMdxpK3DD4IcgmQ==";
  1060. viewer = jwplayer(_ENV,"player");
  1061. viewer:setup(_obj({
  1062. ["height"] = "100%",
  1063. ["width"] = "100%",
  1064. ["controls"] = false,
  1065. ["autostart"] = true,
  1066. ["primary"] = "flash",
  1067. ["displaytitle"] = true,
  1068. ["file"] = "example.mp4"
  1069. }));
  1070. this.setVideo = (function (this, id)
  1071. this.lastStartTime = null;
  1072. this.lastVideoId = null;
  1073. this.videoId = id;
  1074. this.sentKissDuration = false;
  1075. this.initSeek = false;
  1076. end);
  1077. this.setVolume = (function (this, volume)
  1078. this.lastVolume = null;
  1079. this.volume = volume;
  1080. end);
  1081. this.setStartTime = (function (this, seconds)
  1082. this.lastStartTime = null;
  1083. this.startTime = seconds;
  1084. end);
  1085. this.seek = (function (this, seconds)
  1086. if (not _eq(this.player,null)) then
  1087. this.player:seek(seconds);
  1088. if ((_eq(this.player:getState(),"paused")) and (_eq(this.player:getState(),"paused")) or (_eq(this.player:getState(),"idle"))) then
  1089. this.player:play(true);
  1090. end
  1091.  
  1092. end
  1093.  
  1094. end);
  1095. this.onRemove = (function (this)
  1096. clearInterval(_ENV,this.interval);
  1097. end);
  1098. this.getCurrentTime = (function (this)
  1099. if (not _eq(this.player,null)) then
  1100. do return this.player:getPosition(); end
  1101. end
  1102.  
  1103. end);
  1104. this.canChangeTime = (function (this)
  1105. if (not _eq(this.player,null)) then
  1106. do return (not _eq(this.player:getState(),"buffering")); end
  1107. end
  1108.  
  1109. end);
  1110. this.think = (function (this)
  1111. local self,i,defaultQuality,resMatching,qualityLevels;
  1112. if (not _eq(this.player,null)) then
  1113. if _bool(((function() if _bool(theater:isForceVideoRes()) then return (_eq(this.player:getState(),"playing"));  else return theater:isForceVideoRes();  end end)())) then
  1114. if (not _eq(this.lastWindowHeight,window.innerHeight)) then
  1115. qualityLevels = this.player:getPlaylist()[0].sources;
  1116. resMatching = _arr({},0);
  1117. defaultQuality = null;
  1118. i = 0;
  1119. while (_lt(i,qualityLevels.length)) do
  1120. resMatching[qualityLevels[i]["label"]] = i;
  1121. if _bool(qualityLevels[i]["default"]) then
  1122. defaultQuality = i;
  1123. end
  1124.  
  1125. i = _inc(i);
  1126. end
  1127.  
  1128. if (_eq(defaultQuality,null)) then
  1129. defaultQuality = (function() if (_in(resMatching,"720p")) then return resMatching["720p"]; else return 1; end end)();
  1130. end
  1131.  
  1132. if ((function() if (_le(window.innerHeight,1536)) then return (_gt(window.innerHeight,1440));  else return (_le(window.innerHeight,1536));  end end)()) then
  1133. this.forceRes = (function() if (_in(resMatching,"1080p")) then return resMatching["1080p"]; else return defaultQuality; end end)();
  1134. end
  1135.  
  1136. if ((function() if (_le(window.innerHeight,1440)) then return (_gt(window.innerHeight,1080));  else return (_le(window.innerHeight,1440));  end end)()) then
  1137. this.forceRes = (function() if (_in(resMatching,"1080p")) then return resMatching["1080p"]; else return defaultQuality; end end)();
  1138. end
  1139.  
  1140. if ((function() if (_le(window.innerHeight,1080)) then return (_gt(window.innerHeight,720));  else return (_le(window.innerHeight,1080));  end end)()) then
  1141. this.forceRes = (function() if (_in(resMatching,"1080p")) then return resMatching["1080p"]; else return defaultQuality; end end)();
  1142. end
  1143.  
  1144. if ((function() if (_le(window.innerHeight,720)) then return (_gt(window.innerHeight,480));  else return (_le(window.innerHeight,720));  end end)()) then
  1145. this.forceRes = (function() if (_in(resMatching,"720p")) then return resMatching["720p"]; else return defaultQuality; end end)();
  1146. end
  1147.  
  1148. if ((function() if (_le(window.innerHeight,480)) then return (_gt(window.innerHeight,360));  else return (_le(window.innerHeight,480));  end end)()) then
  1149. this.forceRes = (function() if (_in(resMatching,"480p")) then return resMatching["480p"]; else return defaultQuality; end end)();
  1150. end
  1151.  
  1152. if ((function() if (_le(window.innerHeight,360)) then return (_gt(window.innerHeight,240));  else return (_le(window.innerHeight,360));  end end)()) then
  1153. this.forceRes = (function() if (_in(resMatching,"360p")) then return resMatching["360p"]; else return defaultQuality; end end)();
  1154. end
  1155.  
  1156. if (_le(window.innerHeight,240)) then
  1157. this.forceRes = (function() if (_in(resMatching,"240p")) then return resMatching["240p"]; else return defaultQuality; end end)();
  1158. end
  1159.  
  1160. this.player:setCurrentQuality(this.forceRes);
  1161. console:log((_addStr1("Forcing Quality Change to ",this.forceRes)));
  1162. this.lastWindowHeight = window.innerHeight;
  1163. end
  1164.  
  1165. end
  1166.  
  1167. if (not _eq(this.videoId,this.lastVideoId)) then
  1168. self = this;
  1169. setTimeout(_ENV,(function (this)
  1170. if (not _bool(self.player:getPlaylist()[0]) and not _bool(self.player:getPlaylist()[0]) or (_eq(self.player:getPlaylist()[0].file,"example.mp4"))) then
  1171. self:onRemove();
  1172. theater:getPlayerContainer().innerHTML = "<div id='player'><div style='color: red;'>ERROR: Kiss Video Sources Load Failure</div></div>";
  1173. do return end
  1174. end
  1175.  
  1176. end),30000);
  1177. if (this.videoId:lastIndexOf("ol_",0) == 0) then
  1178. eval(_ENV,base64:decode(this.videoId:replace("ol_","")));
  1179. if ((function() if (_type(vs) ~= "undefined") then return (_type(vs) ~= "null");  else return (_type(vs) ~= "undefined");  end end)()) then
  1180. this.player:load(_arr({[0]=_obj({
  1181. ["file"] = vs
  1182. })},1));
  1183. vs = null;
  1184. end
  1185.  
  1186. elseif (this.videoId:lastIndexOf("jw_aes_",0) == 0) then
  1187. this.player:load(_arr({[0]=_obj({
  1188. ["sources"] = eval(_ENV,Skissenc__aes:decrypt(this.videoId:replace("jw_aes_","")))
  1189. })},1));
  1190. elseif (this.videoId:lastIndexOf("jw_sha256_",0) == 0) then
  1191. this.player:load(_arr({[0]=_obj({
  1192. ["sources"] = eval(_ENV,Skissenc__sha256:decrypt(this.videoId:replace("jw_sha256_","")))
  1193. })},1));
  1194. else
  1195. this.player:load(_arr({[0]=_obj({
  1196. ["sources"] = eval(_ENV,atob(_ENV,this.videoId:replace("jw_","")))
  1197. })},1));
  1198. end
  1199.  
  1200. this.lastVideoId = this.videoId;
  1201. this.lastStartTime = this.startTime;
  1202. end
  1203.  
  1204. if ((function() if ((function() if not _bool(this.sentKissDuration) then return (_eq(this.player:getState(),"playing"));  else return not _bool(this.sentKissDuration);  end end)()) then return (_gt(this.player:getDuration(),0));  else return ((function() if not _bool(this.sentKissDuration) then return (_eq(this.player:getState(),"playing"));  else return not _bool(this.sentKissDuration);  end end)());  end end)()) then
  1205. console:log(((_addStr1("RUNLUA: theater.SendKissDuration(",this.player:getDuration())) .. ")"));
  1206. this.sentKissDuration = true;
  1207. end
  1208.  
  1209. if (not _eq(this.player:getState(),"idle")) then
  1210. if (not _eq(this.startTime,this.lastStartTime)) then
  1211. this:seek(this.startTime);
  1212. this.lastStartTime = this.startTime;
  1213. end
  1214.  
  1215. if (not _eq(this.volume,this.player:getVolume())) then
  1216. this.player:setVolume(this.volume);
  1217. this.volume = this.player:getVolume();
  1218. end
  1219.  
  1220. end
  1221.  
  1222. end
  1223.  
  1224. end);
  1225. this.onReady = (function (this)
  1226. local self;
  1227. this.player = viewer;
  1228. self = this;
  1229. this.interval = setInterval(_ENV,(function (this)
  1230. self:think(self);
  1231. end),100);
  1232. end);
  1233. this.toggleControls = (function (this, enabled)
  1234. this.player:setControls(enabled);
  1235. end);
  1236. self = this;
  1237. viewer:on("ready",(function (this)
  1238. self:onReady();
  1239. end));
  1240. end);
  1241. registerPlayer(_ENV,"kissanime",Kiss);
  1242. registerPlayer(_ENV,"kissasian",Kiss);
  1243. registerPlayer(_ENV,"kisscartoon",Kiss);
  1244. KissYT = (function (this)
  1245. local url,attributes,params;
  1246. params = _obj({
  1247. ["allowScriptAccess"] = "always",
  1248. ["bgcolor"] = "#000000",
  1249. ["wmode"] = "opaque"
  1250. });
  1251. attributes = _obj({
  1252. ["id"] = "player"
  1253. });
  1254. url = "https://www.youtube.com/get_player?enablejsapi=1&modestbranding=1";
  1255. this.setVideo = (function (this, id)
  1256. local v,k,flashvars;
  1257. this.lastStartTime = null;
  1258. this.lastVideoId = null;
  1259. this.videoId = id;
  1260. if (id:lastIndexOf("yt_aes_",0) == 0) then
  1261. id = Skissenc__aes:decrypt(id:replace("yt_aes_",""));
  1262. elseif (id:lastIndexOf("yt_sha256_",0) == 0) then
  1263. id = Skissenc__sha256:decrypt(id:replace("yt_sha256_",""));
  1264. else
  1265. id = atob(_ENV,id:replace("yt_",""));
  1266. end
  1267.  
  1268. flashvars = _obj({});
  1269. local _p = _props(id:split("&"), true);
  1270. for _,k in _ipairs(_p) do
  1271. k = _tostr(k);
  1272. local _p = _props(id:split("&")[k]:split("="), true);
  1273. for _,v in _ipairs(_p) do
  1274. v = _tostr(v);
  1275. if ((function() if (not _eq(_type(id:split("&")[k]:split("=")[(v - 1)]),"undefined")) then return (not _eq(_type(id:split("&")[k]:split("=")[v]),"undefined"));  else return (not _eq(_type(id:split("&")[k]:split("=")[(v - 1)]),"undefined"));  end end)()) then
  1276. flashvars[id:split("&")[k]:split("=")[(v - 1)]:replace("amp;","")] = id:split("&")[k]:split("=")[v];
  1277. end
  1278. ::_continue::
  1279. end
  1280. ::_continue::
  1281. end
  1282.  
  1283. swfobject:embedSWF(url,"player","100%","100%","9",null,flashvars,params,attributes);
  1284. this.sentKissDuration = false;
  1285. this.initSeek = false;
  1286. end);
  1287. this.setVolume = (function (this, volume)
  1288. this.lastVolume = null;
  1289. this.volume = volume;
  1290. end);
  1291. this.setStartTime = (function (this, seconds)
  1292. this.lastStartTime = null;
  1293. this.startTime = seconds;
  1294. end);
  1295. this.seek = (function (this, seconds)
  1296. if (not _eq(this.player,null)) then
  1297. this.player:seekTo(seconds,true);
  1298. if (not _eq(this.player:getPlayerState(),1)) then
  1299. this.player:playVideo();
  1300. end
  1301.  
  1302. end
  1303.  
  1304. end);
  1305. this.onRemove = (function (this)
  1306. clearInterval(_ENV,this.interval);
  1307. end);
  1308. this.getCurrentTime = (function (this)
  1309. if (not _eq(this.player,null)) then
  1310. do return this.player:getCurrentTime(); end
  1311. end
  1312.  
  1313. end);
  1314. this.canChangeTime = (function (this)
  1315. if (not _eq(this.player,null)) then
  1316. do return ((function() if (not _eq(this.player:getVideoBytesTotal(),-1)) then return (not _eq(this.player:getPlayerState(),3));  else return (not _eq(this.player:getVideoBytesTotal(),-1));  end end)()); end
  1317. end
  1318.  
  1319. end);
  1320. this.think = (function (this)
  1321. local self;
  1322. if (not _eq(this.player,null)) then
  1323. if _bool(theater:isForceVideoRes()) then
  1324. if (not _eq(this.lastWindowHeight,window.innerHeight)) then
  1325. if ((function() if (_le(window.innerHeight,1536)) then return (_gt(window.innerHeight,1440));  else return (_le(window.innerHeight,1536));  end end)()) then
  1326. this.ytforceres = "highres";
  1327. end
  1328.  
  1329. if ((function() if (_le(window.innerHeight,1440)) then return (_gt(window.innerHeight,1080));  else return (_le(window.innerHeight,1440));  end end)()) then
  1330. this.ytforceres = "highres";
  1331. end
  1332.  
  1333. if ((function() if (_le(window.innerHeight,1080)) then return (_gt(window.innerHeight,720));  else return (_le(window.innerHeight,1080));  end end)()) then
  1334. this.ytforceres = "hd1080";
  1335. end
  1336.  
  1337. if ((function() if (_le(window.innerHeight,720)) then return (_gt(window.innerHeight,480));  else return (_le(window.innerHeight,720));  end end)()) then
  1338. this.ytforceres = "hd720";
  1339. end
  1340.  
  1341. if ((function() if (_le(window.innerHeight,480)) then return (_gt(window.innerHeight,360));  else return (_le(window.innerHeight,480));  end end)()) then
  1342. this.ytforceres = "large";
  1343. end
  1344.  
  1345. if ((function() if (_le(window.innerHeight,360)) then return (_gt(window.innerHeight,240));  else return (_le(window.innerHeight,360));  end end)()) then
  1346. this.ytforceres = "medium";
  1347. end
  1348.  
  1349. if (_le(window.innerHeight,240)) then
  1350. this.ytforceres = "small";
  1351. end
  1352.  
  1353. this.player:setPlaybackQuality(this.ytforceres);
  1354. console:log((_addStr1("Forcing Quality Change to ",this.ytforceres)));
  1355. this.lastWindowHeight = window.innerHeight;
  1356. end
  1357.  
  1358. end
  1359.  
  1360. if (not _eq(this.videoId,this.lastVideoId)) then
  1361. this.lastVideoId = this.videoId;
  1362. this.lastStartTime = this.startTime;
  1363. self = this;
  1364. setTimeout(_ENV,(function (this)
  1365. if ((function() if (_type(self.player.getPlayerState) == "function") then return (_eq(self.player:getPlayerState(),-1));  else return (_type(self.player.getPlayerState) == "function");  end end)()) then
  1366. theater:getPlayerContainer().innerHTML = "<div id='player'><div style='color: red;'>ERROR: Kiss Video Sources Load Failure</div></div>";
  1367. do return end
  1368. end
  1369.  
  1370. end),30000);
  1371. end
  1372.  
  1373. if ((function() if ((function() if not _bool(this.sentKissDuration) then return (_type(this.player.getDuration) == "function");  else return not _bool(this.sentKissDuration);  end end)()) then return (_gt(this.player:getDuration(),0));  else return ((function() if not _bool(this.sentKissDuration) then return (_type(this.player.getDuration) == "function");  else return not _bool(this.sentKissDuration);  end end)());  end end)()) then
  1374. console:log(((_addStr1("RUNLUA: theater.SendKissDuration(",this.player:getDuration())) .. ")"));
  1375. this.sentKissDuration = true;
  1376. end
  1377.  
  1378. if ((function() if (_type(this.player.getPlayerState) == "function") then return (not _eq(this.player:getPlayerState(),-1));  else return (_type(this.player.getPlayerState) == "function");  end end)()) then
  1379. if not _bool(this.initSeek) then
  1380. this:seek((_addNum2(this.startTime,3)));
  1381. this.initSeek = true;
  1382. end
  1383.  
  1384. if (not _eq(this.startTime,this.lastStartTime)) then
  1385. this:seek(this.startTime);
  1386. this.lastStartTime = this.startTime;
  1387. end
  1388.  
  1389. if (not _eq(this.volume,this.player:getVolume())) then
  1390. this.player:setVolume(this.volume);
  1391. this.volume = this.player:getVolume();
  1392. end
  1393.  
  1394. end
  1395.  
  1396. end
  1397.  
  1398. end);
  1399. this.onReady = (function (this)
  1400. local self;
  1401. this.player = document:getElementById("player");
  1402. if _bool(theater:isForceVideoRes()) then
  1403. if ((function() if (_le(window.innerHeight,1536)) then return (_gt(window.innerHeight,1440));  else return (_le(window.innerHeight,1536));  end end)()) then
  1404. this.ytforceres = "highres";
  1405. end
  1406.  
  1407. if ((function() if (_le(window.innerHeight,1440)) then return (_gt(window.innerHeight,1080));  else return (_le(window.innerHeight,1440));  end end)()) then
  1408. this.ytforceres = "highres";
  1409. end
  1410.  
  1411. if ((function() if (_le(window.innerHeight,1080)) then return (_gt(window.innerHeight,720));  else return (_le(window.innerHeight,1080));  end end)()) then
  1412. this.ytforceres = "hd1080";
  1413. end
  1414.  
  1415. if ((function() if (_le(window.innerHeight,720)) then return (_gt(window.innerHeight,480));  else return (_le(window.innerHeight,720));  end end)()) then
  1416. this.ytforceres = "hd720";
  1417. end
  1418.  
  1419. if ((function() if (_le(window.innerHeight,480)) then return (_gt(window.innerHeight,360));  else return (_le(window.innerHeight,480));  end end)()) then
  1420. this.ytforceres = "large";
  1421. end
  1422.  
  1423. if ((function() if (_le(window.innerHeight,360)) then return (_gt(window.innerHeight,240));  else return (_le(window.innerHeight,360));  end end)()) then
  1424. this.ytforceres = "medium";
  1425. end
  1426.  
  1427. if (_le(window.innerHeight,240)) then
  1428. this.ytforceres = "small";
  1429. end
  1430.  
  1431. this.player:setPlaybackQuality(this.ytforceres);
  1432. console:log((_addStr1("Forcing Quality Change to ",this.ytforceres)));
  1433. this.lastWindowHeight = window.innerHeight;
  1434. end
  1435.  
  1436. self = this;
  1437. this.interval = setInterval(_ENV,(function (this)
  1438. self:think(self);
  1439. end),100);
  1440. end);
  1441. end);
  1442. registerPlayer(_ENV,"kissyoutube",KissYT);
  1443. Dailymotion = (function (this)
  1444. local self,viewer;
  1445. viewer = DM:player(document:getElementById("player"),_obj({
  1446. ["width"] = "100%",
  1447. ["height"] = "100%",
  1448. ["params"] = _obj({
  1449. ["autoplay"] = true,
  1450. ["controls"] = true
  1451. })
  1452. }));
  1453. this.setVideo = (function (this, id)
  1454. this.lastStartTime = null;
  1455. this.lastVideoId = null;
  1456. this.videoId = id;
  1457. end);
  1458. this.setVolume = (function (this, volume)
  1459. this.lastVolume = null;
  1460. this.volume = (volume / 100);
  1461. end);
  1462. this.setStartTime = (function (this, seconds)
  1463. this.lastStartTime = null;
  1464. this.startTime = seconds;
  1465. end);
  1466. this.seek = (function (this, seconds)
  1467. if (not _eq(this.player,null)) then
  1468. this.player:seek(seconds);
  1469. if _bool(this.player.paused) then
  1470. this.player:play();
  1471. end
  1472.  
  1473. end
  1474.  
  1475. end);
  1476. this.onRemove = (function (this)
  1477. clearInterval(_ENV,this.interval);
  1478. end);
  1479. this.getCurrentTime = (function (this)
  1480. if (not _eq(this.player,null)) then
  1481. do return this.player.currentTime; end
  1482. end
  1483.  
  1484. end);
  1485. this.think = (function (this)
  1486. if (not _eq(this.player,null)) then
  1487. if (not _eq(this.videoId,this.lastVideoId)) then
  1488. this.player:load(this.videoId,_obj({
  1489. ["autoplay"] = true,
  1490. ["start"] = this.startTime
  1491. }));
  1492. this.lastVideoId = this.videoId;
  1493. this.lastStartTime = this.startTime;
  1494. end
  1495.  
  1496. if (not _eq(this.startTime,this.lastStartTime)) then
  1497. this:seek(this.startTime);
  1498. this.lastStartTime = this.startTime;
  1499. end
  1500.  
  1501. if (not _eq(this.volume,this.lastVolume)) then
  1502. this.player:setVolume(this.volume);
  1503. this.lastVolume = this.player.volume;
  1504. end
  1505.  
  1506. end
  1507.  
  1508. end);
  1509. this.onReady = (function (this)
  1510. local self;
  1511. this.player = viewer;
  1512. self = this;
  1513. this.interval = setInterval(_ENV,(function (this)
  1514. self:think(self);
  1515. end),100);
  1516. end);
  1517. this.toggleControls = (function (this, enabled)
  1518.  
  1519. end);
  1520. self = this;
  1521. viewer:addEventListener("apiready",(function (this)
  1522. self:onReady();
  1523. end));
  1524. end);
  1525. registerPlayer(_ENV,"dailymotion",Dailymotion);
  1526. registerPlayer(_ENV,"dailymotionlive",Dailymotion);
  1527. HitboxLive = (function (this)
  1528. local self,viewer,player__container,pre__player;
  1529. videojs.options.flash.swf = "video-js-5.9.2/video-js.swf";
  1530. pre__player = document:createElement("video");
  1531. pre__player.className = "video-js vjs-default-skin";
  1532. pre__player.id = "player";
  1533. pre__player.preload = "auto";
  1534. pre__player.autoplay = "true";
  1535. player__container = document:getElementById("player").parentNode;
  1536. player__container:removeChild(document:getElementById("player"));
  1537. player__container:appendChild(pre__player);
  1538. viewer = videojs(_ENV,"player");
  1539. this.setVideo = (function (this, id)
  1540. this.lastStartTime = null;
  1541. this.lastVideoId = null;
  1542. this.videoId = id;
  1543. end);
  1544. this.setVolume = (function (this, volume)
  1545. this.lastVolume = null;
  1546. this.volume = (volume / 100);
  1547. end);
  1548. this.onRemove = (function (this)
  1549. clearInterval(_ENV,this.interval);
  1550. end);
  1551. this.think = (function (this)
  1552. local self,playerJSON;
  1553. if (not _eq(this.player,null)) then
  1554. if (not _eq(this.videoId,this.lastVideoId)) then
  1555. playerJSON = _new(XMLHttpRequest);
  1556. self = this;
  1557. playerJSON.onreadystatechange = (function (this)
  1558. local parsedJSON;
  1559. if ((function() if (_eq(playerJSON.readyState,4)) then return (_eq(playerJSON.status,200));  else return (_eq(playerJSON.readyState,4));  end end)()) then
  1560. parsedJSON = JSON:parse(playerJSON.responseText);
  1561. self.player:src(_obj({
  1562. ["type"] = "application/x-mpegURL",
  1563. ["src"] = parsedJSON["clip"]["url"]
  1564. }));
  1565. end
  1566.  
  1567. end);
  1568. playerJSON:open("GET",((_addStr1("https://www.hitbox.tv/api/player/config/live/",this.videoId)) .. "?autoplay=true&embed=true&no_interruption=false&ssl=true"),true);
  1569. playerJSON:send();
  1570. this.lastVideoId = this.videoId;
  1571. this.lastStartTime = this.startTime;
  1572. end
  1573.  
  1574. if (not _eq(this.volume,this.lastVolume)) then
  1575. this.player:volume(this.volume);
  1576. this.lastVolume = this.volume;
  1577. end
  1578.  
  1579. end
  1580.  
  1581. end);
  1582. this.onReady = (function (this)
  1583. local self;
  1584. this.player = viewer;
  1585. self = this;
  1586. this.interval = setInterval(_ENV,(function (this)
  1587. self:think(self);
  1588. end),100);
  1589. end);
  1590. this.toggleControls = (function (this, enabled)
  1591. this.player:controls(enabled);
  1592. end);
  1593. self = this;
  1594. viewer:ready((function (this)
  1595. self:onReady();
  1596. end));
  1597. end);
  1598. registerPlayer(_ENV,"hitboxlive",HitboxLive);
  1599. Hitbox = (function (this)
  1600. local self,viewer,player__container,pre__player;
  1601. videojs.options.flash.swf = "video-js-5.9.2/video-js.swf";
  1602. pre__player = document:createElement("video");
  1603. pre__player.className = "video-js vjs-default-skin";
  1604. pre__player.id = "player";
  1605. pre__player.preload = "auto";
  1606. pre__player.autoplay = "true";
  1607. player__container = document:getElementById("player").parentNode;
  1608. player__container:removeChild(document:getElementById("player"));
  1609. player__container:appendChild(pre__player);
  1610. viewer = videojs(_ENV,"player");
  1611. this.setVideo = (function (this, id)
  1612. this.lastStartTime = null;
  1613. this.lastVideoId = null;
  1614. this.videoId = id;
  1615. end);
  1616. this.setVolume = (function (this, volume)
  1617. this.lastVolume = null;
  1618. this.volume = (volume / 100);
  1619. end);
  1620. this.setStartTime = (function (this, seconds)
  1621. this.lastStartTime = null;
  1622. this.startTime = seconds;
  1623. end);
  1624. this.seek = (function (this, seconds)
  1625. if (not _eq(this.player,null)) then
  1626. this.player:currentTime(seconds);
  1627. if _bool(this.player:paused()) then
  1628. this.player:play();
  1629. end
  1630.  
  1631. end
  1632.  
  1633. end);
  1634. this.onRemove = (function (this)
  1635. clearInterval(_ENV,this.interval);
  1636. end);
  1637. this.getCurrentTime = (function (this)
  1638. if (not _eq(this.player,null)) then
  1639. do return this.player:currentTime(); end
  1640. end
  1641.  
  1642. end);
  1643. this.think = (function (this)
  1644. if (not _eq(this.player,null)) then
  1645. if (not _eq(this.videoId,this.lastVideoId)) then
  1646. this.player:src(_obj({
  1647. ["type"] = "application/x-mpegURL",
  1648. ["src"] = ((_addStr1("http://www.hitbox.tv/api/player/hlsvod/",this.videoId)) .. ".m3u8")
  1649. }));
  1650. this.lastVideoId = this.videoId;
  1651. this.lastStartTime = this.startTime;
  1652. end
  1653.  
  1654. if (not _eq(this.startTime,this.lastStartTime)) then
  1655. this:seek(this.startTime);
  1656. this.lastStartTime = this.startTime;
  1657. end
  1658.  
  1659. if (not _eq(this.volume,this.lastVolume)) then
  1660. this.player:volume(this.volume);
  1661. this.lastVolume = this.volume;
  1662. end
  1663.  
  1664. end
  1665.  
  1666. end);
  1667. this.onReady = (function (this)
  1668. local self;
  1669. this.player = viewer;
  1670. self = this;
  1671. this.interval = setInterval(_ENV,(function (this)
  1672. self:think(self);
  1673. end),100);
  1674. end);
  1675. this.toggleControls = (function (this, enabled)
  1676. this.player:controls(enabled);
  1677. end);
  1678. self = this;
  1679. viewer:ready((function (this)
  1680. self:onReady();
  1681. end));
  1682. end);
  1683. registerPlayer(_ENV,"hitbox",Hitbox);
  1684. end)(_ENV);
  1685. if _bool(window.onTheaterReady) then
  1686. onTheaterReady(_ENV);
  1687. end
  1688.  
  1689. console:log((_addStr1("Loaded theater.js v",theater.VERSION)));
Add Comment
Please, Sign In to add comment