maxcurzi / tplay

A terminal ASCII media player. View images, gifs, videos, webcam, YouTube, etc.. directly in the terminal as ASCII art.
MIT License
208 stars 13 forks source link

Support looping playback #38

Closed maxcurzi closed 3 months ago

maxcurzi commented 3 months ago

Thanks @december1981 for adding this feature. I make a couple of tweaks: 1) Implemented a stub "rewind" in case MPV is used. The audio won't loop but at least it will build. 2) Consolidated runner options in one structure 3) Renamed loops to loop_playback. I'm sad we can't use the "loop" keyword so I opted for more clarity/verboseness, I hope you don't mind!

december1981 commented 3 months ago

That looks fine my side!

december1981 commented 3 months ago

One thing on my original commit, I wasn't too sure about calling the broker to initiate replay, if that might be called multiple times in the run loop until it takes effect. I can regress that, or if you want to tighten that up a little to prevent that.

maxcurzi commented 3 months ago

One thing on my original commit, I wasn't too sure about calling the broker to initiate replay, if that might be called multiple times in the run loop until it takes effect. I can regress that, or if you want to tighten that up a little to prevent that.

you mean this bit?

                if self.loops && frame.is_none() {
                    self.send_control(MediaControl::Replay)?;
                }

That should just happen zero times or once at the end of playback I think (my memory is a bit rusty). I'll merge for now and if we find it's an issue we can address it with a follow up PR

december1981 commented 3 months ago

Yes, it was to that I was referring.

maxcurzi commented 3 months ago

thanks for implementing this feature @december1981 ! I'm sure many people will appreciate this new release :)

december1981 commented 3 months ago

Not a problem, this is a great little app for fans of the terminal, glad to have contributed.