Sha256: d91ba2780d4de9b2ed8c92f0e96668f8a37b6bf997244f4970cea49a0e275e32

Contents?: true

Size: 1.06 KB

Versions: 32

Compression:

Stored size: 1.06 KB

Contents

#!/usr/bin/env ruby

$:.unshift '../../../../../lib'

require 'xmpp4r'
require 'xmpp4r/roster'
require 'xmpp4r/tune'
require 'rbosa'

#
# Send XEP-0118 User Tune events...
#
# See Jabber::UserTune::Helper for the gory details...
#
# NB needs rbosa library to access iTunes - only on MacOSX
#

if ARGV.length != 2:
  puts "Usage: ruby tune_server.rb <jid> <pw>"
  exit 1
end

jid=ARGV[0]
pw=ARGV[1]

Jabber::debug=true

cl = Jabber::Client.new(jid)
cl.connect
cl.auth(pw)

# Following XEP-0163 PEP we need to
# ensure we have a 'both' subscription to the Tune client
roster = Jabber::Roster::Helper.new(cl)
roster.add_subscription_request_callback do |item,pres|
  roster.accept_subscription(pres.from)

  reply = pres.answer
  reply.type = :subscribe
  cl.send(reply)
end

cl.send(Jabber::Presence.new.set_show(:chat))

t=Jabber::UserTune::Helper.new(cl, nil)

itunes=OSA.app('iTunes')

loop do
  track = itunes.current_track

  if track
    puts "Now playing: #{track.name} by #{track.artist}"
    t.now_playing(Jabber::UserTune::Tune.new(track.artist, track.name))
  end

  sleep 5
end

Version data entries

32 entries across 32 versions & 11 rubygems

Version Path
brontes3d-xmpp4r-0.4 data/doc/xmpp4r/examples/basic/tune_server.rb
edavey-xmpp4r-0.4.1 data/doc/xmpp4r/examples/basic/tune_server.rb
edavey-xmpp4r-0.4.2 data/doc/xmpp4r/examples/basic/tune_server.rb
edavey-xmpp4r-0.4 data/doc/xmpp4r/examples/basic/tune_server.rb
ln-xmpp4r-0.5 data/doc/xmpp4r/examples/basic/tune_server.rb
mojodna-xmpp4r-0.4.0.2 data/doc/xmpp4r/examples/basic/tune_server.rb
mojodna-xmpp4r-0.4.0.3 data/doc/xmpp4r/examples/basic/tune_server.rb
seanohalpin-xmpp4r-0.4.1 data/doc/xmpp4r/examples/basic/tune_server.rb
xmpp4r-0.5.6 data/doc/xmpp4r/examples/basic/tune_server.rb
xmpp4r-0.5.5 data/doc/xmpp4r/examples/basic/tune_server.rb
gmcmillan-xmpp4r-0.6.2 data/doc/xmpp4r/examples/basic/tune_server.rb
gmcmillan-xmpp4r-0.6.1 data/doc/xmpp4r/examples/basic/tune_server.rb
gmcmillan-xmpp4r-0.6 data/doc/xmpp4r/examples/basic/tune_server.rb
gmcmillan-xmpp4r-0.5 data/doc/xmpp4r/examples/basic/tune_server.rb
mad-p-xmpp4r-0.6.3 data/doc/xmpp4r/examples/basic/tune_server.rb
mad-p-xmpp4r-0.6.2 data/doc/xmpp4r/examples/basic/tune_server.rb
mad-p-xmpp4r-0.6.1 data/doc/xmpp4r/examples/basic/tune_server.rb
mad-p-xmpp4r-0.6.0 data/doc/xmpp4r/examples/basic/tune_server.rb
cerberus-0.8.0 lib/vendor/xmpp4r/data/doc/xmpp4r/examples/basic/tune_server.rb
cerberus-0.7.9 lib/vendor/xmpp4r/data/doc/xmpp4r/examples/basic/tune_server.rb