3 Replies Latest reply on Dec 12, 2013 3:52 AM by bellasys10

    contentPath set above web-root to get mp4 video using proxy script, partially working...


      I am obfuscating file locations and simultaneously checking permissions to view files by locating certain files above web root and using a proxy script to manage permissions. 


      As can be imagined, I'm having a really tough time supplying these mp4's to Flash for playback. Actually I've achieved succes in many areas, and there seems to be one last thing to hook this up... this is where I'd like feedback and hopefully some clues toward a solution.


      It has occurred to me that setting these files up on a different server and applying a cross-domain policy would be easier than what I'm doing... because it would be functionally equivalent, but I don't want to organize another set of server resources, and I've already created a fallback solution which actually doesn meet my objective on equivalent terms- it's just not as elegant as what I would like to do.


      I have AS2 code which successfully sets contentPath to a proxy script: "http://example.com/myproxy.php?filename=defaultVideo.mp4" and gets an appropriate response from the server- it accurately represents the response the exact same way that my other flash players get with standard URL's with the same content headers,  video/mp4 content type, accept-ranges: bytes, etc. This was quite a trick using nginx and wordpress, but I made it happen.


      My script retrieves the data using fpassthru().


      however, as might be expected contentPath doesn't (seem) to like the data, at least, it's not triggering the right things as other normal url's do, so as far as my script is concerned, it isn't "loading" even though I'm seeing all the data transferred in the exact same # of bytes when not using the proxy script.


      I figured I could at least try this approach much like setting an <img src="data:image/png;base64..." Does anyone have successful experience providing content as data in this regard? I know that many things are possible with ByteArray in AS3, but we're talking about video content here- specifically .mp4


      I have 3 sets of erroneous results which allow me to hold out hope I can just hook it up the way I'm trying


      1. Flash is appending a query var to my POST so the request actually looks like: "http://example.com/myproxy.php?filename=defaultVideo.mp4&FLVPlaybackVersion=1.0.2". This tells me some interesting facts about how Flash uses .contentPath, and what happens when I provide a normal URL. Although I believe I'd need to hack the source code better to understand it... not that I'm above hacking. I just don't understand how or why this is occurring. I thought of using Video Class instead of FLVPlayback Class, but I don't want to change a working script until I tackle this one issue.


      2. I have an issue with a different script now and can't seem to communicate properly on the receiving part after sendAndLoad(). It sends fine but doesn't seem to receive anything into result_var... I am also not getting positive results in my content headers (0 bytes saying transferred unlike the perfect looking stats from the main script), so I don't know at this point if it's my issue on the properly forming content headers (which AFAIK shouldn't really be an issue- just echo stuff and SOMETHING should come across) so now my questions are forked between issues and I'll have to report on the results of that.


      3. When I use just my regular flash player without any tricky script involved, clicking my (custom) play button in the AS2 code seems to trigger jquery when I look at the web stats, but when I trigger all my events using the custom code it uses XHR- even though that's not really expected.


      At this point I believe I have 1 of 2 issues: either I'm just not getting results at all into Flash and only believing that's happening- or I'm hopeless in this because there's no way to tell FLVPlayback that my data connects with the URL it's expecting from contentPath even though it looks like the result is (technically, somewhat) the same from an ordinary call to a normal URL.


      Make sense?


      Any help or insight into the inner workings of flash would be appreciated.


      I'm also getting erroneous results wery telling erroneous results from this, but because I have a related issue using a different code system I'm now wondering if my conceptual method is working but I'm just not getting communication between the php script and Flash. For example, I do not get results when I simply provide a valid url via

        • 1. Re: contentPath set above web-root to get mp4 video using proxy script, partially working...
          bellasys10 Level 1

          I see lots of views on this post but no answer- maybe it needs to be chunked down into it's basic components?


          Also I am seeing several somewhat similar questions on StackOverflow (StackExchange).


          It seems (naturally) very challenging to understand how to provide flash with data in place of a contentPath... on browsers and within other software, this works (for example, my reference to <img src="data:image/png;base64,..." />) but this follows an acceptable convention for transmitting data.


          Within the Flash player environment, the question really is- what happens after I set contentPath- not from a high-level place because that's discussed in the ActionScript Language Reference. We know that setting contentPath effectively sets AutoPlay to true, and does a couple other things...


          What we don't know is what happens with the contentPath and how/when Flash uses it to access the data. The reason this maybe might/should work can be understood by comparing, say what happens in iOS when providing an .mp4 link- apparently the video is "pinged" to grab headers or something via the path, but then it isn't really sourced until play in the native player is played. This was discovered when someone was trying to secure their sesssion and provide member-protected video via iOS. Effectively the first "ping" on the video file transferred appropriately, but the second was not allowed- it counted as a separate session.


          Under "normal" circumstances, this doesn't seem to be the case with Flash. For example, my solution employs a temporary link to content outside www-root, and that link is just as quickly deleted as soon as contentPath gets what it needs I remove it. This works for flash because Flash grabs and effectively begins a data stream  immediately upon setting contentPath. Later, it is obviously not dependent on this contentPath existing. I have tested and proven this sufficiently within my software app.


          Why doesn't it work to provide data as contentPath? I'm pretty sure it relates to the data object that Flash uses to play video. Obviously at first glance the contentPath needs to be just that- a content path. So as I'm basically trying to "hack" the flash player and provide a data structure it recognizes- the missing ingredient is how or where to apply the data itself.


          If I can do THAT one thing, I can very much secure my client's video in an extremely efficient manner.  I might even be able to perform basic encryption while transmitting from the source (custom encryption, but effective nonetheless) particularly in AS3.


          So- how do I load data and attach it to the Video Player as data without using contentPath?


          If I had a better understanding of how Flash uses/expects it's data model this would be easy. As it stands now, since I don't have the Flash source, I have to hack this and do a lot more research about this...

          • 2. Re: contentPath set above web-root to get mp4 video using proxy script, partially working...
            kglad Adobe Community Professional & MVP

            (speaking for myself only, your posts are too long.  if i can't appreciate the issue within 1 or 2 minutes, i move on.)