9 Replies Latest reply: Nov 29, 2011 2:32 AM by MarIfla RSS

    FLVPlayback source with query strings (parameters) doesn't load

    supervu@gmail.com

      Flash version: CS4

      AS version: AS3


      ------------------------------

       

      I'm currently trying to use the FLVPlayback component and pass a source FLV that's living on a cloudfront webserver. The problem is that the cloudfront requires authentication in the form of query strings in the source FLV. For example:

       

      import fl.video.*;
      
      var mainMovie:FLVPlayback = new FLVPlayback();
      mainMovie.source = "http://www.somedomainname.com/firmware.flv?dummyquery=22";
      
      trace(addChild(mainMovie));
      

       

      As soon as I take away the "dummyquery", it works fine. When I add a query string, it breaks (nothing loads).

       

      Here is the error output I get:

       

      [object FLVPlayback]
      VideoError: 1005: Invalid xml: URL: "http://www.somedomainname.com/firmware.flv?dummyquery=22&FLVPlaybackVersion=2.1" No root node found; if url is for an flv it must have .flv extension and take no parameters
           at fl.video::SMILManager/http://www.adobe.com/2007/flash/flvplayback/internal::xmlLoadEventHandler()
           at flash.events::EventDispatcher/dispatchEventFunction()
           at flash.events::EventDispatcher/dispatchEvent()
           at flash.net::URLLoader/onComplete()
      
      

       

      It adds on "&FLVPlaybackVersion=2.1" to the end.

       

      I saw a different article that said I should add a dummy variable at the end like "&dummy=.flv" because I was told that Flash is basically looking for an .flv extension at the end and you can trick it, but it doesn't work because they add on additional code.

       

      Does anyone know how to work around this?

        • 1. Re: FLVPlayback source with query strings (parameters) doesn't load
          Andrei1 Community Member

          I don't know how cloudfront authentication works but I doubt you can use FLVPlayback for urls structured this way. Chances are, you need to write your own player taking into account cloudfront NetConnection/NetStream routine.

          • 2. Re: FLVPlayback source with query strings (parameters) doesn't load
            supervu@gmail.com Community Member

            Thanks for the quick reply.

             

            If I take the source URL that's supposed to go in there, and paste it into a browser.. it gives me access to the file. So that's the only way I know that it works with cloudfront's authentication.

             

            The authentication basically requires two queries: expiration, and signature.

             

            Using that same URL and putting it into my FLVPlayback Component's source, it breaks because of the query strings.

            • 3. Re: FLVPlayback source with query strings (parameters) doesn't load
              Andrei1 Community Member

              Again, I don't believe you can use FLVPlayback for this purpose and you should look into writing your own streaming routine because, it seams, FLVPlayback's way of dealing with urls is not flexible enough.

              • 4. Re: FLVPlayback source with query strings (parameters) doesn't load
                kglad CommunityMVP

                (i think there is a way to append an identifying query string to the source parameter.  check these forums for a similar issue within the past few weeks that, i believe, the op found a work-around.)

                • 5. Re: FLVPlayback source with query strings (parameters) doesn't load
                  supervu@gmail.com Community Member

                  Thanks.

                   

                  Aside from that, how do you customize a component? I downloaded the FLVPlayback 2.5 component from the Flash Media Server Software Tools page (http://www.adobe.com/products/flashmediaserver/tool_downloads/) and then installed it like it told me to:

                   

                  Using Windows 7:

                  1. I downloaded the file
                  2. Unzipped it
                    1. Placed it into this directory: C:\Program Files (x86)\Adobe\Adobe Flash CS4\Common\Configuration\Component Source\ActionScript 3.0\FLVPlayback\
                  3. Edited the SMILManager.as to remove the code that appends the "&FLVPlaybackVersion" code
                  4. Opened Flash

                   

                  It still appends the code when I go to test the movie. Did I not install it correctly? Am I supposed to put it somewhere else? Do I need to tell flash to load a customized version? If so, how?

                  • 6. Re: FLVPlayback source with query strings (parameters) doesn't load
                    Andrei1 Community Member

                    Here is an excerpt from Adobe article (http://www.adobe.com/devnet/flash/articles/flvplayback_fplayer9u3_print.html). It seems it explains xml error:

                     

                    Because a video file can originate from a variety of locations and because a URL can specify an XML or SMIL file in addition to a video file, the FLVPlayback component analyzes the URL that you supply. After  installing Flash Player 9 Update 3, the FLVPlayback component performs the following checks on the URL in this order:

                     

                    • If you specify the RTMP, RTMPT,  RTMPS, RTMPE, or RTMPTE protocol for streaming from Flash Media Server (FMS), the source URL is assumed to be streaming video from Flash Media Server
                    • If the URL does not include a query string, for example:
                      http://www.foo.com/app?param1=value&param2=value
                      and the URL does not end in .txt, .xml or .smil, the source is assumed to be a video file
                    • If the URL cotains the string "/fms/fpad" then the source is assumed to be a FPAD XML file from Flash Media Server
                    • If none of  the above is true, the FLVPlayback component assumes the source URL is a SMIL file
                    • 7. Re: FLVPlayback source with query strings (parameters) doesn't load
                      supervu@gmail.com Community Member

                      I figured it out. I'm just posting here so that other people have the solution to this.

                       

                      I have been following this article:

                      http://www.actionscript.org/resources/articles/995/1/Writing-a-Custom-YouTube-Player-for-a -Google-Gadget/Page1.html

                       

                      And inside it, there's a section that talks about using the FLVPlayback component with URLs containing query strings (parameters).

                       

                      Be very careful of the line change.. it actually changes "<" to ">".

                       

                      Also, you can copy the component .as files straight from your Program files:

                       

                      C:\Program Files (x86)\Adobe\Adobe Flash CS4\Common\Configuration\Component Source\ActionScript 3.0\FLVPlayback\fl
                      

                       

                       

                      ......and copy that whole folder into the directory of your project.You can then customize those .as files as needed.

                       

                      When you update those .as files, it will compile during compilation of your FLA.

                      • 8. Re: FLVPlayback source with query strings (parameters) doesn't load
                        scott.tompkins

                        Hey supervu,

                         

                        I know you already found a workaround to make this work, just figured I'd post an alternative to editing the FLVPlayback compoent. I also am retrieving an FLV file via a .Net ASHX file. To keep both worlds happy, I used a URLRewriter module to translate for me... this one translates what I am using for the FLVPlayback component source:

                         

                        http://domain.com/flv/22.flv  to be resolved as http://domain.com/API/resource.ashx?ID=22

                         

                        There is of course no flv folder in the root of my application...

                         

                        Here is my very simple URLRewriter class in vb.net:

                         

                         

                         

                        Imports Microsoft.VisualBasic
                        Imports System
                        Imports System.Web

                        Public Class URLRewriter
                            Implements IHttpModule

                            Public Sub Init(ByVal inst As System.Web.HttpApplication) Implements System.Web.IHttpModule.Init
                                AddHandler inst.BeginRequest, AddressOf Me.OnBeginRequest
                            End Sub

                            Public Sub OnBeginRequest(ByVal app As Object, ByVal e As EventArgs)
                                Dim inst As HttpApplication = CType(app, HttpApplication)
                                Dim req_path As String = inst.Context.Request.Path
                                Dim trans_path As String = ""
                                Dim search As String = "/flv/"
                                Dim pos As Integer = req_path.IndexOf("/flv/")
                                If pos > -1 Then
                                    Dim key as string = req_path.Substring(pos + search.Length, (req_path.LastIndexOf(".flv") - (pos + search.Length)))
                                    HttpContext.Current.Response.Redirect("~/API/resource.ashx?ID=" & key )
                                End If


                            End Sub

                            Public Sub Dispose() Implements System.Web.IHttpModule.Dispose

                            End Sub

                        End Class

                         

                         

                         

                        and make sure you add this to your web.config.. this will cause URLRewriter to intercept all HTTP requests, and redirect as needed.

                         

                        <system.web>

                             <httpModules>    

                                  <add name="URLRewriter" type="[Namespace].URLRewriter"/>
                              </httpModules>

                        </system.web>

                         

                        Hope this helps someone.

                        • 9. Re: FLVPlayback source with query strings (parameters) doesn't load
                          MarIfla

                          I'm having the same problem and I've tried to solve it the same way. But it does't seem to work.

                           

                          No READY-event is fired. I added a STATE_CHANGE listener, the event is fired and the event.state is VideoState.CONNECTION_ERROR...

                           

                          Has the behaviour perhaps changed in one of the latest Flash versions? I'm using FLVPlayback version 2.5.0.26.