views:

425

answers:

2

I'm developing a video player using WPF and AxShockwaveFlash.

It has following steps:

  1. find video from a web service.
  2. it acquires information of each video.
  3. pass video information to AxShockwaveFlash and embedded flash video player.
  4. embedded flash video player starts streaming download from web service.

I have a problem on step 4.
Step 1-3 shares a cookie (CookieContainer), but step 4 can not.
How can I pass its cookie to embedded flash video player?

A: 

Hi, you can pass "flashvars" to the Flash Active X object, for example

<object type="application/x-shockwave-flash" 
data="myFlashThingy.swf" width="100%" height="100%">

<param name="play" value="true" />
<param name="movie" value="myFlashThingy.swf" />
<param name="menu" value="false" />
<param name="quality" value="high" />

<param name="flashvars" value="videoURL='http://somewhere.com/video.flv'" />

And then you can access those "flashvars" in the ActionScript code.

In ActionScript2 you'd do it like this :

var videoURL:String = _root.videoURL;

And in ActionScript3 you'd do it like this :

var flashVars:Object = (this.root.loaderInfo as LoaderInfo).parameters;
var videoURL:String = flashVars.videoURL;

Hope it helps

just_a_dude
Hi just_a_dude.Video url and other parameters can be already passed to ActiveX using flashVars from C#.I want to know how to pass the cookie to Flash ActiveX.Thanks.
Palm3r
A: 

Its little longer trick, instead of using Shockwave, you should use the WebBrowser and navigate to an ashx or aspx page with all cookies set from your cookiecontainer to webbrowser's cookies.

In order to set cookie correctly you must create a page on your asp.net website as "RedirectWithSession.ashx",

public class RedirectWithSession : IHttpHandler{

      public void ProcessRequest(HttpContext context){
           Response.Cookies.Add("ASP.NET_SessionID", Request.QueryString["SessionID"]);
           Response.Redirect(Request.QueryString["RedirectUrl"]);
      }

}

Now in your WPF app, you must find out ASP.NET_SessionID cookie and pass it on the url to webbrowser as,

http://host.com/RedirectWithSession.ashx?SessionID=[SessionID]&amp;RedirectUrl=[Url]

Your webbrowser will first visit the handler, it will then set session correctly and then your video url will be loaded, this way your session of your webservice context and webbrowser context will be shared.

I just showed you example of ASP.NET_SessionID , you can pass multiple cookies. This is the best way to do it, you can also use custom page and javascript etc, but i dont know if they will work correctly in all security modes.

Akash Kava
Thanks Akash.I have no time to try it now.However, your method looks the best.I'll try it in few days.
Palm3r