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?
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.
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.
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.
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:
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?
Here is an excerpt from Adobe article (http://www.adobe.com/devnet/flash/articles/flvplayback_fplayer9u3_prin t.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:
I figured it out. I'm just posting here so that other people have the solution to this.
I have been following this article:
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.
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:
There is of course no flv folder in the root of my application...
Here is my very simple URLRewriter class in vb.net:
Public Class URLRewriter
Public Sub Init(ByVal inst As System.Web.HttpApplication) Implements System.Web.IHttpModule.Init
AddHandler inst.BeginRequest, AddressOf Me.OnBeginRequest
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 )
Public Sub Dispose() Implements System.Web.IHttpModule.Dispose
and make sure you add this to your web.config.. this will cause URLRewriter to intercept all HTTP requests, and redirect as needed.
<add name="URLRewriter" type="[Namespace].URLRewriter"/>
Hope this helps someone.
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 188.8.131.52.