gswax 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  =begin
2
2
 
3
3
  gsWax
4
- v 0.12.01
4
+ v 0.0.2
5
5
 
6
6
  an audio player for folks who miss their vinyl
7
7
 
@@ -79,7 +79,7 @@ Shoes.app(width: (727 * scl), height: (675 * scl), title: "gsWax") do
79
79
  when "PREVIOUS_TRACK"; previous_track
80
80
  when "NEXT_TRACK"; next_track
81
81
  when "SHUFFLE_TOGGLE"; toggle_wax_shuffle
82
- when "PLAYLIST_CLOSED"; @browser.delete_observer(@playlist) if @browser; @playlist = nil
82
+ when "PLAYLIST_CLOSED"; @playlist = nil
83
83
  when "BROWSER_CLOSED"; @browser = nil
84
84
  when "SETTINGS_CLOSED"; @settings_man = nil
85
85
  end
@@ -105,8 +105,10 @@ Shoes.app(width: (727 * scl), height: (675 * scl), title: "gsWax") do
105
105
 
106
106
  if pos == "prepend"
107
107
  tracks.reverse.each{|e| wax_lineup.insert(0, e)}
108
+ tracks.shuffle.each{|e| wax_lupine.insert(0, e)}
108
109
  else
109
110
  tracks.each{|e| wax_lineup << e}
111
+ tracks.shuffle.each{|e| wax_lupine << e}
110
112
  end
111
113
 
112
114
  if flag
@@ -119,18 +121,30 @@ Shoes.app(width: (727 * scl), height: (675 * scl), title: "gsWax") do
119
121
  def data_drop(data, context)
120
122
  raw = CGI.unescape(data)
121
123
  arr = raw.chomp.split("file:#{File::Separator}#{File::Separator}")
122
- path = arr[-1]
123
124
  okfiles = [/.mp3/, /.flac/, /.ogg/, /.wav/]
124
125
  selected = []
125
-
126
- if File.directory?(path)
127
- Find.find(path){|item|
128
- okfiles.each{|ok| selected << item if item.downcase =~ ok}
129
- }
130
- elsif File.exists?(path)
131
- okfiles.each{|ok| selected << path if path.downcase =~ ok}
132
- end
133
126
 
127
+ arr.each{|path|
128
+ path.chomp!
129
+ if File.directory?(path)
130
+ Find.find(path){|item|
131
+ okfiles.each{|ok| selected << item if File.extname(item.downcase) =~ ok}
132
+ }
133
+ elsif File.file?(path)
134
+ ext = File.extname(path.downcase)
135
+ okfiles.each{|ok| selected << path if ext =~ ok}
136
+ if ext == ".pls" or ext == ".m3u"
137
+ File.open(path){|file|
138
+ file.each_line{|line|
139
+ if line.include?("http:")
140
+ selected << /http.+/.match(line).to_s
141
+ end
142
+ }
143
+ }
144
+ end
145
+ end
146
+ }
147
+
134
148
  add_to_list(selected)
135
149
  @playlist.add(selected) if @playlist
136
150
 
@@ -146,7 +160,7 @@ Shoes.app(width: (727 * scl), height: (675 * scl), title: "gsWax") do
146
160
  dir = Settings.music_dir
147
161
  end
148
162
  else
149
- dir = Settings.brains_dir
163
+ dir = File.dirname(File.expand_path(__FILE__))
150
164
  end
151
165
  @browser = DirBrowser.new(dir)
152
166
  @browser.add_observer(self, :on_signals)
@@ -156,10 +170,7 @@ Shoes.app(width: (727 * scl), height: (675 * scl), title: "gsWax") do
156
170
 
157
171
  def playlist(list)
158
172
  if @playlist
159
- #@playlist.delete_observers
160
- @browser.delete_observer(@playlist) if @browser
161
- @playlist.close_window
162
- @playlist = nil
173
+ @playlist.close_window; @playlist = nil
163
174
  else
164
175
  @playlist = PlayList.new; @playlist.add(list)
165
176
  @playlist.add_observer(self, :on_signals)
@@ -171,7 +182,9 @@ Shoes.app(width: (727 * scl), height: (675 * scl), title: "gsWax") do
171
182
  stop_wax if wax_state != "stopped"
172
183
  f_name = message[1]
173
184
  Settings.playlist_file = f_name
174
- self.wax_batter = 0
185
+ Settings.line_up.clear
186
+ tracks = message[2..-1]
187
+ tracks.each{|track| Settings.line_up << track}
175
188
  read_wax_lineup
176
189
  @table.update(Settings.at_bat)
177
190
  @info_area.set_text("gsWax - ready to rock")
@@ -199,14 +212,16 @@ Shoes.app(width: (727 * scl), height: (675 * scl), title: "gsWax") do
199
212
 
200
213
  def track_progress
201
214
  unless @tracking
202
- GLib::Timeout.add(100){
215
+ timeout = GLib::Timeout.add(100){
203
216
  if wax_state == "playing"
204
- pos_query = Gst::QueryPosition.new(3)#(Gst::Format::Time)
205
- wax_pipeline.query(pos_query)
206
- track_pos = pos_query.parse[1] / 10000.0
207
- arm_pos =(((track_pos * 1.0) / wax_duration) / 1000.0).round(1)
208
- @table.set_arm_pos(arm_pos)
209
- @tracking = true
217
+ if wax_tracking
218
+ pos_query = Gst::QueryPosition.new(3)
219
+ wax_pipeline.query(pos_query)
220
+ track_pos = pos_query.parse[1] / 10000.0
221
+ arm_pos =(((track_pos * 1.0) / wax_duration) / 1000.0).round(1)
222
+ @table.set_arm_pos(arm_pos)
223
+ @tracking = true
224
+ end
210
225
  else
211
226
  @tracking = false
212
227
  false
@@ -225,7 +240,7 @@ Shoes.app(width: (727 * scl), height: (675 * scl), title: "gsWax") do
225
240
  if wax_lineup.empty?
226
241
  wax_lineup << track
227
242
  batter_up_wax
228
- playpause_track
243
+ play_pause_track
229
244
  else
230
245
  wax_lineup.insert(wax_batter + 1, track) unless Settings.shuffle
231
246
  wax_lupine.insert(wax_batter + 1, track) if Settings.shuffle
@@ -236,7 +251,7 @@ Shoes.app(width: (727 * scl), height: (675 * scl), title: "gsWax") do
236
251
  end
237
252
 
238
253
  def play_pause_track
239
- playpause_wax
254
+ play_pause_wax
240
255
  @table.set_state(wax_state)
241
256
  track_progress
242
257
  end
@@ -263,7 +278,7 @@ Shoes.app(width: (727 * scl), height: (675 * scl), title: "gsWax") do
263
278
  def seek(percent)
264
279
  if wax_duration
265
280
  sought = wax_duration * percent
266
- seek_to_wax((sought * 1000.0).round)
281
+ seek_to_wax((sought * 1000.0).round)
267
282
  @table.set_arm_pos(percent)
268
283
  end
269
284
  end
@@ -1,6 +1,6 @@
1
1
  =begin
2
2
 
3
- this file is part of: gsWax v. 0.12.01
3
+ this file is part of: gsWax v. 0.0.2
4
4
 
5
5
  You should have received a copy of the GNU General Public License
6
6
  along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -14,7 +14,7 @@ module Wax
14
14
  include Observable
15
15
 
16
16
  attr_accessor :wax_coverart, :wax_duration, :wax_state, :wax_pipeline,
17
- :wax_batter, :wax_lineup, :wax_lupine, :wax_info
17
+ :wax_batter, :wax_lineup, :wax_lupine, :wax_info, :wax_tracking
18
18
 
19
19
  #----------------------
20
20
  # INITIALIZE
@@ -30,7 +30,7 @@ module Wax
30
30
 
31
31
  def read_wax_lineup
32
32
  @wax_lineup = []
33
- unless Settings.line_up.empty?
33
+ if Settings.line_up
34
34
  @wax_lineup = Settings.line_up
35
35
  @wax_info = "gsWax - ready to rock"
36
36
  else
@@ -76,32 +76,37 @@ module Wax
76
76
  if @wax_lineup.empty?
77
77
  batter_up_wax
78
78
  end
79
+ if @stream_thread; @stream_thread.exit; @stream_thread = nil; end
79
80
  if Settings.at_bat
80
- if File.exists?(Settings.at_bat)
81
+ if Settings.at_bat =~ /http:/
82
+ @wax_pipeline.uri = Settings.at_bat
83
+ @wax_tracking = false
84
+ @wax_state = "playing"
85
+ @wax_info = "Stream: #{Settings.at_bat}"
86
+ send_wax_info("wax_info")
87
+ @stream_thread = Thread.new{@wax_pipeline.play}
88
+ elsif File.exists?(Settings.at_bat)
81
89
  @wax_pipeline.uri= GLib.filename_to_uri(Settings.at_bat)
82
- bus = @wax_pipeline.bus
83
- @tagMsg = []
84
-
85
- bus.add_watch {|bus, message|
86
- case message.type
87
- when Gst::Message::ERROR
88
- p message.parse
89
- when Gst::Message::EOS
90
- @wax_state = "stopped"
91
- next_wax
92
- send_wax_info("eos")
93
- when Gst::Message::TAG
94
- @tagMsg << message.structure.entries
95
- get_wax_tags
96
- end
97
- true
98
- }
99
-
90
+ @wax_tracking = true
100
91
  @wax_pipeline.play
101
92
  @wax_state = "playing"
102
93
  get_wax_duration
103
94
  end
104
-
95
+ @tagMsg = []
96
+ @wax_pipeline.bus.add_watch{|bus, message|
97
+ case message.type
98
+ when Gst::Message::ERROR
99
+ p message.parse
100
+ when Gst::Message::EOS
101
+ @wax_state = "stopped"
102
+ next_wax
103
+ send_wax_info("eos")
104
+ when Gst::Message::TAG
105
+ @tagMsg << message.structure.entries
106
+ get_wax_tags
107
+ end
108
+ true
109
+ }
105
110
  else
106
111
  @wax_info = "no tracks"
107
112
  send_wax_info("wax_info")
@@ -177,7 +182,6 @@ module Wax
177
182
  @wax_info = @infoentries.join
178
183
  send_wax_info("wax_info")
179
184
  end
180
-
181
185
  end #get_wax_tags
182
186
 
183
187
 
@@ -185,7 +189,7 @@ module Wax
185
189
  # TRANSPORT
186
190
  #-----------------------
187
191
 
188
- def playpause_wax
192
+ def play_pause_wax
189
193
  if Settings.at_bat
190
194
  if @wax_state == "stopped"
191
195
  play_wax
@@ -254,20 +258,5 @@ module Wax
254
258
  changed
255
259
  notify_observers(info)
256
260
  end
257
-
258
- def xsave_wax_settings(settings)
259
- settings[0] = @wax_roster
260
- if @wax_shuffle == true
261
- settings[1] = "shuffle on"
262
- else
263
- settings[1] = "shuffle off"
264
- end
265
- settings[2] = Settings.at_bat
266
-
267
- File.open(@settings_file, "w"){|file|
268
- settings.each{|entry| file.puts(entry)}
269
- }
270
- end
271
-
272
261
 
273
262
  end #module Wax
@@ -1,6 +1,6 @@
1
1
  =begin
2
2
 
3
- this file is part of: gsWax v. 0.12.01
3
+ this file is part of: gsWax v. 0.0.2
4
4
 
5
5
  You should have received a copy of the GNU General Public License
6
6
  along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -10,7 +10,7 @@
10
10
  class DirBrowser
11
11
  include Observable
12
12
 
13
- def initialize(path = Settings.brains_dir)
13
+ def initialize(path = File.expand_path(File.dirname(__FILE__)))
14
14
  @okfiles = [/.mp3/, /.flac/, /.ogg/, /.wav/]
15
15
  @selected = []
16
16
  @listview = ListView.new # def in shared.rb
@@ -132,12 +132,35 @@ class DirBrowser
132
132
  dirs << iter[1] ? File.directory?(iter[1]) : files << iter[1]
133
133
  }
134
134
 
135
- files.each{|file| @selected << file} if files[0]
135
+ if files[0]
136
+ files.each{|path|
137
+ if File.extname(path.downcase) == ".pls" or File.extname(path.downcase) == ".m3u"
138
+ File.open(path){|file|
139
+ file.each_line{|line|
140
+ if line.include?("http:")
141
+ @selected << /http.+/.match(line).to_s
142
+ end
143
+ }
144
+ }
145
+ else
146
+ @selected << path
147
+ end
148
+ }
149
+ end
136
150
 
137
151
  if dirs[0]
138
152
  dirs.each{|dir|
139
153
  Find.find(dir){|item|
140
- @okfiles.each{|ok| @selected << item if item.downcase =~ ok}
154
+ @okfiles.each{|ok| @selected << item if File.extname(item.downcase) =~ ok}
155
+ if File.extname(item.downcase) == ".pls" or File.extname(item.downcase) == ".m3u"
156
+ File.open(item){|file|
157
+ file.each_line{|line|
158
+ if line.include?("http:")
159
+ @selected << /http.+/.match(line).to_s
160
+ end
161
+ }
162
+ }
163
+ end
141
164
  }
142
165
  }
143
166
  end
@@ -168,7 +191,7 @@ class DirBrowser
168
191
  if File.directory?(item)
169
192
  dirs << item unless File.basename(item)[0] == "."
170
193
  else
171
- @okfiles.each{|ok| files << item if item.downcase =~ ok}
194
+ @okfiles.each{|ok| files << item if File.extname(item.downcase) =~ ok}
172
195
  end
173
196
  end
174
197
  end
@@ -1,6 +1,6 @@
1
1
  =begin
2
2
 
3
- this file is part of: gsWax v. 0.12.01
3
+ this file is part of: gsWax v. 0.0.2
4
4
 
5
5
  You should have received a copy of the GNU General Public License
6
6
  along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -9,7 +9,7 @@
9
9
 
10
10
  class PlayList
11
11
  include Observable
12
- attr_accessor :listview, :main
12
+ attr_accessor :listview
13
13
 
14
14
  def initialize
15
15
  @selected = []
@@ -157,10 +157,10 @@ class PlayList
157
157
  end
158
158
 
159
159
  def save_list
160
- unless Dir.exists?((File.join(Settings.brains_dir, "playlists")))
161
- Dir.mkdir(File.join(Settings.brains_dir, "playlists"))
160
+ unless Dir.exists?(File.dirname(File.expand_path(__FILE__)) + "/playlists/")
161
+ Dir.mkdir(File.dirname(File.expand_path(__FILE__)) + "/playlists/")
162
162
  end
163
- Dir.chdir(File.join(Settings.brains_dir, "playlists")){
163
+ Dir.chdir(File.dirname(File.expand_path(__FILE__)) + "/playlists/"){
164
164
  @savefile = ask_save_file
165
165
  }
166
166
 
@@ -1,6 +1,6 @@
1
1
  =begin
2
2
 
3
- this file is part of: gsWax v. 0.12.01
3
+ this file is part of: gsWax v. 0.0.2
4
4
 
5
5
  You should have received a copy of the GNU General Public License
6
6
  along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -1,6 +1,6 @@
1
1
  =begin
2
2
 
3
- this file is part of: gsWax v. 0.12.01
3
+ this file is part of: gsWax v. 0.0.2
4
4
 
5
5
  You should have received a copy of the GNU General Public License
6
6
  along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -175,7 +175,7 @@ class SettingsManager
175
175
 
176
176
  page2 = Gtk::VBox.new(false, 2)
177
177
  about_frame = Gtk::Frame.new()
178
- about = "gsWax version 0.12.1\nhttps://github.com/lljk/shoeWax/tree/onGreenShoes"
178
+ about = "gsWax version 0.0.2\nhttps://github.com/lljk/gsWax"
179
179
  about_text = Gtk::Label.new(about)
180
180
  about_text.set_alignment(0.05, 0.5)
181
181
  about_text.set_wrap(true)
@@ -196,7 +196,7 @@ class SettingsManager
196
196
  if Settings.music_dir
197
197
  open_dir = Settings.music_dir if File.exists?(Settings.music_dir)
198
198
  else
199
- open_dir = Settings.brains_dir
199
+ open_dir = File.dirname(File.expand_path(__FILE__))
200
200
  end
201
201
  dialog = Gtk::FileChooserDialog.new(
202
202
  nil,nil,
@@ -1,6 +1,6 @@
1
1
  =begin
2
2
 
3
- this file is part of: gsWax v. 0.12.01
3
+ this file is part of: gsWax v. 0.0.2
4
4
 
5
5
  You should have received a copy of the GNU General Public License
6
6
  along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -11,9 +11,9 @@ require 'yaml'
11
11
 
12
12
  module Settings
13
13
 
14
- def self.read
15
- @brains_dir = File.join(File.dirname(File.expand_path(__FILE__)))
16
- @settings_file = File.join(@brains_dir, "settings", "settings.yml")
14
+ def self.read
15
+ brains_dir = File.dirname(File.expand_path(__FILE__))
16
+ @settings_file = File.join(brains_dir, "settings", "settings.yml")
17
17
  if File.exists?(@settings_file)
18
18
  @settings = begin
19
19
  YAML.load(File.open(@settings_file))
@@ -32,24 +32,21 @@ module Settings
32
32
  [0, 0, 0],
33
33
  nil,
34
34
  0.5,
35
- []
35
+ nil
36
36
  ]
37
+ FileUtils.mkdir_p(File.join(brains_dir, "settings"))
37
38
  self.save
38
39
  end
39
40
  end
40
41
 
41
42
  def self.save
42
- #unless File.exists?(@settings_file)
43
- # Dir.mkdir(File.join(@brains_dir, "settings"), 0777)
44
- # File.new(@settings_file, "w")
45
- #end
46
43
  File.open(@settings_file, "w"){|file|
47
- file.write(@settings.to_yaml)
44
+ file.write(@settings.to_yaml)
48
45
  }
49
46
  end
50
47
 
51
48
  def self.brains_dir
52
- @brains_dir
49
+ File.dirname(File.expand_path(__FILE__))
53
50
  end
54
51
 
55
52
  def self.settings
@@ -1,6 +1,6 @@
1
1
  =begin
2
2
 
3
- this file is part of: gsWax v. 0.12.01
3
+ this file is part of: gsWax v. 0.0.2
4
4
 
5
5
  You should have received a copy of the GNU General Public License
6
6
  along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -189,7 +189,7 @@ class Turntable
189
189
  cover_file = File.join(Settings.brains_dir, "images", "no_cover.png")
190
190
  cover_size = 485.0 * Settings.scale
191
191
 
192
- if path
192
+ if path && File.exists?(path)
193
193
  dir = File.dirname(path)
194
194
  Dir.chdir(dir)
195
195
  files = Dir['*.{jpg,JPG,png,PNG,gif,GIF}']
@@ -1,3 +1,3 @@
1
1
  module Gswax
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gswax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-22 00:00:00.000000000 Z
12
+ date: 2012-02-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: green_shoes
16
- requirement: &82768080 !ruby/object:Gem::Requirement
16
+ requirement: &72033980 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *82768080
24
+ version_requirements: *72033980
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: gstreamer
27
- requirement: &82766800 !ruby/object:Gem::Requirement
27
+ requirement: &72033760 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *82766800
35
+ version_requirements: *72033760
36
36
  description: an audio player for folks who miss thier vinyl
37
37
  email:
38
38
  - jakekaiden@gmail.com
@@ -79,7 +79,7 @@ files:
79
79
  - lib/gswax/version.rb
80
80
  - lib/gswax.rb
81
81
  - bin/gswax
82
- homepage: ''
82
+ homepage: https://sites.google.com/site/gswax0/home
83
83
  licenses: []
84
84
  post_install_message:
85
85
  rdoc_options: []
@@ -99,9 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  version: '0'
100
100
  requirements: []
101
101
  rubyforge_project:
102
- rubygems_version: 1.8.10
102
+ rubygems_version: 1.8.15
103
103
  signing_key:
104
104
  specification_version: 3
105
105
  summary: an audio player for folks who miss their vinyl
106
106
  test_files: []
107
- has_rdoc: