miniradio_server 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17acc65d9824a7c7b32ab10a75ebc702c34566ebb93ec4a238d55d6717ec63a0
4
- data.tar.gz: ba67e415bfa7917debba0b8be7fcb533f82c2ad9eb87526cd5195d8f999243c8
3
+ metadata.gz: f70ca64739dfbd93c1badac47fb27cfde9a116c7386284f80becd71c018f091d
4
+ data.tar.gz: 9232efa32e08339a155806b2e986c93310840c2d4ad48f6f57adb01227463d2c
5
5
  SHA512:
6
- metadata.gz: 99139bf365e9d7633b607b7ded600fae61ca0e6b68a583fd9c01ba3207049cdb8807f2d5b40cd9d57f1f8bbebdb2e53ee25127db8b2961d256779f4e7a6a0032
7
- data.tar.gz: 44dc0383204af89d1083bc091ba2b8f905d7cc0f60f7693457c7134db4c5dc0ed7423ed52e47fad14fd3daabad1c289ae4f408913ae71e8a1cda5a09a009f84c
6
+ metadata.gz: 2faf237ac46476883a6a5299d5da982d45c9fbb547154871c60587237bde37a6d9b66ae45cd7db2127736d37c7d0e3a8509730e0fd5c51fa12b5fa20e9fc28ed
7
+ data.tar.gz: 6ae6dabe71bb1d51ba29f60c1c2f2389b1029a9657c19a3e5558c342db6884f5cd1f324762988a62bb39e6e9fb5271ee7f1b83401d6ba4bbe3b3d855b6e93d8d
data/README.md CHANGED
@@ -105,12 +105,12 @@ bin/miniradio_server
105
105
 
106
106
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
107
107
 
108
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
108
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org/gems/miniradio_server).
109
109
 
110
110
  ## ToDo
111
111
 
112
112
  * Continuous playback of multiple Music tracks
113
- * Use hls.js to support playback in Chrome.
113
+ * :white_check_mark: ~~Use hls.js to support playback in Chrome.~~
114
114
  * :white_check_mark: ~~Rendering of the Delivered Music list page~~
115
115
  * :white_check_mark: ~~Multilingual support for file names.~~
116
116
 
@@ -3,6 +3,7 @@ require 'rack'
3
3
  require 'open3' # Used in convert_to_hls
4
4
  require 'tilt/slim'
5
5
  require 'mp3info'
6
+ require 'json'
6
7
 
7
8
  # Required to use the handler from Rack 3+
8
9
  # You might need to run: gem install rackup
@@ -6,23 +6,45 @@ html
6
6
  title Miniradio Server
7
7
  link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css" type="text/css"
8
8
  link rel="stylesheet" href="style/main.css" type="text/css"
9
+ script src="https://cdn.jsdelivr.net/npm/hls.js@1"
9
10
  body
10
11
  h1 Straming List
11
12
  table.compact.striped
12
13
  thead
13
14
  tr
14
- th scope="col" #
15
+ th scope="col" Play
15
16
  th scope="col" Title
16
17
  th scope="col" Artist
17
18
  th scope="col" Album
18
19
  tbody
19
20
  - mp3_list.each_with_index do |mp3, i|
20
21
  tr
21
- th scope="row"
22
- a> id='song-#{i+1}' href='./#song-#{i+1}' #{i+1}
23
22
  td
24
- a> href='/stream/#{mp3[:file]}/playlist.m3u8' #{mp3[:title] || mp3[:file]}
23
+ audio controls=true id='audio-#{i+1}'
24
+ td=mp3[:title] || mp3[:file]
25
25
  td=mp3[:artist]
26
26
  td=mp3[:album]
27
+ javascript:
28
+ function setupHLS(audioElementId, streamUrl) {
29
+ const audio = document.getElementById(audioElementId);
30
+
31
+ if (Hls.isSupported()) {
32
+ const hls = new Hls();
33
+ hls.loadSource(streamUrl);
34
+ hls.attachMedia(audio);
35
+ hls.on(Hls.Events.MANIFEST_PARSED, function () {
36
+ console.log(`${audioElementId} loaded`);
37
+ });
38
+ } else if (audio.canPlayType('application/vnd.apple.mpegurl')) {
39
+ // HLS native support browser. ex.Safari
40
+ audio.src = streamUrl;
41
+ } else {
42
+ console.error('This browser cannot play HLS.');
43
+ }
44
+ }
45
+ var mp3s = #{{JSON.generate(mp3_list)}};
46
+ for (let i = 0; i < mp3s.length; i++) {
47
+ setupHLS(`audio-${i+1}`, `/stream/${mp3s[i].file}/playlist.m3u8`);
48
+ }
27
49
  hr
28
50
  p Miniradio ver #{MiniradioServer::VERSION}
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MiniradioServer
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miniradio_server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koichiro Ohba