[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linterna-magica-commit] [416] Experimental code that supports YouTube p
From: |
Ivaylo Valkov |
Subject: |
[linterna-magica-commit] [416] Experimental code that supports YouTube playlists auto and shuffle playback . |
Date: |
Tue, 30 Jul 2013 21:35:58 +0000 |
Revision: 416
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=416
Author: valkov
Date: 2013-07-30 21:35:57 +0000 (Tue, 30 Jul 2013)
Log Message:
-----------
Experimental code that supports YouTube playlists auto and shuffle playback.
Modified Paths:
--------------
trunk/src/lm_player_button_functions.js
trunk/src/lm_site_youtube.js
trunk/src/lm_sites.js
Modified: trunk/src/lm_player_button_functions.js
===================================================================
--- trunk/src/lm_player_button_functions.js 2013-07-29 20:11:43 UTC (rev
415)
+++ trunk/src/lm_player_button_functions.js 2013-07-30 21:35:57 UTC (rev
416)
@@ -873,10 +873,17 @@
// Clear when the video end is reached
// or null returned (no video_object found)
if ((time_and_state.position && time_and_state.duration) &&
- (time_and_state.position >= time_and_state.duration))
+ ((time_and_state.position >= time_and_state.duration) ||
+ ((time_and_state.position + 1) >= time_and_state.duration)))
{
clearInterval(self.player_timers[id]);
delete self.player_timers[id];
+
+ var self = this;
+ var val = this.call_site_function_at_position.apply(self,[
+ "player_stream_ended_action",
+ window.location.hostname]);
+
return;
}
Modified: trunk/src/lm_site_youtube.js
===================================================================
--- trunk/src/lm_site_youtube.js 2013-07-29 20:11:43 UTC (rev 415)
+++ trunk/src/lm_site_youtube.js 2013-07-30 21:35:57 UTC (rev 416)
@@ -589,6 +589,43 @@
return false;
}
+LinternaMagica.prototype.sites["youtube.com"].player_stream_ended_action =
+function()
+{
+ var playlist = document.getElementById("watch7-playlist-tray");
+ var autoplay =
document.getElementById("watch7-playlist-bar-autoplay-button");
+ var current_song =
+ this.get_first_element_by_class("playlist-bar-item-playing", playlist);
+
+ var shuffle =
document.getElementById("watch7-playlist-bar-shuffle-button");
+
+ var next_song = null;
+
+ if (!playlist || !autoplay || !current_song ||
+ !this.object_has_css_class(autoplay, "yt-uix-button-toggled"))
+ {
+ return;
+ }
+
+ if (shuffle &&
+ this.object_has_css_class(shuffle, "yt-uix-button-toggled"))
+ {
+ var songs = playlist.getElementsByTagName("a");
+ var rand = Math.floor(Math.random() * songs.length);
+ next_song = songs[rand].getAttribute("href");
+ }
+ else
+ {
+ next_song =
+ current_song.nextSibling.getElementsByTagName("a")[0].
+ getAttribute("href");
+ }
+
+ window.location = next_song;
+
+ return true;
+}
+
LinternaMagica.prototype.sites["youtube.com"].css_fixes =
function(object_data)
{
Modified: trunk/src/lm_sites.js
===================================================================
--- trunk/src/lm_sites.js 2013-07-29 20:11:43 UTC (rev 415)
+++ trunk/src/lm_sites.js 2013-07-30 21:35:57 UTC (rev 416)
@@ -314,6 +314,14 @@
return true;
}
+
+// lm_site_youtube.js:player_stream_ended_action()
+LinternaMagica.prototype.sites.__player_stream_ended_action =
+function()
+{
+ return true;
+}
+
// Check if site specific config and function exists and call it. If
// it doesn't, call the general/default function. A function returns
// false/null, if the calling function should exit/return after this
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [linterna-magica-commit] [416] Experimental code that supports YouTube playlists auto and shuffle playback .,
Ivaylo Valkov <=