sachac / subed

subed is a subtitle editor for Emacs
177 stars 16 forks source link

[feature request] Define functions for changing the playback while audio is playing #70

Closed rodrigomorales1 closed 2 weeks ago

rodrigomorales1 commented 2 weeks ago

My use case: I'm currently editing subtitles for audios in my native language. While I'm editing subtitles, I have noticed that some parts in the audio are very easy to understand for me, so in these parts I wish I could set the playback speed to something very fast (e.g. (setq subed-playback-speed-while-not-typing 4)) in order to better use my time. Some parts in the audio are very difficult to understand (e.g. for some reason the speaker decided to speak faster than usual), so in these parts I wish I could set the the playback speed to the normal speed (i.e. (setq subed-playback-speed-while-not-typing 1)).

The current master branch supports setting subed-playback-speed-while-not-typing and this option is only used for new instances of mpv that subed launches. As far as I know, there is no subed functions for changing the subed-playback-speed-while-not-typing while mpv is already playing the media file.

I wish I could have a function that would let me change the playback for an already mpv instance which was opened by subed.

rodrigomorales1 commented 2 weeks ago

After writing the issue, I just realized that there is a function for changing the playback speed for the current mpv instance. The function is called subed-mpv-playback-speed. These are the functions that I defined:

(defun my-subed-mpv-playback-speed-1 () (interactive) (subed-mpv-playback-speed 1))
(defun my-subed-mpv-playback-speed-2 () (interactive) (subed-mpv-playback-speed 2))
(defun my-subed-mpv-playback-speed-3 () (interactive) (subed-mpv-playback-speed 3))
(defun my-subed-mpv-playback-speed-4 () (interactive) (subed-mpv-playback-speed 4))

The following shows how I mapped the functions:

(define-minor-mode
  my-subed-custom-keys-minor-mode
  "Custom keys for `subed-mode'."
  :keymap (let ((map (make-sparse-keymap)))
            (define-key map (kbd "M-1") 'my-subed-mpv-playback-speed-1)
            (define-key map (kbd "M-2") 'my-subed-mpv-playback-speed-2)
            (define-key map (kbd "M-3") 'my-subed-mpv-playback-speed-3)
            (define-key map (kbd "M-4") 'my-subed-mpv-playback-speed-4)
            map))
sachac commented 1 week ago

Awesome! I'll still keep thinking about possible keybindings since M-number feels a bit too general, but I'm glad you've figured out something that works for you!

On Sun, Jun 23, 2024, 08:24 Rodrigo Morales @.***> wrote:

After writing the issue, I just realized that there is a function for changing the playback speed for the current mpv instance. The function is called subed-mpv-playback-speed. These are the functions that I defined:

(defun my-subed-mpv-playback-speed-1 () (interactive) (subed-mpv-playback-speed 1)) (defun my-subed-mpv-playback-speed-2 () (interactive) (subed-mpv-playback-speed 2)) (defun my-subed-mpv-playback-speed-3 () (interactive) (subed-mpv-playback-speed 3)) (defun my-subed-mpv-playback-speed-4 () (interactive) (subed-mpv-playback-speed 4))

The following shows how I mapped the functions:

(define-minor-mode my-subed-custom-keys-minor-mode "Custom keys for `subed-mode'." :keymap (let ((map (make-sparse-keymap))) (define-key map (kbd "M-1") 'my-subed-mpv-playback-speed-1) (define-key map (kbd "M-2") 'my-subed-mpv-playback-speed-2) (define-key map (kbd "M-3") 'my-subed-mpv-playback-speed-3) (define-key map (kbd "M-4") 'my-subed-mpv-playback-speed-4) map))

— Reply to this email directly, view it on GitHub https://github.com/sachac/subed/issues/70#issuecomment-2184968220, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACD7EX6TDIINPYFLGX3BWDZI246TAVCNFSM6AAAAABJYKHE5SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBUHE3DQMRSGA . You are receiving this because you are subscribed to this thread.Message ID: @.***>