1 Reply Latest reply on Sep 19, 2012 12:24 AM by RongieZeng

    How to change the display ratio of a video file in OSMF

    SunshineEveryday

      Hi all

       

      The video file I want to play has an incorrect width and height embedded in the video meta file (if you get the metadata of that video file, the width and height are incorrect). I'm now able to get the correct width and height, but I don't know how to apply them to OSMF. I'm using the MediaContainer for video display, the default behavior of that container keeps the original (which is incorrect) ratio (get from the video metadata) even I set the width and height. I'd appreciate if anyone can provide suggestion on how to do it.

       

      Thanks.

        • 1. Re: How to change the display ratio of a video file in OSMF
          RongieZeng

          You can modify the OSMF library's ScaleModeUtils class to do this, here's the path:

          OSMF > org.osmf > layout > ScaleModeUtils.as .

           

          My code to implement the 16:9 and 4:3 ratios.

           

                                                           case ScaleMode.STRETCH:
          
                                                            result 
                                                                      = new Point
                                                                                ( availableWidth
                                                                                , availableHeight
                                                                                );
                                                            break;
          
                                                  case ScaleMode.NONE:
          
                                                            result
                                                                      = new Point
                                                                                ( intrinsicWidth          || availableWidth
                                                                                , intrinsicHeight          || availableHeight
                                                                                );
          
                                                            break;
          
                                                           // ****custom begin
                                                  case ScaleMode.FourToThree: 
                                                            var availableRatio1:Number= availableWidth/ availableHeight; 
                                                            if(availableRatio1 > 4/3){
                                                                      result = new Point( availableHeight * 4/3, availableHeight);
                                                            }else{
                                                                      result = new Point( availableWidth , availableWidth * 3/4);
                                                            }
          
                                                            break;
          
                                                  case ScaleMode.SixteenToNine:
                                                            var availableRatio2:Number= availableWidth/ availableHeight; 
                                                            if(availableRatio2 > 16/9){
                                                                      result = new Point( availableHeight * 16/9, availableHeight);
                                                            }else{
                                                                      result = new Point( availableWidth , availableWidth * 9/16);
                                                            }
                                                            break;
                                                  // ****custom end
          
          
          

           

          And then you can set the container's scalemode to apply a ratio:

          layoutMetadata.scaleMode = ScaleMode.STRETCH;

          Or

          layoutMetadata.scaleMode = ScaleMode.FourToThree;