PDA

View Full Version : Specify flash:// javascript file


xmcnuggetx
May 8th, 2009, 02:49 PM
How would you specify a js file to control a flash movie that is "found" on a website? If you send boxee a normal http:// link with a flash movie on it, then it is smart enough to play that movie within boxee. With this behavior how do you specify the .js for pausing, play, ect?

ameno
May 8th, 2009, 03:15 PM
How would you specify a js file to control a flash movie that is "found" on a website? If you send boxee a normal http:// link with a flash movie on it, then it is smart enough to play that movie within boxee. With this behavior how do you specify the .js for pausing, play, ect?

If you are asking how you would use js controls with an already existing player, the answer is... you can't.

The reason is that you have to have ExternalInterface.AddCallback functionality already existent within the player and the domain that the .js is on has to be allowed with Security.AllowDomains.

What I have done, however, with players that I have found, is to pull down the .swf and decompile it using SWF Decompiler. I then load that up into Flash and add the necessary lines of code. note, this will work with many more simple players where the site is not ultra secure. In the case of the big boys, this is going to be difficult.

Alternatively, you could create your own player and instead pull the flvs in directly.

So, in otherwords, you need access to be able to change both the code in your js AND the code in the player to be able to add Boxee controls.

xmcnuggetx
May 8th, 2009, 03:31 PM
boxee does allow this already if you use the flash:// url. Using a specially formatted .js file it allows you to send commands to the flash movie (like mouse clicks). Check http://developer.boxee.tv/rss-specification/ at the bottom of the page.

Example (hulu's .js): http://dir.boxee.tv/apps/hulu/player.js

ameno
May 8th, 2009, 03:39 PM
boxee does allow this already if you use the flash:// url. Using a specially formatted .js file it allows you to send commands to the flash movie (like mouse clicks). Check http://developer.boxee.tv/rss-specification/ at the bottom of the page.


Yes, I know, I have built several already (check out the LP33 application in your app box... I built most of that). BUT, the .swf player itself has to be able to receive those commands and know what to do with them.

Communication between flash and javascript is accomplished via the ExternalInterface class.

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html

Be sure to also note the security sandbox settings there that will need to be set.

Essentially, if the security is allowed, you can fire calls into the swf all day, but if the call itself is not registered and assigned to a function within the swf, the call from js is not going to do anything.

Also, to have FULL functionality (progress bar, volume), you need to have two way calls. So, the swf needs to also call into the js. You need to be able to alter the players actionscript.

xmcnuggetx
May 8th, 2009, 04:06 PM
I understand it can be done through the external interface, but check the hulu example it isn't using scriptable() it's simply using js to move the mouse and click the buttons as if it were the user.

ameno
May 8th, 2009, 05:01 PM
I understand it can be done through the external interface, but check the hulu example it isn't using scriptable() it's simply using js to move the mouse and click the buttons as if it were the user.

Right. Ok, so what you are asking is not about a player "found" on a web page, but a player EMBEDDED in a web page. Looks pretty straight forward to me. You are able to move the mouse and execute actions (like click) with those undocumented methods: FWMouseMove,FWGetPixel,FWMouseClick.

The thing you need to do in that case is pop the browser and center it as opposed to just playing a flash player.

That part is undocumented.

I haven't really dug crazily into hulus code, but it looks like (for example)

path = http://www.hulu.com/watch/56907/30-days-outsourcing#http%3A%2F%2Fwww.hulu.com%2Ffeed%2Fsho w%2F8.rss

url = "flash://hulu.com/src=" + urllib.quote( path ) + "&bx-ourl=" + urllib.quote( path )

Then you build out the list item and run

xbmc.Player( xbmc.PLAYER_CORE_AUTO ).play( url, listitem )

Somehow that is popping the browser into the player. I'm sure it could be reverse engineered, but it's actually a lot more work to set that up for a website than it is to just find the flash files (screen scrape or whatever) and bring them in.

vulkan
May 9th, 2009, 10:17 AM
@xmcniggetx - you need to add "&bx-jsactions=http://...." to the end of the flash:// url.
this parameter (bx-jsactions) tells boxee where to take the controlling .js from.

happy debugging :)

-vulkan.

jdchmiel
October 19th, 2009, 04:53 PM
I am trying to accomplish just including my own js file during development:

boxee.enableLog(true);
boxee.log('Find abcxyz in the log');

is the entire contents of my js file currently, just for proof of it loading.
In a windows environment, is the path:
C:\Program Files\Boxee\system\players\flashplayer\myjs.js
accurate for the location of my file?
is there any better documentation out there at all? I must say that the 3 days of struggling to find documentation for this boxee system as a whole has been a very negative experience. I am now resorting to just blindly asking questions...

DPK
October 19th, 2009, 11:46 PM
is there any better documentation out there at all? I must say that the 3 days of struggling to find documentation for this boxee system as a whole has been a very negative experience. I am now resorting to just blindly asking questions...

http://developer.boxee.tv
http://wiki.boxee.tv/JavaScript_API

jdchmiel
October 20th, 2009, 10:00 AM
yeah... figured that was all there was...

jdchmiel
October 20th, 2009, 11:16 AM
This is a line from my log, generated by the main.xml file:
11:11:15 T:4520 M:2078978048 NOTICE: abcxyz: flash://games.mu.isglab.com/src=http%3A//games.mu.isglab.com/flashgames/ballz/Ballz.swf&bx-jsactions=http%3A//jared.isglab.com/gameRSS/games.mu.isglab.js

This is the relevant code I copied and edited from the hulu app:
<content type="url" url="rss://jared.isglab.com/gameRSS/gameRSS.xml">
<onclick lang="python"><![CDATA[
import urllib
import os
import xbmc
import xbmcgui
import datetime
import random
import Cookie
import mc

try:
n = mc.GetWindow(711).GetList(111).GetFocusedItem()
item = mc.GetWindow(711).GetList(111).GetItem(n)
path = item.GetPath()
if path.startswith("/"):
path = "http://games.mu.isglab.com" + path

javaurl = "http://jared.isglab.com/gameRSS/games.mu.isglab.js"
url = "flash://games.mu.isglab.com/src=%s&bx-jsactions=%s" % (urllib.quote(path),urllib.quote(javaurl))
print "abcxyz: %s" % (url)
item.SetPath(url)
mc.Player().PlayWithActionMenu(item)
except Exception, e:
mc.HideDialogWait()
print "games.mu.isglab feeds error: %s" % str(e)
mc.ShowDialogOk("Error", str( e ))
]]></onclick>
</content>


This is my first python experience, so hopefully some obvious error is preventing me from getting this to work? Any hints or suggestions are very welcome. The above code does open the flash object fine, but the JS file which is only trying to write to the log right now does not get loaded..

Fuzzgtp
October 20th, 2009, 12:25 PM
I never got the log in the js files to work (or cant figure out where the heck it outputs to)

try these to see if your js is working

boxee.autoChoosePlayer=false;
boxee.renderBrowser=true;

if it shows the browser page instead of loading ya know its loading

jdchmiel
October 20th, 2009, 12:50 PM
you sir, are my hero.
I don't know why I thought of something as obvious as the logging code just not doing anything.

Fuzzgtp
October 20th, 2009, 04:04 PM
you sir, are my hero.
I don't know why I thought of something as obvious as the logging code just not doing anything.

Cheers and good luck!