/usr/share/sushi/js/viewers/gst.js is in gnome-sushi 3.24.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | /*
* Copyright (C) 2011 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
* The Sushi project hereby grant permission for non-gpl compatible GStreamer
* plugins to be used and distributed together with GStreamer and Sushi. This
* permission is above and beyond the permissions granted by the GPL license
* Sushi is covered by.
*
* Authors: Cosimo Cecchi <cosimoc@redhat.com>
*
*/
imports.gi.versions.ClutterGst = '3.0';
const ClutterGst = imports.gi.ClutterGst;
const Clutter = imports.gi.Clutter;
const Gdk = imports.gi.Gdk;
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const GtkClutter = imports.gi.GtkClutter;
const Lang = imports.lang;
const Constants = imports.util.constants;
const MimeHandler = imports.ui.mimeHandler;
const TotemMimeTypes = imports.util.totemMimeTypes;
const Utils = imports.ui.utils;
const GstRenderer = new Lang.Class({
Name: 'GstRenderer',
_init : function(args) {
this.moveOnClick = true;
this.canFullScreen = true;
},
prepare : function(file, mainWindow, callback) {
this._mainWindow = mainWindow;
this._file = file;
this._callback = callback;
this._createVideo(file);
this._callback();
},
render : function() {
return this._video;
},
clear : function() {
this._player.playing = false;
},
_createVideo : function(file) {
this._player = new ClutterGst.Playback();
this._video = new Clutter.Actor({
content: new ClutterGst.Aspectratio({
player: this._player
})
});
this._player.set_uri(file.get_uri());
this._player.playing = true;
this._videoSizeChangeId =
this._player.connect('size-change',
Lang.bind(this,
this._onVideoSizeChange));
this._player.connect('notify::playing',
Lang.bind(this,
this._onVideoPlayingChange));
this._player.connect('notify::progress',
Lang.bind(this,
this._onVideoProgressChange));
this._player.connect('notify::duration',
Lang.bind(this,
this._onVideoDurationChange));
},
_updateProgressBar : function() {
if (!this._mainToolbar)
return;
this._isSettingValue = true;
this._progressBar.set_value(this._player.progress * 1000);
this._isSettingValue = false;
},
_updateCurrentLabel : function() {
if (!this._mainToolbar)
return;
let currentTime =
Math.floor(this._player.duration * this._player.progress);
this._currentLabel.set_text(Utils.formatTimeString(currentTime));
},
_updateDurationLabel : function() {
if (!this._mainToolbar)
return;
let totalTime = this._player.duration;
this._durationLabel.set_text(Utils.formatTimeString(totalTime));
},
_onVideoProgressChange : function() {
this._updateCurrentLabel();
this._updateProgressBar();
},
_onVideoDurationChange : function() {
this._updateDurationLabel();
},
_onVideoPlayingChange : function() {
if (this._player.playing)
this._toolbarPlay.set_icon_name('media-playback-pause-symbolic');
else
{
let iconName = 'media-playback-start-symbolic';
this._toolbarPlay.set_icon_name(iconName);
}
},
getSizeForAllocation : function(allocation) {
if (!this._videoWidth ||
!this._videoHeight) {
return [ Constants.VIEW_MIN, Constants.VIEW_MIN ];
}
let baseSize = [ this._videoWidth, this._videoHeight ];
return Utils.getScaledSize(baseSize, allocation, true);
},
createToolbar : function () {
this._mainToolbar = new Gtk.Toolbar({ icon_size: Gtk.IconSize.MENU });
this._mainToolbar.get_style_context().add_class('osd');
this._mainToolbar.set_show_arrow(false);
this._mainToolbar.show();
this._toolbarActor = new GtkClutter.Actor({ contents: this._mainToolbar,
opacity: 0,
x_expand: true });
this._toolbarPlay = new Gtk.ToolButton({ icon_name: 'media-playback-pause-symbolic' });
this._toolbarPlay.show();
this._mainToolbar.insert(this._toolbarPlay, 0);
this._currentLabel = new Gtk.Label({ margin_start: 6,
margin_end: 3 });
let item = new Gtk.ToolItem();
item.add(this._currentLabel);
item.show_all();
this._mainToolbar.insert(item, 1);
this._toolbarPlay.connect('clicked',
Lang.bind(this, function () {
let playing = !this._player.playing;
this._player.playing = playing;
}));
this._progressBar =
Gtk.Scale.new_with_range(Gtk.Orientation.HORIZONTAL,
0, 1000, 10);
this._progressBar.set_value(0);
this._progressBar.set_draw_value(false);
this._progressBar.connect('value-changed',
Lang.bind(this, function() {
if(!this._isSettingValue)
this._player.progress = this._progressBar.get_value() / 1000;
}));
item = new Gtk.ToolItem();
item.set_expand(true);
item.add(this._progressBar);
item.show_all();
this._mainToolbar.insert(item, 2);
this._durationLabel = new Gtk.Label({ margin_start: 3,
margin_end: 6 });
item = new Gtk.ToolItem();
item.add(this._durationLabel);
item.show_all();
this._mainToolbar.insert(item, 3);
this._toolbarZoom = Utils.createFullScreenButton(this._mainWindow);
this._mainToolbar.insert(this._toolbarZoom, 4);
return this._toolbarActor;
},
_onVideoSizeChange : function(player, width, height) {
this._videoWidth = width;
this._videoHeight = height;
this._mainWindow.refreshSize();
},
});
let handler = new MimeHandler.MimeHandler();
let renderer = new GstRenderer();
handler.registerMimeTypes(TotemMimeTypes.videoTypes, renderer);
|