Остановка шаблона Google TV от рандомизации идентификаторов миниатюр - PullRequest
0 голосов
/ 27 января 2012

Я пытаюсь настроить веб-страницу, которая использует HTML5 Google TV Template 2, который можно найти по адресу https://developers.google.com/tv/web/docs/gtv-templates#template2. Хотя я в растерянности, потому что шаблон рандомизирует идентификаторы эскизов (по какой-то странной причине).

У меня 11 видео, и я хочу связать каждое видео с определенной миниатюрой.Какие-либо предложения?

В http://pastebin.com/L2U54DPZ это «dataprovider.js», который обеспечивает работу шаблона.Буду признателен за любую оказанную помощь.Спасибо

Ответы [ 2 ]

1 голос
/ 28 января 2012

В строке 46 изменить: var num = getRandom (15); в var num = small;

В строке 168 изменить: var videoInfo = sources [getRandom (sources.length)]; в var videoInfo = sources [j];

В строке 170 изменить:

    thumb: 'images/thumbs/thumb' + getThumbId() + '.jpg',

в thumb: 'images / thumbs / thumb' + getThumbId (j) + '.jpg',

0 голосов
/ 13 февраля 2012

Имейте в виду, что примеры Google предназначены для иллюстрации функциональности.Я подозреваю, что это случайный случай. Они просто генерируют некоторые данные для примера.

Я изменил dataprovider.js, чтобы сделать его более понятным и иметь больше контроля.измененная версия выглядит так:

 var gtv = gtv || {
  jq: {}
};

/**
 * DataProvider class. Defines a provider for all data (Categories, Images & Videos) shown in the template.
 */
gtv.jq.DataProvider = function() {
};

/**
 * Returns all data shown in the template..
 * @return {object} with the following structure:
 *    - categories -> [category1, category2, ..., categoryN].
 *    - category -> {name, videos}.
 *    - videos -> {thumb, title, subtitle, description, sources}
 *    - sources -> [source1, source2, ..., sourceN]
 *    - source -> string with the url | {src, type, codecs}
 */
gtv.jq.DataProvider.prototype.getData = function() {
  var event_videos = [
    {
      sources: ['http://commondatastorage.googleapis.com/gtv_template_assets/IO2010-Keynote-day1.mp4'],
      title: '2010 Day 1 Keynote',
      thumb: 'images/thumbs/thumb01.jpg',
      description: ['With Vic Gundotra'],
      subtitle: 'Moscone Center'
    },
    {
      sources:['http://commondatastorage.googleapis.com/gtv_template_assets/IO2010-Keynote-day2-android.mp4'],
      title: '2010 Day 2 Keynote',
      thumb: 'images/thumbs/thumb02.jpg',
      description: ['Spider - what spider?'],
      subtitle: 'Moscone Center'
    }
];

 var buck_videos = [
    {
      sources:['http://bffmedia.com/trailer_400p.ogg'],
      title: 'Big Buck 400p Video Trailer',
      thumb: 'http://www.bffmedia.com/buck1.png',
      description: ['Common Creative Project Movie'],
      subtitle: 'Smaller Version'
    },
    {
      sources:['http://bffmedia.com/trailer_1080p.ogg'],
      title: 'Big Buck 1080p Video Trailer',
      thumb: 'http://www.bffmedia.com/buck2.png',
      description:['Common Creative Project Movie'],
      subtitle: 'Big Buck is a Rabbit'
    }
];



 var data = {
    categories: [
    {
      name: 'Dev Events',
      videos: event_videos
    },
    {
      name: 'Big Buck',
      videos: buck_videos
   }
   ]
 };
  return data;
};
...