diff options
author | Matias Linares <matias.linares@comprandoengrupo.net> | 2022-06-22 14:31:23 -0300 |
---|---|---|
committer | Matias Linares <matias.linares@comprandoengrupo.net> | 2022-06-22 14:31:23 -0300 |
commit | bfe3973d0925fa3a429b327563558d36df1934e1 (patch) | |
tree | 9f3bf3417012679ac0fa0ac48039f58f8ca52e84 /bass_player.rb | |
download | bass-player-bfe3973d0925fa3a429b327563558d36df1934e1.tar.gz |
Initial commit
Diffstat (limited to 'bass_player.rb')
-rw-r--r-- | bass_player.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/bass_player.rb b/bass_player.rb new file mode 100644 index 0000000..43deba9 --- /dev/null +++ b/bass_player.rb @@ -0,0 +1,62 @@ +require 'qml' +require './models' + +module BassPlayer + VERSION = '0.1' + class SongController + include QML::Access + register_to_qml + + property(:title) { '' } + property(:duration) { '' } + property(:model) { QML::ArrayModel.new(:title, :duration) } + property(:part_model) { + QML::ArrayModel.new(:name, :from, :to) + } + + def initialize + super() + Song.all.each do |song| + p song + model << { + title: song.title, + duration: ms_to_time(song.duration) + } + end + end + + def add(file_url, duration, metadata) + item = { + title: file_url, + duration: duration + } + p item + model << item + end + + def song_selected(song) + part_model.clear + parts = Part.all.map do |part| + { + name: part.name, + from: ms_to_time(part.from), + to: ms_to_time(part.to) + } + end + + for part in parts + part_model << part + end + end + + def ms_to_time(ms) + retval = Time.at(ms/1000).utc.strftime("%H:%M:%S") + p "ms: '#{ms}' - Time: #{retval}" + return retval + end + end +end + +QML.run do |app| + app.load_path Pathname(__FILE__) + '../main.qml' +end |