简体   繁体   中英

Flash video not appearing on facebook canvas page

this page works when requested locally (a flash movie plays), http://localhost:8080/flash.aspx

I also have url routing set up http://localhost:8080/videos/ also directs to http://localhost:8080/flash.aspx

If I have set up the following facebook application settings:

---website---

  1. site url: http://localhost:8080/
  2. site domain: localhost

---facebook integration---

  1. canvas page: http://apps.facebook.com/my_app/
  2. canvas url: http://localhost:8080/video/

when I request the page: http://apps.facebook.com/my_app - http://localhost:8080/flash.aspx is loaded into the facebook canvas (I can see my testing text), however, the flash movie does not play.

Here is the jquery code I'm using to load the swf on flash.aspx

$(document).ready(function () {
    if (swfobject.hasFlashPlayerVersion("6.0.0")) {
        var att = { data: "flash/video.swf", width: "385", height: "312" };
        var par = { flashvars: "foo=bar" };
        var id = "video-container";
        swfobject.createSWF(att, par, id);
    }
});

Any ideas why the flash movie isn't playing when I request: http://apps.facebook.com/my_app/ but does play as it should when the page is requested locally?

Using an absolute path to the flash file fixed it. http://www.mysite.com/flash/video.swf

I don't know about the domain issues (those are outside the scope of SWFObject), but your code can be improved a little. You're wrapping the entire block in a jQuery ready function, but then you also use the addDomLoadEvent. This is redundant. You can simplify to:

$(document).ready(function () {
    if (swfobject.hasFlashPlayerVersion("6.0.0")) {
        var att = { data: "flash/video.swf", width: "385", height: "312" };
        var par = { flashvars: "foo=bar" };
        var id = "video-container";
        var myObject = swfobject.createSWF(att, par, id);
    }
 });

OR you could just use SWFObject's embedSWF function, which has domload detection built-in:

var flashvars = { foo: "bar" };
var par = {};
var att = {};
swfobject.embedSWF("flash/video.swf", "video-container", "385", "312", "6.0.0", false, flashvars, par, att);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM