了解两键评级实施

Understanding two-button ratings implementation

我正在我们的平台上实施两键评级,我正在为一些更精细的细节而烦恼。

首先,我真的很想在这里简明扼要地解释我遇到的问题!

我们通过 rateItemgetExtendedMetadata 端点处理和返回三种状态,用户可以在三种状态之间移动:

0 - Unrated
1 - Up voted
2 - Down voted

因此 rateItem 接受这三个选项之一。

documentation,我的演示图应该是这样的。

 <Match propname="vote" value="0">
  <!-- the track is unrated -->
  <Ratings>
   <Rating AutoSkip="NEVER" Id="1" StringId="VoteUp" OnSuccessStringId="VoteUpSuccess">
    ...
   </Rating>
   <Rating AutoSkip="ALWAYS" Id="0" StringId="VoteDown" OnSuccessStringId="VoteDownSuccess">
    ...
   </Rating>
  </Ratings>
 </Match>
 <Match propname="vote" value="1">
  <!-- the track is rated thumbs up -->
  <Ratings>
   <Rating AutoSkip="NEVER" Id="3" StringId="VoteUp" OnSuccessStringId="VoteUpSuccess">
    ...
   </Rating>
   <Rating AutoSkip="ALWAYS" Id="2" StringId="VoteDown" OnSuccessStringId="VoteDownSuccess">
    ...
   </Rating>
  </Ratings>
 </Match>
 <Match propname="vote" value="2">
  <!-- the track is rated thumbs down -->
  <Ratings>
   <Rating AutoSkip="NEVER" Id="5" StringId="VoteUp" OnSuccessStringId="VoteUpSuccess">
    ...
   </Rating>
   <Rating AutoSkip="ALWAYS" Id="6" StringId="VoteDown" OnSuccessStringId="VoteDownSuccess">
    ...
   </Rating>
  </Ratings>
 </Match>

这是我开始遇到麻烦的地方。 <Match ... value="X"> 元素看起来很好并且与我的数据显示的相匹配。 但是当单击按钮时,rateItem 端点似乎接收 ID 0 到 6。(示例中缺少 ID 4?)

文档指出:

Id (int) This is the value that will be passed to the rateItem method. The Id must be unique for the given property name.

因此,为了解决这个问题,我修改了演示图,以便从 0 匹配 属性 发送的 ID 为 1 和 2(投票赞成和反对)。然后有一个链接到 0 和 2 的 1 匹配 属性,以及一个链接到 0 和 1 的 2。这就是我所在的位置:

 <Match propname="vote" value="0">
  <!-- the track is unrated -->
  <Ratings>
   <Rating AutoSkip="NEVER" Id="1" StringId="VoteUp" OnSuccessStringId="VoteUpSuccess">
    ...
   </Rating>
   <Rating AutoSkip="NEVER" Id="2" StringId="VoteDown" OnSuccessStringId="VoteDownSuccess">
    ...
   </Rating>
  </Ratings>
 </Match>
 <Match propname="vote" value="1">
  <!-- the track is rated thumbs up -->
  <Ratings>
   <Rating AutoSkip="NEVER" Id="0" StringId="VoteUpCancel" OnSuccessStringId="VoteUpCancelSuccess">
    ...
   </Rating>
   <Rating AutoSkip="NEVER" Id="2" StringId="VoteDown" OnSuccessStringId="VoteDownSuccess">
    ...
   </Rating>
  </Ratings>
 </Match>
 <Match propname="vote" value="2">
  <!-- the track is rated thumbs down -->
  <Ratings>
   <Rating AutoSkip="NEVER" Id="1" StringId="VoteUp" OnSuccessStringId="VoteUpSuccess">
    ...
   </Rating>
   <Rating AutoSkip="NEVER" Id="0" StringId="VoteDownCancel" OnSuccessStringId="VoteDownCancelSuccess">
    ...
   </Rating>
  </Ratings>
 </Match>

请注意,字符串 ID 也已更新,我相信我的字符串文件和图像都没有问题。

这对我来说很有意义,但确实会丢弃我的图像和警报,而且我在不同平台上的结果各不相同(目前已在 iOS 和 Mac 控制器上进行测试)。

至此,有谁能给点建议吗?我希望我在这里有足够的意义!如果有人能提供任何提示,我将不胜感激。

根据 http://musicpartners.sonos.com/node/368 上的文档,您的第一个示例是正确的,id 是您应该在 rateItem 端点上看到的内容。该值描述了一个更一般的类别(赞成、不赞成、中立),但 id 是该类别中的特定状态。在您的第二个示例中,您在同一 propname 中重复 ID 号,这就是您看到不一致行为的原因。

一般来说,流程应该如下所示,当 rateItem 请求通过 ID 中的唯一标识符进入您的服务时,您应该可以在后端对曲目进行适当的评级。您应该使用 rateItemResponse 进行响应,然后是 getLastUpdate 请求(这将更新连接到家庭的所有控制器的评级状态)和 getExtendedMetdata 请求,以便可以将 属性 值更新为与发送的 ID 关联的那个。