RatingTemplate get rating?

https://developer.apple.com/library/prerelease/tvos/documentation/LanguagesUtilities/Conceptual/ATV_Template_Guide/RatingTemplate.html#//apple_ref/doc/uid/TP40015064-CH39-SW6


How can i parse the rating?


i have tried:

addEventListener('select', function (e) { //click also does not work
      console.log(e)
      var pressed = e.target.innerHTML
      console.log(pressed)
})


but this will never be called even if i press on the touchpad


how can i arrange that?


Thanks in advance.

Replies

Full code:


var tvOS = {
  /*
   * RatingView
   *
   * create a nice RatingView (with support of objects)
   *
   * @todo
   * @param string title the title of your RatingView
   * @param string rating the default/averange rating
   * @param string [callback] function to relay on (Does not work)
   * @example tvOS.RatingView(title, rating, callback)
   */
  RatingView: function (title, rating, callback) {
    var temp = ''

    temp += tvOS.TemplateRatingView.replace('tvOS_title', title)
                                   .replace('tvOS_rating', rating)


    temp = tvOS.makeDocument(temp)
    temp.addEventListener('select', function (e) {
      console.log(e)
      var pressed = e.target.innerHTML
      console.log(pressed)
    })


    tvOS.display(temp)
  },

  /*
   * makeDocument
   *
   * make Document with resource
   *
   * @param string resource the resource
   * @example tvOS.makeDocument(xmlString)
   */
  makeDocument: function (resource) {
    if (!tvOS.parser) {
      tvOS.parser = new DOMParser()
    }


    var doc = tvOS.parser.parseFromString(resource, 'application/xml')
    return doc
  },

  /*
   * display
   *
   * to display a view
   *
   * @param mixed view the view you want to display
   * @example tvOS.display(view)
   */
  display: function (view) {
    navigationDocument.pushDocument(view)
  },

  // * tvOS.TemplateRatingView
  // *
  // * Template for TemplateRating
  // *
  // * @var string TemplateRatingView
  TemplateRatingView: `<?xml version="1.0" encoding="UTF-8"?>
<document>
  <ratingTemplate theme="light">
      <title>tvOS_title</title>
      <ratingBadge value="tvOS_rating"></ratingBadge>
  </ratingTemplate>
</document>`
}

I am in the same boat, did you ever figure out how to get the selected rating?

add the event listener for type "change" instead of select, and as user is changing the rating, the event gets dispatched with new value