Sha256: 6b731b6d7dc3abee56bedcb5caff9c18cdd9f383baa67711c15d1e5ba79cceb2

Contents?: true

Size: 533 Bytes

Versions: 1

Compression:

Stored size: 533 Bytes

Contents

module WebMidi
  Navigator = Native(`navigator`)

  def self.support?
    Native(`navigator.requestMIDIAccess !== undefined`)
  end

  def self.request_access(options = {}, &block)
    raise "WebMIDI not supported" unless support?

    success = lambda do |access|
      block.call Access.new(access)
    end

    failure = lambda do |e|
      fail e
    end

    Navigator
      .requestMIDIAccess(options)
      .then(success, failure)
  end

  def self.new(options = {}, &block)
    self.request_access(options, &block)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-web-midi-0.0.2 opal/web_midi.rb