Edit

thodg/mpd_client/examples/rangeid.rb

Branch :

  • Show log

    Commit

  • Author : Anton Maminov
    Date : 2018-07-31 17:31:06
    Hash : 141cc085
    Message : Rename MPDClient to MPD::Client (#6) * Rename MPDClient to MPD::Client * remove redundants return * Avoid single-line method definitions * nothing special * update readme * add idle example * add rubocop * add .hound.yml * add travis config * add badges to readme * remove rakefile * add rake * revert rakefile * ichange gemspec * add rspec * change travis config * remove rakefile * remove rack-test * add spec * add test * fix rubocop * update badges

  • examples/rangeid.rb
  • # frozen_string_literal: true
    
    require 'bundler'
    Bundler.setup :default
    
    require 'pp'
    require 'logger'
    require 'mpd_client'
    
    MPD::Client.log = Logger.new($stderr)
    
    client = MPD::Client.new
    client.connect('localhost', 6600)
    
    # Get id of the first song in the playllist
    song = client.playlistinfo(1).first
    pp "#{song['artist']} - #{song['title']}"
    song_id = song['id']
    
    # Specifies the portion of the song that shall be played
    client.rangeid(song_id, [60, 70])
    
    # Play the playlist at song 1
    client.play(1)
    
    pp client.status