PageRenderTime 52ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/plugins/bitrateselect/src/actionscript/org/flowplayer/bitrateselect/HDBitrateResource.as

https://github.com/longlho/flowplayer
ActionScript | 60 lines | 38 code | 13 blank | 9 comment | 8 complexity | 1003ff71b6e3a285c5577b1a598c4aaf MD5 | raw file
Possible License(s): MIT, BSD-3-Clause
  1. /*
  2. * This file is part of Flowplayer, http://flowplayer.org
  3. *
  4. * By: Daniel Rossi <electroteque@gmail.com>, Anssi Piirainen <api@iki.fi> Flowplayer Oy
  5. * Copyright (c) 2009, 2010 Electroteque Multimedia, Flowplayer Oy
  6. *
  7. * Released under the MIT License:
  8. * http://www.opensource.org/licenses/mit-license.php
  9. */
  10. package org.flowplayer.bitrateselect {
  11. import org.flowplayer.net.BitrateResource;
  12. import org.flowplayer.net.BitrateItem;
  13. import org.flowplayer.model.Clip;
  14. public class HDBitrateResource extends BitrateResource {
  15. private var _hasHD:Boolean = false;
  16. override public function addBitratesToClip(clip:Clip):Vector.<BitrateItem> {
  17. var streamingItems:Vector.<BitrateItem> = super.addBitratesToClip(clip);
  18. if (streamingItems.length == 2) {
  19. var item1:BitrateItem = streamingItems[0] as BitrateItem;
  20. var item2:BitrateItem = streamingItems[streamingItems.length - 1] as BitrateItem;
  21. setHdProperty(item1, item2, clip);
  22. log.debug("HD feature enabled? " + _hasHD);
  23. }
  24. return streamingItems;
  25. }
  26. private function setHdProperty(item1:BitrateItem, item2:BitrateItem, clip:Clip):void {
  27. if (!(item1.hd || item2.hd || item1.sd || item2.sd)) return;
  28. _hasHD = true;
  29. if (item1.hd) {
  30. clip.setCustomProperty("hdBitrateItem", item1);
  31. clip.setCustomProperty("sdBitrateItem", item2);
  32. item2.sd = true;
  33. return;
  34. }
  35. if (item1.sd) {
  36. clip.setCustomProperty("sdBitrateItem", item1);
  37. clip.setCustomProperty("hdBitrateItem", item2);
  38. item2.hd = true;
  39. return;
  40. }
  41. setHdProperty(item2, item1, clip);
  42. }
  43. public function get hasHD():Boolean {
  44. return _hasHD;
  45. }
  46. }
  47. }