Skip to content

Commit 096f80d

Browse files
committed
feat: add audio loop play
1 parent 1e9be4d commit 096f80d

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

TODO.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
* [x] video loop play
44
* [x] audio play use ffplay
5-
* [ ] control audio play
6-
* [ ] add audio loop play
5+
* [x] add audio loop play
76
* [ ] add play control: pause, next, prev, exit
87
* [ ] memory play is too limit
98
* [ ] windows support

lib/convert2ascii/terminal-player.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,14 @@ def self_adaption_frame_play
115115
if @audio
116116
Thread.new do
117117
start_time = Time.now # 以音频为准
118-
system("ffplay -nodisp -i #{@audio} &> /dev/null")
118+
play_cmd = "ffplay -nodisp "
119+
if @play_loop
120+
play_cmd << " -loop 0"
121+
end
122+
system("#{play_cmd} -i #{@audio} &> /dev/null")
119123
if @debug
120124
puts Rainbow("[info] audio time: #{Time.now - start_time} s").green
121125
end
122-
123-
# TODO control audio play
124-
# Open3.popen3("afplay #{@audio}") do |stdin, stdout, stderr, wait_thr|
125-
# # 可以在这里处理输出或错误信息
126-
# end
127126
end
128127
end
129128
frame_index = 0

0 commit comments

Comments
 (0)