diff --git a/changelog.md b/changelog.md index f3c0bed..9428a1a 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,9 @@ ### New additions * For users with multiple soundcards, there is a new tab in the preferences dialogue of Socializer, called sound. From there, you can define which soundcard will be used for input and output. +* the audio player can seek positions in the currently playing track. You can use the menu items (located in the main menu) or use the new available keystrokes dedicated to the actions. Seeking will be made in 5 second intervals. + * Alt+Shift+Left arrow: Seek 5 seconds backwards. + * Alt+Shift+Right arrow: Seek 5 seconds forwards. * it is possible to select the language used in socializer from the preferences dialog. When changing the language, the application must be restarted for the changes to take effect. * A new option, called open in vk.com, has been added in the context menu for almost all objects (items in home timeline, walls, documents, people, group topics and in buffers for conversations). This option will open the selected item in the VK website. * when opening the list of friends added by an user, you can display the context menu from an item on the list and view the user profile, open it in VK.com, among other actions. diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 367e242..e1e3212 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -542,6 +542,8 @@ class Controller(object): widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_next, menuitem=self.window.player_next) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_previous, menuitem=self.window.player_previous) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_all, menuitem=self.window.player_play_all) + widgetUtils.connect_event(self.window, widgetUtils.MENU, self.seek_left, menuitem=self.window.player_seek_left) + widgetUtils.connect_event(self.window, widgetUtils.MENU, self.seek_right, menuitem=self.window.player_seek_right) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_volume_down, menuitem=self.window.player_volume_down) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_volume_up, menuitem=self.window.player_volume_up) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_mute, menuitem=self.window.player_mute) @@ -776,6 +778,12 @@ class Controller(object): def menu_mute(self, *args, **kwargs): player.player.volume = 0 + def seek_left(self, *args, **kwargs): + pub.sendMessage("seek", ms=-500000) + + def seek_right(self, *args, **kwargs): + pub.sendMessage("seek", ms=500000) + def view_my_profile(self, *args, **kwargs): self.user_profile(self.session.user_id) diff --git a/src/presenters/player.py b/src/presenters/player.py index 10d63c5..a93cab1 100644 --- a/src/presenters/player.py +++ b/src/presenters/player.py @@ -53,6 +53,7 @@ class audioPlayer(object): pub.subscribe(self.stop, "stop") pub.subscribe(self.play_next, "play-next") pub.subscribe(self.play_previous, "play-previous") + pub.subscribe(self.seek, "seek") def play(self, object, set_info=True, fresh=False): """ Play an URl Stream. @@ -181,6 +182,16 @@ class audioPlayer(object): self.playing_track -= 1 call_threaded(self.play, self.queue[self.playing_track]) + def seek(self, ms=0): + if self.check_is_playing(): + if self.stream.position < 500000 and ms < 0: + self.stream.position = 0 + else: + try: + self.stream.position = self.stream.position+ms + except: + pass + def check_is_playing(self): """ check if the player is already playing a stream. """ if self.stream == None: diff --git a/src/wxUI/mainWindow.py b/src/wxUI/mainWindow.py index 3299ed2..d5b43fa 100644 --- a/src/wxUI/mainWindow.py +++ b/src/wxUI/mainWindow.py @@ -41,6 +41,8 @@ class mainWindow(wx.Frame): self.player_previous = player.Append(wx.NewId(), _("Previous")) self.player_next = player.Append(wx.NewId(), _("Next")) self.player_shuffle = player.AppendCheckItem(wx.NewId(), _("Shuffle")) + self.player_seek_left = player.Append(wx.NewId(), _("Seek backwards")) + self.player_seek_right = player.Append(wx.NewId(), _("Seek forwards")) self.player_volume_up = player.Append(wx.NewId(), _("Volume up")) self.player_volume_down = player.Append(wx.NewId(), _("Volume down")) self.player_mute = player.Append(wx.NewId(), _("Mute")) @@ -65,6 +67,8 @@ class mainWindow(wx.Frame): # Translators: Keystroke used to play/pause the current item in the playback queue. Use the latin alphabet, but you can match a different key here. For example if you want to assign this to the key "П", use G. (wx.ACCEL_CTRL, ord(_("P")), self.player_play.GetId()), (wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord(_("P")), self.player_play_all.GetId()), + (wx.ACCEL_ALT|wx.ACCEL_SHIFT, wx.WXK_LEFT, self.player_seek_left.GetId()), + (wx.ACCEL_ALT|wx.ACCEL_SHIFT, wx.WXK_RIGHT, self.player_seek_right.GetId()), ]) self.SetAcceleratorTable(self.accel_tbl)