mediamodel.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964
  1. // Copyright 2009 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @fileoverview Provides the base media model consistent with the Yahoo Media
  16. * RSS specification {@link http://search.yahoo.com/mrss/}.
  17. */
  18. goog.provide('goog.ui.media.MediaModel');
  19. goog.provide('goog.ui.media.MediaModel.Category');
  20. goog.provide('goog.ui.media.MediaModel.Credit');
  21. goog.provide('goog.ui.media.MediaModel.Credit.Role');
  22. goog.provide('goog.ui.media.MediaModel.Credit.Scheme');
  23. goog.provide('goog.ui.media.MediaModel.Medium');
  24. goog.provide('goog.ui.media.MediaModel.MimeType');
  25. goog.provide('goog.ui.media.MediaModel.Player');
  26. goog.provide('goog.ui.media.MediaModel.SubTitle');
  27. goog.provide('goog.ui.media.MediaModel.Thumbnail');
  28. goog.require('goog.array');
  29. goog.require('goog.html.TrustedResourceUrl');
  30. /**
  31. * An base data value class for all media data models.
  32. *
  33. * MediaModels are exact matches to the fields defined in the Yahoo RSS media
  34. * specification {@link http://search.yahoo.com/mrss/}.
  35. *
  36. * The current common data shared by medias is to have URLs, mime types,
  37. * captions, descriptions, thumbnails and players. Some of these may not be
  38. * available, or applications may not want to render them, so {@code null}
  39. * values are allowed. {@code goog.ui.media.MediaRenderer} checks whether the
  40. * values are available before creating DOMs for them.
  41. *
  42. * @param {string=} opt_url An optional URL of the media.
  43. * @param {string=} opt_caption An optional caption of the media.
  44. * @param {string=} opt_description An optional description of the media.
  45. * @param {goog.ui.media.MediaModel.MimeType=} opt_type The type of the media.
  46. * @param {goog.ui.media.MediaModel.Medium=} opt_medium The medium of the media.
  47. * @param {number=} opt_duration The duration of the media in seconds.
  48. * @param {number=} opt_width The width of the media in pixels.
  49. * @param {number=} opt_height The height of the media in pixels.
  50. * @constructor
  51. */
  52. goog.ui.media.MediaModel = function(
  53. opt_url, opt_caption, opt_description, opt_type, opt_medium, opt_duration,
  54. opt_width, opt_height) {
  55. /**
  56. * The URL of the media.
  57. * @type {string|undefined}
  58. * @private
  59. */
  60. this.url_ = opt_url;
  61. /**
  62. * The caption of the media.
  63. * @type {string|undefined}
  64. * @private
  65. */
  66. this.caption_ = opt_caption;
  67. /**
  68. * A description of the media, typically user generated comments about it.
  69. * @type {string|undefined}
  70. * @private
  71. */
  72. this.description_ = opt_description;
  73. /**
  74. * The mime type of the media.
  75. * @type {goog.ui.media.MediaModel.MimeType|undefined}
  76. * @private
  77. */
  78. this.type_ = opt_type;
  79. /**
  80. * The medium of the media.
  81. * @type {goog.ui.media.MediaModel.Medium|undefined}
  82. * @private
  83. */
  84. this.medium_ = opt_medium;
  85. /**
  86. * The duration of the media in seconds.
  87. * @type {number|undefined}
  88. * @private
  89. */
  90. this.duration_ = opt_duration;
  91. /**
  92. * The width of the media in pixels.
  93. * @type {number|undefined}
  94. * @private
  95. */
  96. this.width_ = opt_width;
  97. /**
  98. * The height of the media in pixels.
  99. * @type {number|undefined}
  100. * @private
  101. */
  102. this.height_ = opt_height;
  103. /**
  104. * A list of thumbnails representations of the media (eg different sizes of
  105. * the same photo, etc).
  106. * @type {Array<goog.ui.media.MediaModel.Thumbnail>}
  107. * @private
  108. */
  109. this.thumbnails_ = [];
  110. /**
  111. * The list of categories that are applied to this media.
  112. * @type {Array<goog.ui.media.MediaModel.Category>}
  113. * @private
  114. */
  115. this.categories_ = [];
  116. /**
  117. * The list of credits that pertain to this media object.
  118. * @type {!Array<goog.ui.media.MediaModel.Credit>}
  119. * @private
  120. */
  121. this.credits_ = [];
  122. /**
  123. * The list of subtitles for the media object.
  124. * @type {Array<goog.ui.media.MediaModel.SubTitle>}
  125. * @private
  126. */
  127. this.subTitles_ = [];
  128. };
  129. /**
  130. * The supported media mime types, a subset of the media types found here:
  131. * {@link http://www.iana.org/assignments/media-types/} and here
  132. * {@link http://en.wikipedia.org/wiki/Internet_media_type}
  133. * @enum {string}
  134. */
  135. goog.ui.media.MediaModel.MimeType = {
  136. HTML: 'text/html',
  137. PLAIN: 'text/plain',
  138. FLASH: 'application/x-shockwave-flash',
  139. JPEG: 'image/jpeg',
  140. GIF: 'image/gif',
  141. PNG: 'image/png'
  142. };
  143. /**
  144. * Supported mediums, found here:
  145. * {@link http://video.search.yahoo.com/mrss}
  146. * @enum {string}
  147. */
  148. goog.ui.media.MediaModel.Medium = {
  149. IMAGE: 'image',
  150. AUDIO: 'audio',
  151. VIDEO: 'video',
  152. DOCUMENT: 'document',
  153. EXECUTABLE: 'executable'
  154. };
  155. /**
  156. * The media player.
  157. * @type {goog.ui.media.MediaModel.Player}
  158. * @private
  159. */
  160. goog.ui.media.MediaModel.prototype.player_;
  161. /**
  162. * Gets the URL of this media.
  163. * @return {string|undefined} The URL of the media.
  164. */
  165. goog.ui.media.MediaModel.prototype.getUrl = function() {
  166. return this.url_;
  167. };
  168. /**
  169. * Sets the URL of this media.
  170. * @param {string} url The URL of the media.
  171. * @return {!goog.ui.media.MediaModel} The object itself, used for chaining.
  172. */
  173. goog.ui.media.MediaModel.prototype.setUrl = function(url) {
  174. this.url_ = url;
  175. return this;
  176. };
  177. /**
  178. * Gets the caption of this media.
  179. * @return {string|undefined} The caption of the media.
  180. */
  181. goog.ui.media.MediaModel.prototype.getCaption = function() {
  182. return this.caption_;
  183. };
  184. /**
  185. * Sets the caption of this media.
  186. * @param {string} caption The caption of the media.
  187. * @return {!goog.ui.media.MediaModel} The object itself, used for chaining.
  188. */
  189. goog.ui.media.MediaModel.prototype.setCaption = function(caption) {
  190. this.caption_ = caption;
  191. return this;
  192. };
  193. /**
  194. * Gets the media mime type.
  195. * @return {goog.ui.media.MediaModel.MimeType|undefined} The media mime type.
  196. */
  197. goog.ui.media.MediaModel.prototype.getType = function() {
  198. return this.type_;
  199. };
  200. /**
  201. * Sets the media mime type.
  202. * @param {goog.ui.media.MediaModel.MimeType} type The media mime type.
  203. * @return {!goog.ui.media.MediaModel} The object itself, used for chaining.
  204. */
  205. goog.ui.media.MediaModel.prototype.setType = function(type) {
  206. this.type_ = type;
  207. return this;
  208. };
  209. /**
  210. * Gets the media medium.
  211. * @return {goog.ui.media.MediaModel.Medium|undefined} The media medium.
  212. */
  213. goog.ui.media.MediaModel.prototype.getMedium = function() {
  214. return this.medium_;
  215. };
  216. /**
  217. * Sets the media medium.
  218. * @param {goog.ui.media.MediaModel.Medium} medium The media medium.
  219. * @return {!goog.ui.media.MediaModel} The object itself, used for chaining.
  220. */
  221. goog.ui.media.MediaModel.prototype.setMedium = function(medium) {
  222. this.medium_ = medium;
  223. return this;
  224. };
  225. /**
  226. * Gets the description of this media.
  227. * @return {string|undefined} The description of the media.
  228. */
  229. goog.ui.media.MediaModel.prototype.getDescription = function() {
  230. return this.description_;
  231. };
  232. /**
  233. * Sets the description of this media.
  234. * @param {string} description The description of the media.
  235. * @return {!goog.ui.media.MediaModel} The object itself, used for chaining.
  236. */
  237. goog.ui.media.MediaModel.prototype.setDescription = function(description) {
  238. this.description_ = description;
  239. return this;
  240. };
  241. /**
  242. * Gets the thumbnail urls.
  243. * @return {Array<goog.ui.media.MediaModel.Thumbnail>} The list of thumbnails.
  244. */
  245. goog.ui.media.MediaModel.prototype.getThumbnails = function() {
  246. return this.thumbnails_;
  247. };
  248. /**
  249. * Sets the thumbnail list.
  250. * @param {Array<goog.ui.media.MediaModel.Thumbnail>} thumbnails The list of
  251. * thumbnail.
  252. * @return {!goog.ui.media.MediaModel} The object itself, used for chaining.
  253. */
  254. goog.ui.media.MediaModel.prototype.setThumbnails = function(thumbnails) {
  255. this.thumbnails_ = thumbnails;
  256. return this;
  257. };
  258. /**
  259. * Gets the duration of the media.
  260. * @return {number|undefined} The duration in seconds.
  261. */
  262. goog.ui.media.MediaModel.prototype.getDuration = function() {
  263. return this.duration_;
  264. };
  265. /**
  266. * Sets duration of the media.
  267. * @param {number} duration The duration of the media, in seconds.
  268. * @return {!goog.ui.media.MediaModel} The object itself, used for chaining.
  269. */
  270. goog.ui.media.MediaModel.prototype.setDuration = function(duration) {
  271. this.duration_ = duration;
  272. return this;
  273. };
  274. /**
  275. * Gets the width of the media in pixels.
  276. * @return {number|undefined} The width in pixels.
  277. */
  278. goog.ui.media.MediaModel.prototype.getWidth = function() {
  279. return this.width_;
  280. };
  281. /**
  282. * Sets the width of the media.
  283. * @param {number} width The width of the media, in pixels.
  284. * @return {!goog.ui.media.MediaModel} The object itself, used for chaining.
  285. */
  286. goog.ui.media.MediaModel.prototype.setWidth = function(width) {
  287. this.width_ = width;
  288. return this;
  289. };
  290. /**
  291. * Gets the height of the media in pixels.
  292. * @return {number|undefined} The height in pixels.
  293. */
  294. goog.ui.media.MediaModel.prototype.getHeight = function() {
  295. return this.height_;
  296. };
  297. /**
  298. * Sets the height of the media.
  299. * @param {number} height The height of the media, in pixels.
  300. * @return {!goog.ui.media.MediaModel} The object itself, used for chaining.
  301. */
  302. goog.ui.media.MediaModel.prototype.setHeight = function(height) {
  303. this.height_ = height;
  304. return this;
  305. };
  306. /**
  307. * Gets the player data.
  308. * @return {goog.ui.media.MediaModel.Player|undefined} The media player data.
  309. */
  310. goog.ui.media.MediaModel.prototype.getPlayer = function() {
  311. return this.player_;
  312. };
  313. /**
  314. * Sets the player data.
  315. * @param {goog.ui.media.MediaModel.Player} player The media player data.
  316. * @return {!goog.ui.media.MediaModel} The object itself, used for chaining.
  317. */
  318. goog.ui.media.MediaModel.prototype.setPlayer = function(player) {
  319. this.player_ = player;
  320. return this;
  321. };
  322. /**
  323. * Gets the categories of the media.
  324. * @return {Array<goog.ui.media.MediaModel.Category>} The categories of the
  325. * media.
  326. */
  327. goog.ui.media.MediaModel.prototype.getCategories = function() {
  328. return this.categories_;
  329. };
  330. /**
  331. * Sets the categories of the media
  332. * @param {Array<goog.ui.media.MediaModel.Category>} categories The categories
  333. * of the media.
  334. * @return {!goog.ui.media.MediaModel} The object itself, used for chaining.
  335. */
  336. goog.ui.media.MediaModel.prototype.setCategories = function(categories) {
  337. this.categories_ = categories;
  338. return this;
  339. };
  340. /**
  341. * Finds the first category with the given scheme.
  342. * @param {string} scheme The scheme to search for.
  343. * @return {goog.ui.media.MediaModel.Category} The category that has the
  344. * given scheme. May be null.
  345. */
  346. goog.ui.media.MediaModel.prototype.findCategoryWithScheme = function(scheme) {
  347. if (!this.categories_) {
  348. return null;
  349. }
  350. var category = goog.array.find(this.categories_, function(category) {
  351. return category ? (scheme == category.getScheme()) : false;
  352. });
  353. return /** @type {goog.ui.media.MediaModel.Category} */ (category);
  354. };
  355. /**
  356. * Gets the credits of the media.
  357. * @return {!Array<goog.ui.media.MediaModel.Credit>} The credits of the media.
  358. */
  359. goog.ui.media.MediaModel.prototype.getCredits = function() {
  360. return this.credits_;
  361. };
  362. /**
  363. * Sets the credits of the media
  364. * @param {!Array<goog.ui.media.MediaModel.Credit>} credits The credits of the
  365. * media.
  366. * @return {!goog.ui.media.MediaModel} The object itself, used for chaining.
  367. */
  368. goog.ui.media.MediaModel.prototype.setCredits = function(credits) {
  369. this.credits_ = credits;
  370. return this;
  371. };
  372. /**
  373. * Finds all credits with the given role.
  374. * @param {string} role The role to search for.
  375. * @return {!Array<!goog.ui.media.MediaModel.Credit>} An array of credits
  376. * with the given role. May be empty.
  377. */
  378. goog.ui.media.MediaModel.prototype.findCreditsWithRole = function(role) {
  379. var credits = goog.array.filter(
  380. this.credits_, function(credit) { return role == credit.getRole(); });
  381. return /** @type {!Array<!goog.ui.media.MediaModel.Credit>} */ (credits);
  382. };
  383. /**
  384. * Gets the subtitles for the media.
  385. * @return {Array<goog.ui.media.MediaModel.SubTitle>} The subtitles.
  386. */
  387. goog.ui.media.MediaModel.prototype.getSubTitles = function() {
  388. return this.subTitles_;
  389. };
  390. /**
  391. * Sets the subtitles for the media
  392. * @param {Array<goog.ui.media.MediaModel.SubTitle>} subtitles The subtitles.
  393. * @return {!goog.ui.media.MediaModel} The object itself.
  394. */
  395. goog.ui.media.MediaModel.prototype.setSubTitles = function(subtitles) {
  396. this.subTitles_ = subtitles;
  397. return this;
  398. };
  399. /**
  400. * Constructs a thumbnail containing details of the thumbnail's image URL and
  401. * optionally its size.
  402. * @param {string} url The URL of the thumbnail's image.
  403. * @param {goog.math.Size=} opt_size The size of the thumbnail's image if known.
  404. * @constructor
  405. * @final
  406. */
  407. goog.ui.media.MediaModel.Thumbnail = function(url, opt_size) {
  408. /**
  409. * The thumbnail's image URL.
  410. * @type {string}
  411. * @private
  412. */
  413. this.url_ = url;
  414. /**
  415. * The size of the thumbnail's image if known.
  416. * @type {goog.math.Size}
  417. * @private
  418. */
  419. this.size_ = opt_size || null;
  420. };
  421. /**
  422. * Gets the thumbnail URL.
  423. * @return {string} The thumbnail's image URL.
  424. */
  425. goog.ui.media.MediaModel.Thumbnail.prototype.getUrl = function() {
  426. return this.url_;
  427. };
  428. /**
  429. * Sets the thumbnail URL.
  430. * @param {string} url The thumbnail's image URL.
  431. * @return {!goog.ui.media.MediaModel.Thumbnail} The object itself, used for
  432. * chaining.
  433. */
  434. goog.ui.media.MediaModel.Thumbnail.prototype.setUrl = function(url) {
  435. this.url_ = url;
  436. return this;
  437. };
  438. /**
  439. * Gets the thumbnail size.
  440. * @return {goog.math.Size} The size of the thumbnail's image if known.
  441. */
  442. goog.ui.media.MediaModel.Thumbnail.prototype.getSize = function() {
  443. return this.size_;
  444. };
  445. /**
  446. * Sets the thumbnail size.
  447. * @param {goog.math.Size} size The size of the thumbnail's image.
  448. * @return {!goog.ui.media.MediaModel.Thumbnail} The object itself, used for
  449. * chaining.
  450. */
  451. goog.ui.media.MediaModel.Thumbnail.prototype.setSize = function(size) {
  452. this.size_ = size;
  453. return this;
  454. };
  455. /**
  456. * Constructs a player containing details of the player's URL and
  457. * optionally its size.
  458. * @param {!goog.html.TrustedResourceUrl} url The URL of the player.
  459. * @param {Object=} opt_vars Optional map of arguments to the player.
  460. * @param {goog.math.Size=} opt_size The size of the player if known.
  461. * @constructor
  462. * @final
  463. */
  464. goog.ui.media.MediaModel.Player = function(url, opt_vars, opt_size) {
  465. /**
  466. * The player's URL.
  467. * @type {!goog.html.TrustedResourceUrl}
  468. * @private
  469. */
  470. this.trustedResourceUrl_ = url;
  471. /**
  472. * Player arguments, typically flash arguments.
  473. * @type {Object}
  474. * @private
  475. */
  476. this.vars_ = opt_vars || null;
  477. /**
  478. * The size of the player if known.
  479. * @type {goog.math.Size}
  480. * @private
  481. */
  482. this.size_ = opt_size || null;
  483. };
  484. /**
  485. * Gets the player URL.
  486. * @return {!goog.html.TrustedResourceUrl} The player's URL.
  487. */
  488. goog.ui.media.MediaModel.Player.prototype.getTrustedResourceUrl = function() {
  489. return this.trustedResourceUrl_;
  490. };
  491. /**
  492. * Gets the player URL.
  493. * @return {string} The player's URL.
  494. */
  495. goog.ui.media.MediaModel.Player.prototype.getUrl = function() {
  496. return this.trustedResourceUrl_.getTypedStringValue();
  497. };
  498. /**
  499. * Sets the player URL.
  500. * @param {!goog.html.TrustedResourceUrl} url The player's URL.
  501. * @return {!goog.ui.media.MediaModel.Player} The object itself, used for
  502. * chaining.
  503. */
  504. goog.ui.media.MediaModel.Player.prototype.setUrl = function(url) {
  505. this.trustedResourceUrl_ = url;
  506. return this;
  507. };
  508. /**
  509. * Gets the player arguments.
  510. * @return {Object} The media player arguments.
  511. */
  512. goog.ui.media.MediaModel.Player.prototype.getVars = function() {
  513. return this.vars_;
  514. };
  515. /**
  516. * Sets the player arguments.
  517. * @param {Object} vars The media player arguments.
  518. * @return {!goog.ui.media.MediaModel.Player} The object itself, used for
  519. * chaining.
  520. */
  521. goog.ui.media.MediaModel.Player.prototype.setVars = function(vars) {
  522. this.vars_ = vars;
  523. return this;
  524. };
  525. /**
  526. * Gets the size of the player.
  527. * @return {goog.math.Size} The size of the player if known.
  528. */
  529. goog.ui.media.MediaModel.Player.prototype.getSize = function() {
  530. return this.size_;
  531. };
  532. /**
  533. * Sets the size of the player.
  534. * @param {goog.math.Size} size The size of the player.
  535. * @return {!goog.ui.media.MediaModel.Player} The object itself, used for
  536. * chaining.
  537. */
  538. goog.ui.media.MediaModel.Player.prototype.setSize = function(size) {
  539. this.size_ = size;
  540. return this;
  541. };
  542. /**
  543. * A taxonomy to be set that gives an indication of the type of media content,
  544. * and its particular contents.
  545. * @param {string} scheme The URI that identifies the categorization scheme.
  546. * @param {string} value The value of the category.
  547. * @param {string=} opt_label The human readable label that can be displayed in
  548. * end user applications.
  549. * @constructor
  550. * @final
  551. */
  552. goog.ui.media.MediaModel.Category = function(scheme, value, opt_label) {
  553. /**
  554. * The URI that identifies the categorization scheme.
  555. * @type {string}
  556. * @private
  557. */
  558. this.scheme_ = scheme;
  559. /**
  560. * The value of the category.
  561. * @type {string}
  562. * @private
  563. */
  564. this.value_ = value;
  565. /**
  566. * The human readable label that can be displayed in end user applications.
  567. * @type {string}
  568. * @private
  569. */
  570. this.label_ = opt_label || '';
  571. };
  572. /**
  573. * Gets the category scheme.
  574. * @return {string} The category scheme URI.
  575. */
  576. goog.ui.media.MediaModel.Category.prototype.getScheme = function() {
  577. return this.scheme_;
  578. };
  579. /**
  580. * Sets the category scheme.
  581. * @param {string} scheme The category's scheme.
  582. * @return {!goog.ui.media.MediaModel.Category} The object itself, used for
  583. * chaining.
  584. */
  585. goog.ui.media.MediaModel.Category.prototype.setScheme = function(scheme) {
  586. this.scheme_ = scheme;
  587. return this;
  588. };
  589. /**
  590. * Gets the categor's value.
  591. * @return {string} The category's value.
  592. */
  593. goog.ui.media.MediaModel.Category.prototype.getValue = function() {
  594. return this.value_;
  595. };
  596. /**
  597. * Sets the category value.
  598. * @param {string} value The category value to be set.
  599. * @return {!goog.ui.media.MediaModel.Category} The object itself, used for
  600. * chaining.
  601. */
  602. goog.ui.media.MediaModel.Category.prototype.setValue = function(value) {
  603. this.value_ = value;
  604. return this;
  605. };
  606. /**
  607. * Gets the label of the category.
  608. * @return {string} The label of the category.
  609. */
  610. goog.ui.media.MediaModel.Category.prototype.getLabel = function() {
  611. return this.label_;
  612. };
  613. /**
  614. * Sets the label of the category.
  615. * @param {string} label The label of the category.
  616. * @return {!goog.ui.media.MediaModel.Category} The object itself, used for
  617. * chaining.
  618. */
  619. goog.ui.media.MediaModel.Category.prototype.setLabel = function(label) {
  620. this.label_ = label;
  621. return this;
  622. };
  623. /**
  624. * Indicates an entity that has contributed to a media object. Based on
  625. * 'media.credit' in the rss spec.
  626. * @param {string} value The name of the entity being credited.
  627. * @param {goog.ui.media.MediaModel.Credit.Role=} opt_role The role the entity
  628. * played.
  629. * @param {goog.ui.media.MediaModel.Credit.Scheme=} opt_scheme The URI that
  630. * identifies the role scheme.
  631. * @constructor
  632. * @final
  633. */
  634. goog.ui.media.MediaModel.Credit = function(value, opt_role, opt_scheme) {
  635. /**
  636. * The name of entity being credited.
  637. * @type {string}
  638. * @private
  639. */
  640. this.value_ = value;
  641. /**
  642. * The role the entity played.
  643. * @type {goog.ui.media.MediaModel.Credit.Role|undefined}
  644. * @private
  645. */
  646. this.role_ = opt_role;
  647. /**
  648. * The URI that identifies the role scheme
  649. * @type {goog.ui.media.MediaModel.Credit.Scheme|undefined}
  650. * @private
  651. */
  652. this.scheme_ = opt_scheme;
  653. };
  654. /**
  655. * The types of known roles.
  656. * @enum {string}
  657. */
  658. goog.ui.media.MediaModel.Credit.Role = {
  659. UPLOADER: 'uploader',
  660. OWNER: 'owner'
  661. };
  662. /**
  663. * The types of known schemes.
  664. * @enum {string}
  665. */
  666. goog.ui.media.MediaModel.Credit.Scheme = {
  667. EUROPEAN_BROADCASTING: 'urn:ebu',
  668. YAHOO: 'urn:yvs',
  669. YOUTUBE: 'urn:youtube'
  670. };
  671. /**
  672. * Gets the name of the entity being credited.
  673. * @return {string} The name of the entity.
  674. */
  675. goog.ui.media.MediaModel.Credit.prototype.getValue = function() {
  676. return this.value_;
  677. };
  678. /**
  679. * Sets the value of the credit object.
  680. * @param {string} value The value.
  681. * @return {!goog.ui.media.MediaModel.Credit} The object itself.
  682. */
  683. goog.ui.media.MediaModel.Credit.prototype.setValue = function(value) {
  684. this.value_ = value;
  685. return this;
  686. };
  687. /**
  688. * Gets the role of the entity being credited.
  689. * @return {goog.ui.media.MediaModel.Credit.Role|undefined} The role of the
  690. * entity.
  691. */
  692. goog.ui.media.MediaModel.Credit.prototype.getRole = function() {
  693. return this.role_;
  694. };
  695. /**
  696. * Sets the role of the credit object.
  697. * @param {goog.ui.media.MediaModel.Credit.Role} role The role.
  698. * @return {!goog.ui.media.MediaModel.Credit} The object itself.
  699. */
  700. goog.ui.media.MediaModel.Credit.prototype.setRole = function(role) {
  701. this.role_ = role;
  702. return this;
  703. };
  704. /**
  705. * Gets the scheme of the credit object.
  706. * @return {goog.ui.media.MediaModel.Credit.Scheme|undefined} The URI that
  707. * identifies the role scheme.
  708. */
  709. goog.ui.media.MediaModel.Credit.prototype.getScheme = function() {
  710. return this.scheme_;
  711. };
  712. /**
  713. * Sets the scheme of the credit object.
  714. * @param {goog.ui.media.MediaModel.Credit.Scheme} scheme The scheme.
  715. * @return {!goog.ui.media.MediaModel.Credit} The object itself.
  716. */
  717. goog.ui.media.MediaModel.Credit.prototype.setScheme = function(scheme) {
  718. this.scheme_ = scheme;
  719. return this;
  720. };
  721. /**
  722. * A reference to the subtitle URI for a media object.
  723. * Implements the 'media.subTitle' in the rss spec.
  724. *
  725. * @param {string} href The subtitle's URI.
  726. * to fetch the subtitle file.
  727. * @param {string} lang An RFC 3066 language.
  728. * @param {string} type The MIME type of the URI.
  729. * @constructor
  730. * @final
  731. */
  732. goog.ui.media.MediaModel.SubTitle = function(href, lang, type) {
  733. /**
  734. * The subtitle href.
  735. * @type {string}
  736. * @private
  737. */
  738. this.href_ = href;
  739. /**
  740. * The RFC 3066 language.
  741. * @type {string}
  742. * @private
  743. */
  744. this.lang_ = lang;
  745. /**
  746. * The MIME type of the resource.
  747. * @type {string}
  748. * @private
  749. */
  750. this.type_ = type;
  751. };
  752. /**
  753. * Sets the href for the subtitle object.
  754. * @param {string} href The subtitle's URI.
  755. * @return {!goog.ui.media.MediaModel.SubTitle} The object itself.
  756. */
  757. goog.ui.media.MediaModel.SubTitle.prototype.setHref = function(href) {
  758. this.href_ = href;
  759. return this;
  760. };
  761. /**
  762. * Get the href for the subtitle object.
  763. * @return {string} href The subtitle's URI.
  764. */
  765. goog.ui.media.MediaModel.SubTitle.prototype.getHref = function() {
  766. return this.href_;
  767. };
  768. /**
  769. * Sets the language for the subtitle object.
  770. * @param {string} lang The RFC 3066 language.
  771. * @return {!goog.ui.media.MediaModel.SubTitle} The object itself.
  772. */
  773. goog.ui.media.MediaModel.SubTitle.prototype.setLang = function(lang) {
  774. this.lang_ = lang;
  775. return this;
  776. };
  777. /**
  778. * Get the lang for the subtitle object.
  779. * @return {string} lang The RFC 3066 language.
  780. */
  781. goog.ui.media.MediaModel.SubTitle.prototype.getLang = function() {
  782. return this.lang_;
  783. };
  784. /**
  785. * Sets the type for the subtitle object.
  786. * @param {string} type The MIME type.
  787. * @return {!goog.ui.media.MediaModel.SubTitle} The object itself.
  788. */
  789. goog.ui.media.MediaModel.SubTitle.prototype.setType = function(type) {
  790. this.type_ = type;
  791. return this;
  792. };
  793. /**
  794. * Get the type for the subtitle object.
  795. * @return {string} type The MIME type.
  796. */
  797. goog.ui.media.MediaModel.SubTitle.prototype.getType = function() {
  798. return this.type_;
  799. };