7 Replies Latest reply on Aug 10, 2010 10:09 AM by StormFactory

    Loading image without file extension?


      Hello developers.


      Im a trying to use OSMF to create a slideshow of still images. All images are hosted on a media server that exposes the image files by public custom urls. But theese urls does not contain the file extension. It seems OSMF cannot recognize the type and therefore does not load the image.


      Example I: Image is not recognized by OSMF


      // var url:String = "http://media.myserver.com/testimage.png";  // <-- this works

      var url:String = "http://media.myserver.com/28/3849?height=400"; // <-- filetype is ".jpg", but not part of url. Does not work.


      var mediaSprite:MediaPlayerSprite = new MediaPlayerSprite();



      var element:ImageElement = new ImageElement();

      element.resource = new URLResource( url );

      mediaSprite.media = element;


      Example II: Image is recognized by mx.controls.Image


      The mx.controls.Image object can detect the url without file extension and show an image:


      var image:Image = new Image();

      image.source = "http://media.myserver.com/28/3849?height=400"; // <-- this works





      Is it possible to do the same with OSMF? I have tried to google if I can apply a metadata tag with the ".jpg" file extension, but have not found a solution. I am also not quite sure how to add metadata, so if this is the solution, an example would be great.


      Any help is appreciated, since I otherwise will need to use the mx.control.Image class (i cannot change the way the media server returns the url).



        • 1. Re: Loading image without file extension?

          Just to reconfirm


          whether this URL




          returns a


          a jpg file path?


          And it works ifused in MXML like


          <mx:Image src="http://media.myserver.com/28/3849?height=400">


          If so i that might be a bug.


          I can log one for you

          • 2. Re: Loading image without file extension?
            StormFactory Level 1

            Yes, I can confirm both of your questions.


            http://media.myserver.dk/28/3849 is a .jpg file path, and the picture shows up in the browser (Firefox) if i type it into the address bar. I can also load it the the mx.controls.Image class as in both the examples (AS3 and MXML). But I cannot load it into OSMF as in the example i provide.


            I read in some post (sorry, can't remember where), that metadata only applys for videos (?), and that a metadata workaround was upcoming (or present) for video urls with no file extension. But i have not tried that out myself.


            In the osmf.elements.ImageLoader this method (from the osmf framework) search the url for file extensions in the url string, so if it is a  framework but, then this could be it (?):


                     * @private
                     * Indicates whether this ImageLoader is capable of handling the specified resource.
                     * Returns <code>true</code> for URLResources with GIF, JPG, or PNG extensions.
                     * @param resource Resource proposed to be loaded.
                    override public function canHandleResource(resource:MediaResourceBase):Boolean
                        var rt:int = MediaTypeUtil.checkMetadataMatchWithResource(resource, MEDIA_TYPES_SUPPORTED, MIME_TYPES_SUPPORTED);
                        if (rt != MediaTypeUtil.METADATA_MATCH_UNKNOWN)
                            return rt == MediaTypeUtil.METADATA_MATCH_FOUND;
                        var urlResource:URLResource = resource as URLResource;
                        if (urlResource != null &&
                            urlResource.url != null)
                            var url:URL = new URL(urlResource.url);
                            return (url.path.search(/\.gif$|\.jpg$|\.png$/i) != -1);
                        return false;

            Anyway it should be possible to apply the image filetype as metadata for urls like this one http://media.myserver.dk/28/3849. Or if it could be possible to setup an default fallback filetype for theese kind of urls. An even better solution would be if the framework could recognize the type of image filetype (as it seems the mx.controls.Image class do), but I am not sure how to implement this.


            It would be great if you would log it as a bug - please confirm when it is done, or I will do it later. Thanks!

            • 3. Re: Loading image without file extension?
              Poomani Level 1

              http://media.myserver.dk/28/3849 doesn't show up an image when i opened with firefox. Any idea why?

              • 4. Re: Loading image without file extension?
                StormFactory Level 1

                Hi again.


                "myserver" is an alias for my company's media server.



                • 6. Re: Loading image without file extension?
                  StormFactory Level 1

                  Hi again.


                  I have found a workaround for urls not containing the filetype extension:


                  var url:String = "http://media.myserver.dk/28/3849?height=400"; // <- jpg file path

                  var element:ImageElement = new ImageElement();

                  element.resource = new URLResource( url );

                  element.resource.mediaType = MediaType.IMAGE;


                  By setting the MediayType specifically to image, the ImageElement component can load the url even if the filetype is not present in the url string. If the url contains "'.jpg", ".gif" og ".png", then it is not nessesary to explicit define the MediaType for the element's resource.


                  Im not sure if this is intended use of the MediaType class or a workaround. It seems counterintuitive that i have to set the MediaType to IMAGE for an ImageElement.

                  • 7. Re: Loading image without file extension?
                    weizhangstrobe Level 2

                    Yes, that is exactly the way to load an image that has no file extension. This is not a design flaw of OSMF because for this type of URL, there is really no way to figure out what is the media type except for getting helps from the client. Think about it, the URL can potentially point to any file type, an FLV file, F4M file for http streaming, or anything.



                    -Wei Zhang

                    Senior Computer Scientist

                    Adobe Systems, Inc.