zik 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/ChangeLog +222 -0
- data/INSTALL +34 -0
- data/Makefile.in +199 -0
- data/README +53 -0
- data/ZiK.desktop +11 -0
- data/ZiK.rb +377 -0
- data/configure +269 -0
- data/dependencies +142 -0
- data/doc/COPYING +340 -0
- data/doc/ChangeLog +222 -0
- data/doc/html/fr/index.html +128 -0
- data/doc/html/index.html +126 -0
- data/doc/html/pix/ZiK3.png +0 -0
- data/doc/html/pix/capture.png +0 -0
- data/doc/html/pix/capture_cd.png +0 -0
- data/doc/html/pix/capture_compact.png +0 -0
- data/doc/html/pix/capture_radio.png +0 -0
- data/doc/html/pix/icon.png +0 -0
- data/doc/html/pix/logo.png +0 -0
- data/doc/html/styles/main.css +47 -0
- data/doc/man/manpage.1 +43 -0
- data/gui/assistant.rb +133 -0
- data/gui/cdgui.rb +54 -0
- data/gui/common.rb +56 -0
- data/gui/config.rb +120 -0
- data/gui/edit.rb +413 -0
- data/gui/error.rb +124 -0
- data/gui/gui.rb +1383 -0
- data/gui/mod.rb +239 -0
- data/gui/preference.rb +496 -0
- data/gui/progress.rb +50 -0
- data/gui/radiogui.rb +404 -0
- data/gui/search.rb +249 -0
- data/gui/socket.rb +107 -0
- data/mod/brainz.rb +76 -0
- data/mod/brainz/dialogs.rb +132 -0
- data/mod/brainz/functions.rb +55 -0
- data/mod/brainz/ofa.rb +76 -0
- data/mod/brainz/song.rb +139 -0
- data/mod/brainz/widget.rb +34 -0
- data/mod/cover.rb +90 -0
- data/mod/cover/application-x-cd-image.svg +666 -0
- data/mod/cover/config.rb +79 -0
- data/mod/cover/configwidget.rb +35 -0
- data/mod/cover/widget.rb +147 -0
- data/mod/hotkeys.rb +137 -0
- data/mod/hotkeys/config.rb +84 -0
- data/mod/hotkeys/configwidget.rb +93 -0
- data/mod/interact.rb +131 -0
- data/mod/interact/configwidget.rb +107 -0
- data/mod/interact/interaction.rb +79 -0
- data/mod/notify.rb +128 -0
- data/mod/notify/config.rb +96 -0
- data/mod/notify/configwidget.rb +76 -0
- data/mod/notify/window.rb +56 -0
- data/mod/trayicon.rb +83 -0
- data/mod/trayicon/config.rb +79 -0
- data/mod/trayicon/configwidget.rb +35 -0
- data/mod/trayicon/icon.rb +99 -0
- data/pix/ZiK.svg +78 -0
- data/pix/ZiK3.png +0 -0
- data/pix/assistant/capture.png +0 -0
- data/pix/gtk-directory.svg +287 -0
- data/pix/media-cdrom.svg +292 -0
- data/pix/network-wireless.svg +429 -0
- data/pix/player_play.svg +286 -0
- data/pix/sound.svg +244 -0
- data/pix/sound_directory.svg +464 -0
- data/player/cdplayer.rb +108 -0
- data/player/player.rb +132 -0
- data/player/radioplayer.rb +124 -0
- data/playlist/cdlist.rb +140 -0
- data/playlist/common.rb +343 -0
- data/playlist/editlist.rb +50 -0
- data/playlist/export.rb +108 -0
- data/playlist/playlist.rb +143 -0
- data/playlist/radiolist.rb +148 -0
- data/playlist/song.rb +122 -0
- data/po/ZiK.pot +622 -0
- data/po/fr/ZiK.po +658 -0
- data/zik +2 -0
- metadata +265 -0
- metadata.gz.sig +0 -0
data/player/cdplayer.rb
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Copyright 2007-2011 Vincent Carmona
|
4
|
+
vinc4mai@gmail.com
|
5
|
+
|
6
|
+
This file is part of ZiK.
|
7
|
+
|
8
|
+
ZiK is free software; you can redistribute it and/or modify
|
9
|
+
it under the terms of the GNU General Public License as published by
|
10
|
+
the Free Software Foundation; either version 2 of the License, or
|
11
|
+
(at your option) any later version.
|
12
|
+
|
13
|
+
ZiK is distributed in the hope that it will be useful,
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
GNU General Public License for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License
|
19
|
+
along with ZiK; if not, write to the Free Software
|
20
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
=end
|
22
|
+
|
23
|
+
module Cd
|
24
|
+
class Player
|
25
|
+
attr_writer :gui
|
26
|
+
|
27
|
+
def initialize(d='/dev/cdrom')
|
28
|
+
@playing=false
|
29
|
+
|
30
|
+
@src=Gst::ElementFactory.make('cdiocddasrc')
|
31
|
+
device=d
|
32
|
+
|
33
|
+
@sink=Gst::ElementFactory.make('autoaudiosink')
|
34
|
+
|
35
|
+
@vol=Gst::ElementFactory.make('volume')
|
36
|
+
|
37
|
+
@pipeline=Gst::Pipeline.new
|
38
|
+
@pipeline.bus.add_watch {|bus, message| got_bus_message(message)}
|
39
|
+
@pipeline.add(@src, @vol, @sink)
|
40
|
+
@src >> @vol >> @sink
|
41
|
+
end
|
42
|
+
|
43
|
+
def device=(d)
|
44
|
+
@src.device=d
|
45
|
+
end
|
46
|
+
|
47
|
+
def playing?
|
48
|
+
@playing
|
49
|
+
end
|
50
|
+
|
51
|
+
def stop
|
52
|
+
@playing=false
|
53
|
+
@pipeline.stop
|
54
|
+
ErrorInfo.new("Player stopped.")
|
55
|
+
end
|
56
|
+
|
57
|
+
def pause
|
58
|
+
if playing?
|
59
|
+
@playing=false
|
60
|
+
@pipeline.pause
|
61
|
+
ErrorInfo.new("Pause.")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def play(song)
|
66
|
+
begin
|
67
|
+
@playing=true
|
68
|
+
@src.track=song.track
|
69
|
+
@pipeline.play
|
70
|
+
ErrorInfo.new("Playing #{song.name}.")
|
71
|
+
rescue
|
72
|
+
ErrorError.new(_("Playing track #{song.track}."), true)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def position
|
77
|
+
q=Gst::QueryPosition.new(Gst::Format::Type::TIME)
|
78
|
+
@pipeline.query(q)
|
79
|
+
q.parse[1]/1000000000
|
80
|
+
end
|
81
|
+
|
82
|
+
def position=(pos)
|
83
|
+
@pipeline.send_event(Gst::EventSeek.new(1.0,
|
84
|
+
Gst::Format::Type::TIME, Gst::Seek::FLAG_FLUSH.to_i | Gst::Seek::FLAG_KEY_UNIT.to_i, Gst::Seek::TYPE_SET,
|
85
|
+
pos*1000000000, Gst::Seek::TYPE_NONE, -1))
|
86
|
+
#@pipeline.seek(1.0, Gst::Format::Type::TIME, Gst::Seek::FLAG_FLUSH.to_i | Gst::Seek::FLAG_KEY_UNIT.to_i, Gst::Seek::TYPE_SET, pos*1000000000, Gst::Seek::TYPE_NONE, -1)
|
87
|
+
#Arguments for Gst::EventSeek taken from the ruby-gstreamer0.10 (and not from ruby-gnome2) binding examples (cf:video-player)
|
88
|
+
end
|
89
|
+
|
90
|
+
def volume=(n)
|
91
|
+
@vol.volume=n
|
92
|
+
ErrorInfo.new("Set volume to #{n}.")
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def got_bus_message(message)
|
98
|
+
case message.type
|
99
|
+
when Gst::Message::ERROR
|
100
|
+
ErrorError.new(_("Gstreamer error."), true)
|
101
|
+
stop
|
102
|
+
when Gst::Message::EOS
|
103
|
+
@gui.next_song#Use Dbus to propagate message instead of :gui ???
|
104
|
+
end
|
105
|
+
true#Without this line only the first message is processed
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
data/player/player.rb
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Copyright 2007-2011 Vincent Carmona
|
4
|
+
vinc4mai@gmail.com
|
5
|
+
|
6
|
+
This file is part of ZiK.
|
7
|
+
|
8
|
+
ZiK is free software; you can redistribute it and/or modify
|
9
|
+
it under the terms of the GNU General Public License as published by
|
10
|
+
the Free Software Foundation; either version 2 of the License, or
|
11
|
+
(at your option) any later version.
|
12
|
+
|
13
|
+
ZiK is distributed in the hope that it will be useful,
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
GNU General Public License for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License
|
19
|
+
along with ZiK; if not, write to the Free Software
|
20
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
=end
|
22
|
+
|
23
|
+
class Player
|
24
|
+
|
25
|
+
attr_writer :gui
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
@playing=false
|
29
|
+
@playbin=Gst::ElementFactory.make('playbin')
|
30
|
+
@playbin.ready
|
31
|
+
@playbin.bus.add_watch {|bus, message| got_bus_message(message)}
|
32
|
+
end
|
33
|
+
|
34
|
+
def stop
|
35
|
+
@playing=false
|
36
|
+
@playbin.stop
|
37
|
+
ErrorInfo.new("Player stopped.")
|
38
|
+
end
|
39
|
+
|
40
|
+
def play(song)
|
41
|
+
begin
|
42
|
+
@playing=true
|
43
|
+
@playbin.uri=GLib.filename_to_uri(song.path)
|
44
|
+
@playbin.play
|
45
|
+
ErrorInfo.new("Playing #{song.name}.")
|
46
|
+
rescue
|
47
|
+
ErrorError.new(_("Playing file://#{song.path}"))
|
48
|
+
@gui.next_song
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def pause
|
53
|
+
if playing?
|
54
|
+
@playing=false
|
55
|
+
@playbin.pause
|
56
|
+
ErrorInfo.new("Pause.")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def playing?
|
61
|
+
@playing
|
62
|
+
end
|
63
|
+
|
64
|
+
def position
|
65
|
+
q=Gst::QueryPosition.new(Gst::Format::Type::TIME)
|
66
|
+
@playbin.query(q)
|
67
|
+
q.parse[1]/1000000000
|
68
|
+
end
|
69
|
+
|
70
|
+
def position=(pos)
|
71
|
+
@playbin.send_event(Gst::EventSeek.new(1.0,
|
72
|
+
Gst::Format::Type::TIME, Gst::Seek::FLAG_FLUSH.to_i | Gst::Seek::FLAG_KEY_UNIT.to_i, Gst::Seek::TYPE_SET,
|
73
|
+
pos*1000000000, Gst::Seek::TYPE_NONE, -1))
|
74
|
+
#@playbin.seek(1.0, Gst::Format::Type::TIME, Gst::Seek::FLAG_FLUSH.to_i | Gst::Seek::FLAG_KEY_UNIT.to_i, Gst::Seek::TYPE_SET, pos*1000000000, Gst::Seek::TYPE_NONE, -1)
|
75
|
+
#Arguments for Gst::EventSeek taken from the ruby-gstreamer0.10 (and not from ruby-gnome2) binding examples (cf:video-player)
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
def duration
|
80
|
+
q=Gst::QueryDuration.new(Gst::Format::Type::TIME)
|
81
|
+
@playbin.query(q)
|
82
|
+
q.parse[1]/1000000000
|
83
|
+
end
|
84
|
+
|
85
|
+
def volume
|
86
|
+
@playbin.volume
|
87
|
+
end
|
88
|
+
|
89
|
+
def volume=(n)
|
90
|
+
@playbin.volume=n
|
91
|
+
ErrorInfo.new("Set volume to #{n}.")
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
begin
|
97
|
+
Gst::InstallPlugins
|
98
|
+
def got_bus_message(message)
|
99
|
+
case message
|
100
|
+
when Gst::Message::ERROR
|
101
|
+
ErrorError.new(_("Gstreamer error."), true)
|
102
|
+
@gui.next_song_on_error
|
103
|
+
when Gst::Message::EOS
|
104
|
+
@gui.next_song#Use Dbus to propagate message instead of :gui or a SIGNAL???
|
105
|
+
when Gst::MissingMessage
|
106
|
+
ErrorInfo.new("Missing plugins.")
|
107
|
+
context=Gst::InstallPluginsContext.new
|
108
|
+
Gst::InstallPlugins.async([message.installer_detail], context){|ret|
|
109
|
+
case ret
|
110
|
+
when Gst::InstallPluginsReturn::SUCCESS, Gst::InstallPluginsReturn::PARTIAL_SUCCESS
|
111
|
+
@gui.update_gst_registry
|
112
|
+
else
|
113
|
+
ErrorInfo.new("Missing plugins return: "+ret.name)
|
114
|
+
@gui.next_song
|
115
|
+
end
|
116
|
+
}
|
117
|
+
end
|
118
|
+
true#Without this line only the first message is processed
|
119
|
+
end
|
120
|
+
rescue NameError
|
121
|
+
def got_bus_message(message)
|
122
|
+
case message.type
|
123
|
+
when Gst::Message::ERROR
|
124
|
+
ErrorError.new(_("Gstreamer error."), true)
|
125
|
+
@gui.next_song_on_error
|
126
|
+
when Gst::Message::EOS
|
127
|
+
@gui.next_song#Use Dbus to propagate message instead of :gui or a SIGNAL???
|
128
|
+
end
|
129
|
+
true#Without this line only the first message is processed
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Copyright 2007-2011 Vincent Carmona
|
4
|
+
vinc4mai@gmail.com
|
5
|
+
|
6
|
+
This file is part of ZiK.
|
7
|
+
|
8
|
+
ZiK is free software; you can redistribute it and/or modify
|
9
|
+
it under the terms of the GNU General Public License as published by
|
10
|
+
the Free Software Foundation; either version 2 of the License, or
|
11
|
+
(at your option) any later version.
|
12
|
+
|
13
|
+
ZiK is distributed in the hope that it will be useful,
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
GNU General Public License for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License
|
19
|
+
along with ZiK; if not, write to the Free Software
|
20
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
=end
|
22
|
+
module Radio
|
23
|
+
class Player < Player
|
24
|
+
def play(radio)
|
25
|
+
@streams=[]
|
26
|
+
begin
|
27
|
+
url=radio.url
|
28
|
+
case url
|
29
|
+
when /^http:\/\/.*\.m3u$/i
|
30
|
+
list=get_list(url)
|
31
|
+
@streams=list.to_a
|
32
|
+
@streams.reject!{|a| a=~/^\#/}
|
33
|
+
@streams.each{|a| a.chomp!}
|
34
|
+
when /^http:\/\/.*\.pls$/i, /^http:\/\/.*\.asx$/i
|
35
|
+
list=get_list(url)
|
36
|
+
@streams=URI::extract(list)
|
37
|
+
else
|
38
|
+
@streams=url.to_a
|
39
|
+
end
|
40
|
+
rescue
|
41
|
+
ErrorError.new(_("Parsing #{radio.url}."), true)
|
42
|
+
end
|
43
|
+
@i=-1
|
44
|
+
next_stream
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def get_list(url)
|
50
|
+
reponse=Net::HTTP.get_response(URI.parse(url))
|
51
|
+
case reponse
|
52
|
+
when Net::HTTPSuccess
|
53
|
+
list=reponse.body
|
54
|
+
when Net::HTTPRedirection
|
55
|
+
ErrorWarning.new("#{url} is moved to #{reponse['location']}")
|
56
|
+
list=Net::HTTP.get(URI.parse(reponse['location']))
|
57
|
+
else
|
58
|
+
ErrorError.new(response.error!)
|
59
|
+
raise response.error!
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
begin
|
64
|
+
Gst::InstallPlugins
|
65
|
+
def got_bus_message(message)
|
66
|
+
case message.type
|
67
|
+
when Gst::Message::ERROR
|
68
|
+
ErrorError.new(_('Gstreamer error'), true)
|
69
|
+
stop
|
70
|
+
next_stream
|
71
|
+
when Gst::Message::EOS
|
72
|
+
@gui.next_song#Use Dbus to propagate message instead of :gui ???
|
73
|
+
when Gst::MissingMessage
|
74
|
+
ErrorInfo.new("Missing plugins.")
|
75
|
+
context=Gst::InstallPluginsContext.new
|
76
|
+
Gst::InstallPlugins.async([message.installer_detail], context){|ret|
|
77
|
+
case ret
|
78
|
+
when Gst::InstallPluginsReturn::SUCCESS, Gst::InstallPluginsReturn::PARTIAL_SUCCESS
|
79
|
+
@gui.update_gst_registry
|
80
|
+
else
|
81
|
+
ErrorInfo.new("Missing plugins return: "+ret.name)
|
82
|
+
stop
|
83
|
+
next_stream
|
84
|
+
end
|
85
|
+
}
|
86
|
+
end
|
87
|
+
true#Without this line only the first message is processed
|
88
|
+
end
|
89
|
+
rescue NameError
|
90
|
+
def got_bus_message(message)
|
91
|
+
case message.type
|
92
|
+
when Gst::Message::ERROR
|
93
|
+
ErrorError.new(_('Gstreamer error'), true)
|
94
|
+
stop
|
95
|
+
next_stream
|
96
|
+
when Gst::Message::EOS
|
97
|
+
@gui.next_song#Use Dbus to propagate message instead of :gui ???
|
98
|
+
end
|
99
|
+
true#Without this line only the first message is processed
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def next_stream
|
104
|
+
@i+=1
|
105
|
+
if @i<@streams.length
|
106
|
+
begin
|
107
|
+
@playing=true
|
108
|
+
@playbin.uri=@streams[@i]
|
109
|
+
##On some platform total freeze can happened when playing some webradio.
|
110
|
+
##i.e. http://mp3.live.tv-radio.com/centpourcent/all/centpourcent-128k.mp3
|
111
|
+
##gstreamer-good-plugin/souphttpsrc + ruby/gtk may be in cause.
|
112
|
+
##Using a thread as a workaround
|
113
|
+
##Thread.new{@playbin.play}.join also freeze!!
|
114
|
+
#@playbin.play
|
115
|
+
#puts "Playing #{@streams[@i]}."
|
116
|
+
Thread.new{@playbin.play; ErrorInfo.new("Playing #{@streams[@i]}.")}
|
117
|
+
rescue
|
118
|
+
ErrorError.new(_("Playing #{@streams[@i]}"), true)
|
119
|
+
next_stream
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
data/playlist/cdlist.rb
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Copyright 2007-2011 Vincent Carmona
|
4
|
+
vinc4mai@gmail.com
|
5
|
+
|
6
|
+
This file is part of ZiK.
|
7
|
+
|
8
|
+
ZiK is free software; you can redistribute it and/or modify
|
9
|
+
it under the terms of the GNU General Public License as published by
|
10
|
+
the Free Software Foundation; either version 2 of the License, or
|
11
|
+
(at your option) any later version.
|
12
|
+
|
13
|
+
ZiK is distributed in the hope that it will be useful,
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
GNU General Public License for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License
|
19
|
+
along with ZiK; if not, write to the Free Software
|
20
|
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
21
|
+
=end
|
22
|
+
module Cd
|
23
|
+
|
24
|
+
class Song
|
25
|
+
attr_reader :track, :duration, :name, :type
|
26
|
+
attr_accessor :artist, :album, :title
|
27
|
+
|
28
|
+
def initialize(track, duration)
|
29
|
+
@track=track; @duration=duration
|
30
|
+
@artist=''; @album=''; @title=''
|
31
|
+
@type=SONG_CD
|
32
|
+
refresh_name
|
33
|
+
end
|
34
|
+
|
35
|
+
def refresh_name
|
36
|
+
if @title.empty?
|
37
|
+
@name='Track '+@track.to_s
|
38
|
+
else
|
39
|
+
if @artist.empty?
|
40
|
+
@name=@title
|
41
|
+
else
|
42
|
+
@name=@artist+' - '+@title
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class List
|
49
|
+
include ListPlay
|
50
|
+
|
51
|
+
attr_reader :songs, :current
|
52
|
+
attr_writer :web
|
53
|
+
|
54
|
+
def initialize(config)
|
55
|
+
@songs=[]
|
56
|
+
@order=[]
|
57
|
+
@config=config
|
58
|
+
@shuffle=config['shuffle'];@repeat=config['repeat']
|
59
|
+
@web=config['cd_web']
|
60
|
+
|
61
|
+
@current=0; @n=0
|
62
|
+
|
63
|
+
@mb=MusicBrainz::Client.new
|
64
|
+
#@mb.utf8=true
|
65
|
+
refresh
|
66
|
+
|
67
|
+
@current=@order[0] if @shuffle
|
68
|
+
end
|
69
|
+
|
70
|
+
def device=(device)
|
71
|
+
@mb.device=device
|
72
|
+
end
|
73
|
+
|
74
|
+
def clear
|
75
|
+
@songs.clear
|
76
|
+
@order.clear
|
77
|
+
@current=0; @n=0
|
78
|
+
end
|
79
|
+
|
80
|
+
def refresh
|
81
|
+
refresh_off
|
82
|
+
refresh_on if @web
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def refresh_on
|
88
|
+
refresh_off
|
89
|
+
if @mb.query(MusicBrainz::Query::GetCDInfo)
|
90
|
+
nbAlbums=@mb.result(MusicBrainz::Query::GetNumAlbums).to_i
|
91
|
+
if nbAlbums < 1
|
92
|
+
ErrorWarning.new("No album found.")
|
93
|
+
else
|
94
|
+
if nbAlbums >1
|
95
|
+
ErrorWarning.new("#{nbAlbums} albums are found. Use the first one.")
|
96
|
+
end
|
97
|
+
@mb.select(MusicBrainz::Query::SelectAlbum, 1)
|
98
|
+
album=@mb.result(MusicBrainz::Query::MBE_AlbumGetAlbumName)
|
99
|
+
nbTracks=@mb.result(MusicBrainz::Query::AlbumGetNumTracks).to_i
|
100
|
+
for i in 1..nbTracks
|
101
|
+
artist=@mb.result(MusicBrainz::Query::MBE_AlbumGetArtistName, i)
|
102
|
+
title=@mb.result(MusicBrainz::Query::MBE_AlbumGetTrackName, i)
|
103
|
+
s=@songs[i-1]
|
104
|
+
s.artist=artist;s.album=album;s.title=title;s.refresh_name
|
105
|
+
end
|
106
|
+
end
|
107
|
+
else
|
108
|
+
ErrorWarning.new("CD not found on MusicBrainz.")
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def refresh_off
|
113
|
+
self.clear
|
114
|
+
self.device=@config['cd_device']
|
115
|
+
if @mb.query(MusicBrainz::Query::GetCDTOC)
|
116
|
+
nbTracks=@mb.result(MusicBrainz::Query::TOCGetLastTrack).to_i
|
117
|
+
offset=[]
|
118
|
+
for i in 1..nbTracks+1
|
119
|
+
offset.push(@mb.result(MusicBrainz::Query::TOCGetTrackSectorOffset, i).to_i)
|
120
|
+
end
|
121
|
+
offset.sort!#Apparently the offset are not given in tracks order.
|
122
|
+
temp=[];temp[0]=0;temp.concat(offset[0...nbTracks])
|
123
|
+
d=[]
|
124
|
+
[temp, offset].transpose.each{|a,b|
|
125
|
+
dur=((b-a+1).to_f/75.0).round#Calcul track duration from frame offset.
|
126
|
+
d.push(dur)
|
127
|
+
}
|
128
|
+
d.delete_at(0)
|
129
|
+
i=1
|
130
|
+
d.each{|duration|
|
131
|
+
@songs.push(Cd::Song.new(i, duration))
|
132
|
+
@order.push(i-1)
|
133
|
+
i+=1
|
134
|
+
}
|
135
|
+
@order.sort_by{rand}
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|