PageSourceSearch

https://liveplasma.com/js/youtube_player.js?288

js liveplasma.com collected 2026-09-24 09:31:23 UTC 7,605 bytes, 217 lines download raw bytes

1
2      // 2. This code loads the IFrame Player API code asynchronously.
3      var tag = document.createElement('script');
4
5      tag.src = "https://www.youtube.com/iframe_api";
6      var firstScriptTag = document.getElementsByTagName('script')[0];
7      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
8
9      // 3. This function creates an <iframe> (and YouTube player)
10      //    after the API code downloads.
11      var player;
12      function onYouTubeIframeAPIReady() {
13        player = new YT.Player('player', {
14          height: '200',
15          width: '249',
16          videoId: '',
17            playerVars: { 'autoplay': 0,'controls': 0,'fs':0,'iv_load_policy':3,'modestbranding':1,'showinfo':0},
18          events: {
19            'onReady': onPlayerReady,
20            'onStateChange': onPlayerStateChange,
21            'onError': onPlayerError,
22
23          }
24        });
25      }
26
27      // 4. The API will call this function when the video player is ready.
28      function onPlayerReady(event) {
29         // player.nextVideo() ;
30          console.log("onPlayerReady()",event);
31         document.getElementById('player').style.display = "none" ;
32        //event.target.playVideo();
33      }
34
35     
36        var cpt_error = 0 ;
37        var new_playlist  =Array() ;
38
39        let timeoutID ;
40        let new_index ; 
41
42      function onPlayerError(event) {
43
44
45        if(timeoutID) clearTimeout(timeoutID);
46
47        timeoutID = setTimeout( function(){
48
49            console.log("onPlayerError()",event.data);
50
51            var cpt = 0 ;
52
53              new_index = player.playerInfo.playlistIndex+1 ;
54
55
56
57            // player.nextVideo() ;
58
59             
60          
61               new_playlist = player.getPlaylist() ;
62             
63
64              
65             
66           
67
68             // player.cuePlaylist(new_playlist, new_index, 0, 'small')
69
70               youtube_player_load_playlist(radio.radio_artist_mbid,"","similar_playlist",25)
71              /*
72              setTimeout( function(){
73                  console.log(new_playlist);
74                  player.cuePlaylist(new_playlist, new_index, 0, 'small')
75                  console.log(player.getPlaylist())
76                 // player.playVideo()
77               }
78              , 2000); */
79
80         }
81          , 500);
82        console.log(timeoutID)
83          /*
84          cpt_error++ ;
85          if(cpt_error >= 2) {
86              console.log("onPlayerError()",event.data);
87              old_index = player.playerInfo.playlistIndex ;
88              console.log("track index "+old_index)
89              console.log(player.getPlaylist())
90         
91
92          
93
94          
95
96
97         //  player.cuePlaylist(new_playlist, 0, 0, 'small')
98          setTimeout( function(){
99              player.cuePlaylist(new_playlist, 0, 0, 'small')
100              console.log(player.getPlaylist())
101              cpt_error = 0
102              player.playVideoAt(0)
103           }
104          , 1000);   
105
106           }     */ 
107          
108      }
109
110
111
112
113      // 5. The API calls this function when the player's state changes.
114      //    The function indicates that when playing a video (state=1),
115      //    the player should play for six seconds and then stop.
116      var done = false;
117
118      
119  
120      function onPlayerStateChange(event) {
121
122          console.log("onPlayerStateChange()",event.data);
123         // console.log(player.playerInfo);
124
125          if((event.data == 5) && (player.getPlaylist().length>=1)) {
126              player.nextVideo() ;
127          }
128
129        //  clearTimeout(timeoutID)
130          
131
132          switch(event.data) {
133            case -1 : document.getElementById('timeranim_player').beginElement(); gTimer_player.style("opacity",1) ;
134
135             break ;
136            case 5 : document.getElementById('timeranim_player').beginElement(); gTimer_player.style("opacity",1) ;player.playVideo();break ;
137            case 0 : document.getElementById('halo_anim').endElement() ;document.getElementById('halo_anim2').endElement() ; break ;
138            case 3 : gTimer_player.style("opacity",0) ;
139              document.getElementById('timeranim_player').endElement() ;
140              document.getElementById('halo_anim').beginElement() ;
141              document.getElementById('halo_anim2').beginElement() ; break ;
142            case 1 :
143               console.log(timeoutID)
144              clearTimeout(timeoutID);
145             
146              document.getElementById('player').style.display = "block" ;
147              gTimer_player.style("opacity",0) ;
148              document.getElementById('timeranim_player').endElement() ;
149              document.getElementById('halo_anim').beginElement() ;
150              document.getElementById('halo_anim2').beginElement() ;
151
152
153              //setTimeout(function(){ update_progress_bar(player.getCurrentTime(),player.getDuration()) }, 1000);
154
155
156              //clearInterval(myInterval);
157              var myInterval = setInterval(function(){ update_progress_bar(player.getCurrentTime(),player.getDuration()) }, 1000);
158
159             // var array_playlist = player.getPlaylist() ;
160             // var i = player.getPlaylistIndex() ;
161
162              var videoId = player.playerInfo.videoData.title ;
163           //   console.log("index "+player.playerInfo.playlistIndex+ " "+playlist[player.playerInfo.playlistIndex].title)
164             // 
165             // console.log("track duration:"+player.getDuration())
166
167              radio.playing_artist_name = playlist[player.playerInfo.playlistIndex].name ;
168
169
170             if(playlist[player.playerInfo.playlistIndex].title != "") {
171                
172                radio.playing_track_title = playlist[player.playerInfo.playlistIndex].title ;
173
174                set_playing_artist("",playlist[player.playerInfo.playlistIndex].name,playlist[player.playerInfo.playlistIndex].title) 
175                console.log("youtube_player.js DB title "+playlist[player.playerInfo.playlistIndex].title)
176             } else {
177
178                radio.playing_track_title = player.playerInfo.videoData.title ;
179                set_playing_artist("",playlist[player.playerInfo.playlistIndex].name,player.playerInfo.videoData.title) 
180                //on envoit le titre pour completer la DB
181               // DB_update_track_name(playlist[player.playerInfo.playlistIndex].video_id,player.playerInfo.videoData.title) ;
182              
183               // DB_update_track_info(playlist[player.playerInfo.playlistIndex].video_id,player.playerInfo.videoData.title) ;
184             }
185
186             update_music_player(true,true) ;
187
188             DB_update_track_duration(playlist[player.playerInfo.playlistIndex].video_id,player.getDuration(),playing_artist.id) ;
189             
190
191               gtag('event', 'play', {'event_category': 'audio',
192                          'event_label': videoId
193                    });
194              break ;                    
195            default : gTimer_player.style("opacity",0) ; document.getElementById('timeranim_player').endElement();
196            document.getElementById('halo_anim').endElement() ;document.getElementById('halo_anim2').endElement() ;
197             break ;     
198          }
199
200
201
202
203          /*
204        if ((event.data == YT.PlayerState.CUED) && (player.getPlayerState() == 0)
204){
205          player.nextVideo() ;
206            console.log("nextVideo()");
207        }
208        */
209      }
210      function stopVideo() {
211        player.stopVideo();
212      }
213
214
215
216
217 

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.