[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r12316: Implement the "server side"
From: |
Rob Savoye |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r12316: Implement the "server side" in movie_root and Player for the ExternalInterface |
Date: |
Mon, 19 Jul 2010 14:13:29 -0600 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 12316 [merge]
committer: Rob Savoye <address@hidden>
branch nick: trunk
timestamp: Mon 2010-07-19 14:13:29 -0600
message:
Implement the "server side" in movie_root and Player for the ExternalInterface
commands SetVariable, GetVariable, IsPlaying, PercentLoaded, Play, Rewind,
TotalFrames, and StopPlay.
Don't fake out PercentLoaded in the plugin, since it now works correctly.
modified:
gui/Player.cpp
libcore/movie_root.cpp
plugin/npapi/callbacks.cpp
=== modified file 'gui/Player.cpp'
--- a/gui/Player.cpp 2010-07-14 13:51:15 +0000
+++ b/gui/Player.cpp 2010-07-19 20:13:29 +0000
@@ -629,6 +629,44 @@
return "";
}
+ if (event == "ExternalInterface.Play") {
+ _gui.play();
+ return "";
+ }
+
+ if (event == "ExternalInterface.StopPlay") {
+ _gui.pause();
+ return "";
+ }
+
+ if (event == "ExternalInterface.Rewind") {
+ _gui.restart();
+ return "";
+ }
+
+ if (event == "ExternalInterface.Pan") {
+ // FIXME: the 3 args are encoded as 1:2:0
+ log_unimpl("ExternalInterface.Pan");
+ return "";
+ }
+
+ if (event == "ExternalInterface.IsPlaying") {
+ return (_gui.isStopped()) ? "false" : "true";
+ }
+
+ if (event == "ExternalInterface.SetZoomRect") {
+ // FIXME: the 4 arguments are encoded as 1:2:0:1
+ log_unimpl("ExternalInterface.SetZoomRect");
+ return "";
+ }
+
+ if (event == "ExternalInterface.Zoom") {
+ // The 1 argument is a percentage to zoom
+ int percent = strtol(arg.c_str(), NULL, 0);
+ log_unimpl("ExternalInterface.Zoom(%d)", percent);
+ return "";
+ }
+
if (event == "System.capabilities.screenResolutionX") {
std::ostringstream ss;
=== modified file 'libcore/movie_root.cpp'
--- a/libcore/movie_root.cpp 2010-07-19 10:33:58 +0000
+++ b/libcore/movie_root.cpp 2010-07-19 20:13:29 +0000
@@ -1561,46 +1561,76 @@
} else if (invoke->name == "SetVariable") {
// SetVariable doesn't send a response
+ MovieClip *mc = getLevel(0);
+ as_object *obj = getObject(mc);
+ string_table &st = getStringTable(*obj);
+ std::string var = invoke->args[0].to_string();
+ as_value &val = invoke->args[1] ;
+ obj->set_member(st.find(var), val);
} else if (invoke->name == "GetVariable") {
// GetVariable sends the value of the variable
-#if 1
- as_value val("Hello World");
- // FIXME: need to use a real value
-#else
- as_object::SortedPropertyList props;
- enumerateProperties(o, props);
-#endif
+ MovieClip *mc = getLevel(0);
+ as_object *obj = getObject(mc);
+ string_table &st = getStringTable(*obj);
+ std::string var = invoke->args[0].to_string();
+ as_value val;
+ obj->get_member(st.find(var), &val);
ss << ExternalInterface::toXML(val);
} else if (invoke->name == "GotoFrame") {
// GotoFrame doesn't send a response
} else if (invoke->name == "IsPlaying") {
- // IsPlaying sends true or false
- as_value val(true);
- // FIXME: need to use a real value
+ std::string result = callInterface("ExternalInterface.IsPlaying");
+ as_value val((result == "true") ? true : false);
ss << ExternalInterface::toXML(val);
} else if (invoke->name == "LoadMovie") {
+ log_unimpl("ExternalInterface::LoadMovie()");
// LoadMovie doesn't send a response
} else if (invoke->name == "Pan") {
// Pan doesn't send a response
+ std::string arg = invoke->args[0].to_string();
+ arg += ":";
+ arg += invoke->args[0].to_string();
+ arg += ":";
+ arg += invoke->args[1].to_string();
+ arg += ":";
+ arg += invoke->args[2].to_string();
+ callInterface("ExternalInterface.Pan", arg);
} else if (invoke->name == "PercentLoaded") {
// PercentLoaded sends the percentage
- as_value val(100);
- // FIXME: need to use a real value
+ MovieClip *mc = getLevel(0);
+ int loaded = mc->get_bytes_loaded();
+ int total = mc->get_bytes_total();
+ as_value val((loaded/total) * 100);
ss << ExternalInterface::toXML(val);
} else if (invoke->name == "Play") {
+ callInterface("ExternalInterface.Play");
// Play doesn't send a response
} else if (invoke->name == "Rewind") {
+ callInterface("ExternalInterface.Rewind");
// Rewind doesn't send a response
} else if (invoke->name == "SetZoomRect") {
+ std::string arg = invoke->args[0].to_string();
+ arg += ":";
+ arg += invoke->args[0].to_string();
+ arg += ":";
+ arg += invoke->args[1].to_string();
+ arg += ":";
+ arg += invoke->args[2].to_string();
+ arg += ":";
+ arg += invoke->args[3].to_string();
+ callInterface("ExternalInterface.SetZoomRect", arg);
// SetZoomRect doesn't send a response
} else if (invoke->name == "StopPlay") {
+ callInterface("ExternalInterface.SetZoomRect");
// StopPlay doesn't send a response
} else if (invoke->name == "Zoom") {
+ std::string var = invoke->args[0].to_string();
+ callInterface("ExternalInterface.Zoom", var);
// Zoom doesn't send a response
} else if (invoke->name == "TotalFrames") {
+ MovieClip *mc = getLevel(0);
+ as_value val(mc->get_loaded_frames());
// TotalFrames sends the number of frames in the movie
- as_value val(100);
- // FIXME: need to use a real value
ss << ExternalInterface::toXML(val);
} else {
std::string result = callExternalCallback(invoke->name, invoke->args);
=== modified file 'plugin/npapi/callbacks.cpp'
--- a/plugin/npapi/callbacks.cpp 2010-06-18 03:27:56 +0000
+++ b/plugin/npapi/callbacks.cpp 2010-07-19 20:13:29 +0000
@@ -348,22 +348,11 @@
// Receives something like this:
// <number>33</number>
bool
-PercentLoaded (NPObject */* npobj */, NPIdentifier /* name */, const NPVariant
*/*args */,
- uint32_t /* argCount */, NPVariant *result)
+PercentLoaded (NPObject *npobj, NPIdentifier /* name */, const NPVariant
*/*args */,
+ uint32_t argCount, NPVariant *result)
{
// log_debug(__PRETTY_FUNCTION__);
-#if 1
- static int counter = 0;
-// log_error("%s: %d ; %d\n", __FUNCTION__, gpso->getControlFD(), counter);
- INT32_TO_NPVARIANT(counter, *result);
- if (counter >= 100) {
- counter = 0;
- } else {
- counter += 20;
- }
- return true;
-#else
GnashPluginScriptObject *gpso = (GnashPluginScriptObject *)npobj;
if (argCount == 0) {
@@ -385,9 +374,9 @@
return false;
}
- NPVariant *value = ei.parseXML(data);
- if (NPVARIANT_IS_INT32(*value)) {
- INT32_TO_NPVARIANT(NPVARIANT_TO_INT32(*value), *result);
+ GnashNPVariant value = ExternalInterface::parseXML(data);
+ if (NPVARIANT_IS_INT32(value.get())) {
+ INT32_TO_NPVARIANT(NPVARIANT_TO_INT32(value.get()), *result);
} else {
INT32_TO_NPVARIANT(0, *result);
}
@@ -397,7 +386,6 @@
BOOLEAN_TO_NPVARIANT(false, *result);
return false;
-#endif
}
// Play();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r12316: Implement the "server side" in movie_root and Player for the ExternalInterface,
Rob Savoye <=