mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 16:02:00 +02:00
YT: auto select best matching resolution for used monitor
This commit is contained in:
@@ -19,6 +19,7 @@ class ClapperPlayer extends PlayerBase
|
||||
this.needsFastSeekRestore = false;
|
||||
this.customVideoTitle = null;
|
||||
|
||||
this.windowMapped = false;
|
||||
this.canAutoFullscreen = false;
|
||||
this.playOnFullscreen = false;
|
||||
this.quitOnStop = false;
|
||||
@@ -54,7 +55,11 @@ class ClapperPlayer extends PlayerBase
|
||||
if(!this.ytClient)
|
||||
this.ytClient = new YouTube.YouTubeClient();
|
||||
|
||||
this.ytClient.getPlaybackDataAsync(videoId)
|
||||
const { root } = this.widget;
|
||||
const surface = root.get_surface();
|
||||
const monitor = root.display.get_monitor_at_surface(surface);
|
||||
|
||||
this.ytClient.getPlaybackDataAsync(videoId, monitor)
|
||||
.then(data => {
|
||||
this.customVideoTitle = data.title;
|
||||
super.set_uri(data.uri);
|
||||
@@ -121,10 +126,9 @@ class ClapperPlayer extends PlayerBase
|
||||
this.playlistWidget.addItem(uri);
|
||||
}
|
||||
|
||||
const firstTrack = this.playlistWidget.get_row_at_index(0);
|
||||
if(!firstTrack) return;
|
||||
|
||||
firstTrack.activate();
|
||||
/* If not mapped yet, first track will play after map */
|
||||
if(this.windowMapped)
|
||||
this._playFirstTrack();
|
||||
}
|
||||
|
||||
set_subtitles(source)
|
||||
@@ -291,6 +295,14 @@ class ClapperPlayer extends PlayerBase
|
||||
: Gst.filename_to_uri(source);
|
||||
}
|
||||
|
||||
_playFirstTrack()
|
||||
{
|
||||
const firstTrack = this.playlistWidget.get_row_at_index(0);
|
||||
if(!firstTrack) return;
|
||||
|
||||
firstTrack.activate();
|
||||
}
|
||||
|
||||
_performCloseCleanup(window)
|
||||
{
|
||||
window.disconnect(this.closeRequestSignal);
|
||||
@@ -522,6 +534,12 @@ class ClapperPlayer extends PlayerBase
|
||||
}
|
||||
}
|
||||
|
||||
_onWindowMap(window)
|
||||
{
|
||||
this.windowMapped = true;
|
||||
this._playFirstTrack();
|
||||
}
|
||||
|
||||
_onCloseRequest(window)
|
||||
{
|
||||
this._performCloseCleanup(window);
|
||||
|
Reference in New Issue
Block a user