Class: Jabber::UserTune::Helper

Class | Jabber::UserTune::Helper
In: | lib/xmpp4r/tune/helper/helper.rb
Parent: | PubSub::ServiceHelper

A Helper for XEP-0118 User Tune

Use this helper to send user tunes, or receive them from a specified jid. Described at www.xmpp.org/extensions/xep-0118.html

For example: <pre> h = UserTune::Helper( @client, ‘radio1@hug.hellomatty.com’ ) h.add_usertune_callback do |tune|

      puts "Now playing: #{tune.title} by #{tune.artist}"

end </pre>

Also see the examples provided.

### Methods

add_usertune_callback now_playing stop_playing

### Public Instance methods

add_usertune_callback(prio = 200, ref = nil, &block)

Add a callback that will be invoked when a tune is received from the jid specified when you constructed the Helper.

[Source]

        # File lib/xmpp4r/tune/helper/helper.rb, line 48
    48:       def add_usertune_callback(prio = 200, ref = nil, &block)
    49:         add_event_callback(prio, ref) do |event|
    50:           tune = event.first_element('items/item/tune')
    51:           if tune
    52:             block.call(tune)
    53:           end
    54:         end
    55:       end

now_playing(track)

Send out the tune currently playing.

track: | [Jabber::UserTune::Tune] the tune currently playing

[Source]

        # File lib/xmpp4r/tune/helper/helper.rb, line 31
    31:       def now_playing(track)
    32:         item = Jabber::PubSub::Item.new()
    33:         item.add(track)
    34:
    35:         publish_item_to(NS_USERTUNE, item)
    36:       end

stop_playing()

Use this method to indicate that you have stopped playing a tune.

[Source]

        # File lib/xmpp4r/tune/helper/helper.rb, line 41
    41:       def stop_playing
    42:         now_playing(Jabber::UserTune::Tune.new())
    43:       end

[Validate]