mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2026-01-18 05:23:07 +01:00
added prev and next buttons for the stream player
This commit is contained in:
@@ -129,6 +129,8 @@ class MainAppWindow:
|
||||
"on_play_stream": self.on_play_stream,
|
||||
"on_player_play": self.on_player_play,
|
||||
"on_player_stop": self.on_player_stop,
|
||||
"on_player_previous": self.on_player_previous,
|
||||
"on_player_next": self.on_player_next,
|
||||
"on_player_close": self.on_player_close,
|
||||
"on_player_press": self.on_player_press,
|
||||
"on_full_screen": self.on_full_screen,
|
||||
@@ -1203,42 +1205,52 @@ class MainAppWindow:
|
||||
|
||||
@run_idle
|
||||
def on_player_play(self, item=None):
|
||||
self.play()
|
||||
url = self.get_stream_url()
|
||||
if not url:
|
||||
return
|
||||
self.play(url)
|
||||
|
||||
def play(self):
|
||||
def play(self, url):
|
||||
if not self._player:
|
||||
try:
|
||||
self._player = Player()
|
||||
except (NameError, AttributeError):
|
||||
show_dialog(DialogType.ERROR, self._main_window, "No VLC is found. Check that it is installed!")
|
||||
return
|
||||
else:
|
||||
if self._drawing_area_xid:
|
||||
self._player.set_xwindow(self._drawing_area_xid)
|
||||
self._services_main_box.set_visible(False)
|
||||
self._bouquets_main_box.set_visible(False)
|
||||
w, h = self._main_window.get_size()
|
||||
self._player_box.set_size_request(w * 0.6, -1)
|
||||
|
||||
self._player_box.set_visible(True)
|
||||
|
||||
if self._player.is_playing():
|
||||
self.on_player_stop()
|
||||
|
||||
GLib.idle_add(self._player.play, url, priority=GLib.PRIORITY_LOW)
|
||||
|
||||
def get_stream_url(self):
|
||||
path, column = self._fav_view.get_cursor()
|
||||
if path:
|
||||
row = self._fav_model[path][:]
|
||||
if row[5] == BqServiceType.IPTV.name:
|
||||
url = get_iptv_url(row, Profile(self._profile))
|
||||
if not url:
|
||||
return
|
||||
|
||||
if not self._player:
|
||||
try:
|
||||
self._player = Player()
|
||||
except (NameError, AttributeError):
|
||||
show_dialog(DialogType.ERROR, self._main_window, "No VLC is found. Check that it is installed!")
|
||||
return
|
||||
else:
|
||||
if self._drawing_area_xid:
|
||||
self._player.set_xwindow(self._drawing_area_xid)
|
||||
self._services_main_box.set_visible(False)
|
||||
self._bouquets_main_box.set_visible(False)
|
||||
w, h = self._main_window.get_size()
|
||||
self._player_box.set_size_request(w * 0.6, -1)
|
||||
|
||||
self._player_box.set_visible(True)
|
||||
|
||||
if self._player.is_playing():
|
||||
self.on_player_stop()
|
||||
|
||||
GLib.idle_add(self._player.play, url, priority=GLib.PRIORITY_LOW)
|
||||
return get_iptv_url(row, Profile(self._profile))
|
||||
|
||||
def on_player_stop(self, item=None):
|
||||
if self._player:
|
||||
self._player.stop()
|
||||
|
||||
def on_player_previous(self, item):
|
||||
if self._fav_view.do_move_cursor(self._fav_view, Gtk.MovementStep.DISPLAY_LINES, -1):
|
||||
self.on_play_stream()
|
||||
|
||||
def on_player_next(self, item):
|
||||
if self._fav_view.do_move_cursor(self._fav_view, Gtk.MovementStep.DISPLAY_LINES, 1):
|
||||
self.on_play_stream()
|
||||
|
||||
def on_player_close(self, item=None):
|
||||
if self._player:
|
||||
self._player.release()
|
||||
|
||||
@@ -1211,7 +1211,7 @@ Author: Dmitriy Yefremov
|
||||
<child>
|
||||
<object class="GtkPaned" id="main_paned">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="player_box">
|
||||
<property name="width_request">320</property>
|
||||
@@ -1236,7 +1236,7 @@ Author: Dmitriy Yefremov
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkToolItem" id="player_play_tool_item">
|
||||
<object class="GtkToolItem" id="player_item">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
@@ -1249,10 +1249,10 @@ Author: Dmitriy Yefremov
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="player_play_tool_button">
|
||||
<object class="GtkToolButton" id="player_play_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="is_important">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Play</property>
|
||||
<property name="stock_id">gtk-media-play</property>
|
||||
<signal name="clicked" handler="on_player_play" swapped="no"/>
|
||||
</object>
|
||||
@@ -1262,10 +1262,10 @@ Author: Dmitriy Yefremov
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="player_stop_tool_button">
|
||||
<object class="GtkToolButton" id="player_stop_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="is_important">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Stop playback</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="stock_id">gtk-media-stop</property>
|
||||
<signal name="clicked" handler="on_player_stop" swapped="no"/>
|
||||
@@ -1276,7 +1276,35 @@ Author: Dmitriy Yefremov
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolItem" id="player_play_tool_item_2">
|
||||
<object class="GtkToolButton" id="player_prev_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="tooltip_text" translatable="yes">Previous stream in the list</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="stock_id">gtk-media-previous</property>
|
||||
<signal name="clicked" handler="on_player_previous" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="player_next_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="tooltip_text" translatable="yes">Next stream in the list</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="stock_id">gtk-media-next</property>
|
||||
<signal name="clicked" handler="on_player_next" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolItem" id="player_item_2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
@@ -1289,10 +1317,10 @@ Author: Dmitriy Yefremov
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="player_full_tool_button">
|
||||
<object class="GtkToolButton" id="player_full_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="is_important">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Toggle the video in fullscreen</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="stock_id">gtk-fullscreen</property>
|
||||
<signal name="clicked" handler="on_full_screen" swapped="no"/>
|
||||
@@ -1303,11 +1331,11 @@ Author: Dmitriy Yefremov
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="player_close_tool_button">
|
||||
<object class="GtkToolButton" id="player_close_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="tooltip_text" translatable="yes">Close</property>
|
||||
<property name="margin_right">15</property>
|
||||
<property name="is_important">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="stock_id">gtk-close</property>
|
||||
<signal name="clicked" handler="on_player_close" swapped="no"/>
|
||||
@@ -1537,7 +1565,7 @@ Author: Dmitriy Yefremov
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="services_scrolled_window">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="services_tree_view">
|
||||
@@ -2036,7 +2064,7 @@ Author: Dmitriy Yefremov
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="fav_scrolled_window">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_bottom">2</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
@@ -2274,7 +2302,7 @@ Author: Dmitriy Yefremov
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_bottom">2</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
|
||||
@@ -1,21 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1
|
||||
|
||||
Copyright (C) Dmitriy Yefremov
|
||||
The MIT License (MIT)
|
||||
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved. This file is offered as-is,
|
||||
without any warranty.
|
||||
Copyright (c) 2018 Dmitriy Yefremov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
Author: Dmitriy Yefremov
|
||||
|
||||
-->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<!-- interface-license-type all_permissive -->
|
||||
<requires lib="gtk+" version="3.16"/>
|
||||
<!-- interface-license-type mit -->
|
||||
<!-- interface-name DemonEditor -->
|
||||
<!-- interface-copyright Dmitriy Yefremov -->
|
||||
<!-- interface-description Enigma2 channel and satellites list editor for GNU/Linux. -->
|
||||
<!-- interface-copyright 2018 Dmitriy Yefremov -->
|
||||
<!-- interface-authors Dmitriy Yefremov -->
|
||||
<object class="GtkImage" id="reset_image">
|
||||
<property name="visible">True</property>
|
||||
|
||||
Reference in New Issue
Block a user