2 Replies Latest reply on Sep 18, 2009 1:37 AM by flibustier3

    checkPolicyFile

    flibustier3

      Hello

       

      I'm trying to use OSMF mediaPlayer in my Flex application. For moving between sections of application I use efflex transitions. In debug mode on local machine everythins is fine, but when I upload it to remote server I get such exeption:

       

      A policy file is required, but the checkPolicyFile flag was not set when this media was loaded.
          at flash.display::BitmapData/draw()

       

      I happens on Slide effect.

       

      I tried this, but it didn't worked

       

      var stream:NetStream;

      var loadable:ILoadable=wrapper.element.getTrait(MediaTraitType.LOADABLE) as ILoadable;
                      var context:NetLoadedContext=NetLoadedContext(loadable.loadedContext);
                      stream=context.stream;
                      stream.checkPolicyFile=true;

        • 1. Re: checkPolicyFile
          bringrags Level 4

          You probably need to set checkPolicyFile before the video is loaded.  To do so, you can override the NetLoader to make sure that the property is always set:

           

          public class PolicyCheckingNetLoader extends NetLoader

          {

              public function PolicyCheckingNetLoader(allowConnectionSharing:Boolean = true, factory:NetConnectionFactory = null)

              {

                  super(allowConnectionSharing, factory);

              }


              override protected function createNetStream(connection:NetConnection,loadable:ILoadable):NetStream

              {

                  var ns:NetStream = new NetStream();

                  ns.checkPolicyFile = true;

                  return ns;

              }

          }

           

          (Note that checking for policy files can be inefficient, so you might want to parametrize the above class's constructor so that you can decide whether to check or not.)

           

          You can then use this class in place of your NetLoader (which gets passed to VideoElement's constructor as the first param).

           

          (Edited to add constructor to example code)

          • 2. Re: checkPolicyFile
            flibustier3 Level 1

            Only one correction

             

            public class PolicyCheckingNetLoader extends NetLoader

            {

                public function PolicyCheckingNetLoader(allowConnectionSharing:Boolean = true, factory:NetConnectionFactory = null)

                {

                    super(allowConnectionSharing, factory);

                }


                override protected function createNetStream(connection:NetConnection,loadable:ILoadable):NetStream

                {

                    var ns:NetStream = new NetStream(connection);

                    ns.checkPolicyFile = true;

                    return ns;

                }

            }

             

            Your solution works! Thank you!