2 Replies Latest reply on Oct 20, 2011 9:23 AM by schreiter

    get video dimensions

    schreiter

      Hi,

       

      how do i get video width and height?

      Ive set up the simplest of all video players just using a mediaContainer and mediaPlayer.

      mediaContainer width and height are set to 640x360px (16:9).

      when i load a 4:3 video i know that the video is set to 480x360 to maintain the aspect ratio.

      But as i am working with a dynamic size for the video player i am searching for an easy way

      to get the size of the current video. I know that i could do it by taking the aspect ratio of the

      video from the metadata and calculate the size by myselt, but there must be an easier way to do it?!

       

      greets

      vincent

        • 2. Re: get video dimensions
          schreiter Level 1

          Thanks for the quick answer.

           

          This is either not what i was looking for or i might be to stupid right now

           

          This is what ive done:

           

          private function playSingleStream(source:String):void

          {

              _streamResource = new StreamingURLResource(source, _streamType, start, _streamEnd);

              _streamResource.urlIncludesFMSApplicationInstance = true;

           

              _streamElement = new VideoElement(_streamResource, _netLoader);

              _streamElement.smoothing = true;

              _streamElement.addEventListener(MediaElementEvent.TRAIT_ADD, traitAddHandler);

              _mediaPlayer.media = _streamElement;

              _mediaContainer.addMediaElement(_streamElement);

          }

                 

           

          private function traitAddHandler(e:MediaElementEvent):void

          {

              if(e.traitType == MediaTraitType.DISPLAY_OBJECT)

              {

                  var t:VideoElement = e.currentTarget as VideoElement;

                  var dp:DisplayObjectTrait = t.getTrait("displayObject") as DisplayObjectTrait;

                  dp.addEventListener(DisplayObjectEvent.MEDIA_SIZE_CHANGE, mediaSizeChangeHandler);

              }

          }

           

          private function mediaSizeChangeHandler(e:DisplayObjectEvent):void

          {

              log(e.newWidth);

              log(e.newHeight);

          }

           

          i am still only getting the original size of the video in mediaSizeChangeHandler.

          also the MEDIA_SIZE_CHANGE is not triggered when i resize the videoplayer although video the video

          is definitly resized because it is displayed in correct size and place.

           

          greets

          vincent