Permalink
Browse files

Fixing miscellaneous bugs (contributed by Robert, Albert, and Josef).

  • Loading branch information...
1 parent 863e4af commit bb5d56a8c60125b261e9cfb8f5121ce6f59d0029 @BrianFranklin BrianFranklin committed Apr 5, 2012
Showing with 26 additions and 22 deletions.
  1. +26 −22 RenditionSelector/src/RenditionSelector.as
@@ -198,28 +198,32 @@ package
if (_choices)
{
var index:Number = -1;
- var renditions:Array = _renditionCombo.getSelectedData().value;
- for (var i:int = 0; i < renditions.length; i++)
- {
- var rendition:Object = renditions[i];
-
- // if this is the last rendition for the choice or if the detected
- // bandwidth is higher than the rendition's encoding rate
- // then return that rendition's index
- // this works because the renditions for a particular choice
- // are ordered by highest to lowest bit rate
- if (context.detectedBandwidth >= rendition.encodingRate ||
- i == renditions.length-1)
- {
- debug("detected bandwidth: " + context.detectedBandwidth);
- debug("renditions length: " + renditions.length);
- debug("rendition encoding rate: " + rendition.encodingRate);
- debug("rendition index: " + rendition.index);
- index = rendition.index;
- break;
- }
- }
- return index;
+ //Check for selection (-1 value) before assigning to array to avoid TypeError
+ if( _renditionCombo.getSelectedData().value; != -1 )
+ {
+ var renditions:Array = _renditionCombo.getSelectedData().value;
+ for (var i:int = 0; i < renditions.length; i++)
+ {
+ var rendition:Object = renditions[i];
+
+ // if this is the last rendition for the choice or if the detected
+ // bandwidth is higher than the rendition's encoding rate
+ // then return that rendition's index
+ // this works because the renditions for a particular choice
+ // are ordered by highest to lowest bit rate
+ if ((context.detectedBandwidth * 1024) >= rendition.encodingRate ||
+ i == renditions.length-1)
+ {
+ debug("detected bandwidth: " + context.detectedBandwidth);
+ debug("renditions length: " + renditions.length);
+ debug("rendition encoding rate: " + rendition.encodingRate);
+ debug("rendition index: " + rendition.index);
+ index = rendition.index;
+ break;
+ }
+ }
+ return index;
+ }
}
return -1;
}

2 comments on commit bb5d56a

there is a error on line 202:

if( _renditionCombo.getSelectedData().value; != -1 )

a "extra" semicolon..

Owner

BrianFranklin replied Jun 9, 2012

Thanks for pointing that out!

Please sign in to comment.