blob: 43deba9f22c4887af411a3ea796ffd75c5727a13 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
|