Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. var YouTubeFlashVideo = function() {
  2.  
  3. var params = {
  4. allowScriptAccess: "always",
  5. bgcolor: "#000000",
  6. wmode: "opaque"
  7. };
  8.  
  9. var attributes = {
  10. id: "player",
  11. };
  12.  
  13. this.setVideo = function( id ) {
  14. this.lastStartTime = null;
  15. this.videoId = id;
  16.  
  17. var url = 'https://youtube.googleapis.com/yva_video?enablejsapi=1&autoplay=1&fs=1&hl=en&modestbranding=1&autohide=1&showinfo=0&controls=0';
  18.  
  19. if ( theater.isCCEnabled() ) {
  20. url += "&cc_load_policy=1";
  21. url += "&yt:cc=on";
  22. }
  23.  
  24. if (id.length > 11) {
  25. url += '&docid=' + id + '&ps=docs&partnerid=30';
  26. }
  27.  
  28. swfobject.embedSWF(url, "player", "126.6%", "104.2%", "9", null, null, params, attributes);
  29. }
  30.  
  31. this.setVolume = function( volume ) {
  32. this.lastVolume = null;
  33. this.volume = volume;
  34. };
  35.  
  36. this.setStartTime = function( seconds ) {
  37. this.lastStartTime = null;
  38. this.startTime = seconds;
  39. };
  40.  
  41. this.seek = function( seconds ) {
  42. if ( this.player != null ) {
  43. this.player.seekTo( seconds, true );
  44.  
  45. if ( this.player.getPlayerState() != 1 ) {
  46. this.player.playVideo();
  47. }
  48. }
  49. };
  50.  
  51. this.onRemove = function() {
  52. clearInterval( this.interval );
  53. };
  54.  
  55. this.getCurrentTime = function() {
  56. if ( this.player != null ) {
  57. return this.player.getCurrentTime();
  58. }
  59. };
  60.  
  61. this.think = function() {
  62. if ( this.player != null ) {
  63. if ( (typeof(this.player.getPlayerState) === "function") && this.player.getPlayerState() != -1 ) {
  64. if ( this.startTime != this.lastStartTime ) {
  65. this.seek( this.startTime );
  66. this.lastStartTime = this.startTime;
  67. }
  68. if ( this.volume != this.player.getVolume() ) {
  69. this.player.setVolume( this.volume );
  70. this.volume = this.player.getVolume();
  71. }
  72. }
  73. }
  74. };
  75.  
  76. this.onReady = function() {
  77. this.player = document.getElementById('player');
  78. this.player.style.marginLeft = "-24.2%";
  79. this.player.style.marginTop = "-2%";
  80.  
  81. this.ytforceres="large";
  82.  
  83. if (theater.isHDEnabled()) {
  84. this.ytforceres = "hd720";
  85. }
  86.  
  87. if (this.videoId.length <= 11) {
  88. this.player.loadVideoById( this.videoId, this.startTime, this.ytforceres);
  89. this.lastStartTime = this.startTime;
  90. } else {
  91. this.player.setPlaybackQuality(this.ytforceres);
  92. }
  93.  
  94. var self = this;
  95. this.interval = setInterval( function() { self.think(self); }, 100 );
  96. };
  97.  
  98. };
  99. registerPlayer( "youtube", YouTubeFlashVideo );
  100. registerPlayer( "drive", YouTubeFlashVideo );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement