Be able to pass variables to Flash #68

Closed
wants to merge 5 commits into
from

Conversation

Projects
None yet
2 participants
Contributor

magcius commented Dec 16, 2012

Implements flashvars. Should fix #53.

@yurydelendik yurydelendik and 1 other commented on an outdated diff Dec 17, 2012

extension/firefox/components/FlashStreamConverter.js
@@ -114,14 +133,15 @@ ChromeActions.prototype = {
var data = new Uint8Array(chunk.length);
for (var i = 0; i < data.length; i++)
data[i] = chunk.charCodeAt(i) & 0xFF;
- win.postMessage({callback:"loadFile", url: url,
+ win.postMessage({callback:"loadFile", url: url, params: params,
@yurydelendik

yurydelendik Dec 17, 2012

Contributor

this statement is called multiple times -- there is no point to pass params each time. Redesign API or send it only first time.

@magcius

magcius Dec 17, 2012

Contributor

what about: initial "loadFile" call with URL and params, and each piece of data from then on is sent in a "fileData" event, with the chunk of data, loaded, and total.

@yurydelendik

yurydelendik Dec 17, 2012

Contributor

Sounds good. Add session id or some other identifier to the loadFile and fileData events -- we may load more than one file in the future.

@yurydelendik yurydelendik commented on an outdated diff Dec 17, 2012

src/flash/display/Loader.js
@@ -311,7 +311,8 @@ var LoaderDefinition = (function () {
var def = {
initialize: function () {
- this._contentLoaderInfo = null;
+ this.contentLoaderInfo = new flash.display.LoaderInfo;
@yurydelendik

yurydelendik Dec 17, 2012

Contributor

Not sure why the getter is removed. Initialize it here in _contentLoaderInfo and keep the simple getter to "signify" read-only nature of the property

Contributor

yurydelendik commented Dec 17, 2012

Please squash the commits into one.

Contributor

magcius commented Dec 17, 2012

Which commits?

Contributor

yurydelendik commented Dec 17, 2012

Which commits?

All in magcius:params branch

Contributor

magcius commented Dec 17, 2012

Huh -- why? All of them are logical changes that stand on their own...

Contributor

yurydelendik commented Dec 17, 2012

They all look like small step-by-step changes to fix simple issue #53.

Contributor

yurydelendik commented Dec 17, 2012

How would I test the solution? Can you create a simple html/swf demo, e.g. in the examples folder?

Contributor

magcius commented Dec 17, 2012

I wrote a simple example that calls trace() on all the flash vars it gets, and confirmed it worked in the inspector.

@yurydelendik yurydelendik commented on an outdated diff Dec 21, 2012

extension/firefox/components/FlashStreamConverter.js
@@ -144,7 +163,7 @@ ChromeActions.prototype = {
}
win.postMessage({callback:"loadFile", sessionId: sessionId, topic: "close"}, "*");
} else if (xhr.readyState === 1) {
- win.postMessage({callback:"loadFile", sessionId: sessionId, topic: "open"}, "*");
+ win.postMessage({callback:"loadFile", sessionId: sessionId, topic: "open", params: params}, "*");
@yurydelendik

yurydelendik Dec 21, 2012

Contributor

This method is used not only for movie download. Loading of the other file don't params. Please use other way to transmit params than "loadFile".

@yurydelendik yurydelendik commented on an outdated diff Dec 21, 2012

extension/firefox/content/web/viewer.html
@@ -199,12 +199,8 @@
function runViewer() {
var flashParams = JSON.parse(FirefoxCom.requestSync('getPluginParams', null));
- movieUrl = flashParams.url;
- var movieArgs = flashParams.arguments;
- var isOverlay = flashParams.isOverlay;
- console.log("url=" + movieUrl + ";params=" + uneval(movieArgs));
- FirefoxCom.requestSync('loadFile', {url: movieUrl, sessionId: 0});
- if (isOverlay) {
+ FirefoxCom.requestSync('loadFile', flashParams);
@yurydelendik

yurydelendik Dec 21, 2012

Contributor

The extension needs sessionId field and there is no need to send flashParams back. Use {url: flashParams.url, sessionId: 0} instead.

@yurydelendik yurydelendik commented on the diff Jan 24, 2013

examples/inspector/inspector.js
@@ -90,13 +90,31 @@ var builtinPath = avm2Root + "generated/builtin/builtin.abc";
var libraryPath = avm2Root + "generated/shell/shell.abc";
var playerGlobalPath = "../../src/flash/playerGlobal.min.abc";
+function parseQueryString(qs) {
+ if (!qs)
+ return {};
+
+ if (qs.charAt(0) == '?')
+ qs = qs.slice(1);
+
+ var values = qs.split('&');
+ var obj = {};
+ for (var i = 0; i < values.length; i++) {
+ var kv = values[i].split('=');
+ var key = kv[0], value = kv[1];
@yurydelendik

yurydelendik Jan 24, 2013

Contributor

value = decodeURIComponent(kv[1]);

@yurydelendik yurydelendik commented on the diff Jan 24, 2013

examples/inspector/inspector.js
@@ -90,13 +90,31 @@ var builtinPath = avm2Root + "generated/builtin/builtin.abc";
var libraryPath = avm2Root + "generated/shell/shell.abc";
var playerGlobalPath = "../../src/flash/playerGlobal.min.abc";
+function parseQueryString(qs) {
+ if (!qs)
+ return {};
+
+ if (qs.charAt(0) == '?')
+ qs = qs.slice(1);
+
+ var values = qs.split('&');
+ var obj = {};
+ for (var i = 0; i < values.length; i++) {
+ var kv = values[i].split('=');
@yurydelendik

yurydelendik Jan 24, 2013

Contributor

if param value will have extra = the value will be truncated, e.g. key=val=ue. It's better to use indexOf here

@yurydelendik yurydelendik commented on the diff Jan 24, 2013

extension/firefox/components/FlashStreamConverter.js
@@ -64,6 +64,24 @@ function combineUrl(baseUrl, url) {
}
}
+function parseQueryString(qs) {
@yurydelendik

yurydelendik Jan 24, 2013

Contributor

same comments as above

@yurydelendik yurydelendik commented on an outdated diff Jan 24, 2013

extension/firefox/content/web/viewer.html
@@ -220,11 +220,11 @@
function runViewer() {
var flashParams = JSON.parse(FirefoxCom.requestSync('getPluginParams', null));
movieUrl = flashParams.url;
- var movieArgs = flashParams.arguments;
+ var movieParams = flashParams.params;
@yurydelendik

yurydelendik Jan 24, 2013

Contributor

make movieParams global (similar to movieUrl)

@yurydelendik yurydelendik commented on an outdated diff Jan 24, 2013

extension/firefox/content/web/viewer.html
var isOverlay = flashParams.isOverlay;
pauseExecution = flashParams.isPausedAtStart;
- console.log("url=" + movieUrl + ";params=" + uneval(movieArgs));
- FirefoxCom.requestSync('loadFile', {url: movieUrl, sessionId: 0});
+ console.log("url=" + movieUrl + ";params=" + uneval(movieParams));
+ FirefoxCom.requestSync('loadFile', {url: movieUrl, params: flashParams, sessionId: flashParams});
@yurydelendik

yurydelendik Jan 24, 2013

Contributor

remove params from here

@yurydelendik yurydelendik commented on an outdated diff Jan 24, 2013

extension/firefox/content/web/viewer.html
@@ -278,7 +278,7 @@
switch (args.topic) {
case "open":
subscription = new Subscription();
- parseSwf(movieUrl, subscription);
+ parseSwf(movieUrl, args.params, subscription);
@yurydelendik

yurydelendik Jan 24, 2013

Contributor

use global movieParams created above

magcius added some commits Dec 16, 2012

@magcius magcius Loader: Don't lazily init the contentLoaderInfo field
We use it almost immediately after we create it, so this makes
no sense.
0bca897
@magcius magcius extension: Rename some loader variables
Make naming consistent between components.
5723ee4
@magcius magcius extension: Use the "flashvars" attribute to grab params from
Embed parameters are not passed to the movie.
b3348c6
@magcius magcius Add support for passing movie params
In the case of the inspector, we simply use the entire query string
of the page if there's an "rfile" and pass it directly to the SWF.

In the case of the viewer, we parse the <embed>/<object> parameters.
We eventually may need to parse the query string after the src URL.
5fd02ed
@magcius magcius LoaderInfo: Add support for _getArgs
This is what's used; "get parameters" just calls this internally
and makes a copy.
f28d0f0
Contributor

yurydelendik commented Feb 13, 2013

f28d0f0 is broken, replaced by 8feae58

Added examples at examples/external/params.html (see 6006dba): not all ways to pass parameters work as in flash player

Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment