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

Add a loop feature #13

Closed maxcurzi closed 3 months ago

maxcurzi commented 1 year ago

Describe the solution you'd like Allow looping of videos, rather than stopping at the end.

Additional context

december1981 commented 3 months ago

I actually got this working with storing the audio content in memory and replaying with a byte cursor, and the video replay was with a flag, easy enough: video.set(opencv::videoio::CAP_PROP_POS_AVI_RATIO, 0.0);

See my change here: https://github.com/maxcurzi/tplay/compare/main...december1981:tplay:support-playback-loop?expand=1

I just used an argument "loops" to enable or not. The default behaviour of animated gifs was to loop, so I stopped that unless the loops argument was used, for consistency.

I used loops, and not loop by the way, because otherwise it's r#loop in code...

december1981 commented 3 months ago

I should add, I only played around with the audio loop for rodio.

maxcurzi commented 3 months ago

Looks great. I tested it and it works like a charm! @december1981 I created a pull request after making just a couple of tweaks. Have a look if you'd like at https://github.com/maxcurzi/tplay/pull/38 (not sure why I can't tag you directly on the PR)