yahoo news video doesn't play on placeholder activation
yahoo news video doesn't play on placeholder activation
Fx 3.6.17 & 4.0.1, NS 2.1.0.3 & 2.1.0.4rc6, new profile, block flash on trusted
http://news.yahoo.com/video/
This is caused by the instantiation code keeping a reference to the temp dummy embed and then when the activated player fires a ready event (the player receives the event handler via the flashvars) the dummy is used to initiate playback, instead of the real object.
This type of problem could be solved by a new kind of page level activation surrogate that NS would invoke immediately after obtaining a reference to an activated object, somehow passing this reference to it, allowing it to connect the object to the page JS and initialize it if necessarily. In this case simply updating the reference should do the trick. This can probably also fix quicktime activation on apple.com. What do you think of this approach?
http://news.yahoo.com/video/
This is caused by the instantiation code keeping a reference to the temp dummy embed and then when the activated player fires a ready event (the player receives the event handler via the flashvars) the dummy is used to initiate playback, instead of the real object.
This type of problem could be solved by a new kind of page level activation surrogate that NS would invoke immediately after obtaining a reference to an activated object, somehow passing this reference to it, allowing it to connect the object to the page JS and initialize it if necessarily. In this case simply updating the reference should do the trick. This can probably also fix quicktime activation on apple.com. What do you think of this approach?
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17
- Giorgio Maone
- Site Admin
- Posts: 9524
- Joined: Wed Mar 18, 2009 11:22 pm
- Location: Palermo - Italy
- Contact:
Re: yahoo news video doesn't play on placeholder activation
It sounds good. Any code?
Mozilla/5.0 (Windows NT 5.2; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
- Giorgio Maone
- Site Admin
- Posts: 9524
- Joined: Wed Mar 18, 2009 11:22 pm
- Location: Palermo - Italy
- Contact:
Re: yahoo news video doesn't play on placeholder activation
Sorry, I made some attempts but didn't manage to make this work.
The main problem is that the object originally instantiated cannot be reused (it needs to be cloned in order to play correctly), so the instance grabbed by the code cannot be manipulated.
On the other hand, there's no way to change the instance itself.
Probably the only way to make this is modifying original instance to proxy every single call and forward it to the new instance: I'm trying, but so far with not much success because of native wrappers. Surely it won't make next stable.
If you've got other ideas, please feel free to share.
The main problem is that the object originally instantiated cannot be reused (it needs to be cloned in order to play correctly), so the instance grabbed by the code cannot be manipulated.
On the other hand, there's no way to change the instance itself.
Probably the only way to make this is modifying original instance to proxy every single call and forward it to the new instance: I'm trying, but so far with not much success because of native wrappers. Surely it won't make next stable.
If you've got other ideas, please feel free to share.
Mozilla/5.0 (Windows NT 5.2; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
- Giorgio Maone
- Site Admin
- Posts: 9524
- Joined: Wed Mar 18, 2009 11:22 pm
- Location: Palermo - Italy
- Contact:
Re: yahoo news video doesn't play on placeholder activation
OK, this is what I'm currently trying right before replacing the placeholder with the cloned embedded element:
While the function proxying code seems to work correctly, I never see an alert with a function call.
It would seem no function gets called on the original object, unless I'm missing something.
Code: Select all
var obj = ctx.object.cloneNode(true);
let sb = new CU.Sandbox(ctx.window, { wantXrays: false });
sb.o = ctx.object;
sb.c = obj;
sb.w = ctx.window;
CU.evalInSandbox("for (var p in o) if (typeof o[p] === 'function') (function(p) { c[p] = o[p]; o[p] = function() { w.alert(p); return c[p].apply(c, arguments); }})(p)", sb);
It would seem no function gets called on the original object, unless I'm missing something.
Mozilla/5.0 (Windows NT 5.2; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Re: yahoo news video doesn't play on placeholder activation
The idea I had was to execute a per page customized piece of code (surrogate) on placeholder activation after the plugin is created, allowing this code to update the page's references to the plugin, that would otherwise continue pointing to the dead dummy node. From my debugging session, it looked possible, there is only a single reference to the plugin object and it's reachable and updatable from top level page code (surrogate)Giorgio Maone wrote:Sorry, I made some attempts but didn't manage to make this work.
You seem to be trying a generic approach by turning the dummy into a proxy to the real node? If that can work reliably, it would be better than a surrogate and ought to be sufficient in this case. Are there caveats, like property access or anything layout related? There are probably scenarios where extra initialization is needed after instantiation so an activation surrogate would still be necessary.
I debugged the page, before the first post, the player is definitely scripted after becoming ready, that's how it gets its playlist, which is not supplied through the flashvarsGiorgio Maone wrote:It would seem no function gets called on the original object
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17
- Giorgio Maone
- Site Admin
- Posts: 9524
- Joined: Wed Mar 18, 2009 11:22 pm
- Location: Palermo - Italy
- Contact:
Re: yahoo news video doesn't play on placeholder activation
So this should be an ad hoc per-site surrogate, right?al_9x wrote: The idea I had was to execute a per page customized piece of code (surrogate) on placeholder activation after the plugin is created, allowing this code to update the page's references to the plugin, that would otherwise continue pointing to the dead dummy node. From my debugging session, it looked possible, there is only a single reference to the plugin object and it's reachable and updatable from top level page code (surrogate)
And how should it look like?
As far as I could see, the stored instance is a local var called "instance" which is visible only from inside some closures, and as such it's not updatable by my code.
Am I missing something obvious?
Mozilla/5.0 (Windows NT 5.2; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Re: yahoo news video doesn't play on placeholder activation
Yes, page level, invoked on plugin activation. Are you giving up on proxying?Giorgio Maone wrote:So this should be an ad hoc per-site surrogate, right?
It would need to receive the ref to the created plugin (player id and flashvars which could be useful can be obtained from it, right?). Not sure what is that best way to accomplish this, maybe have the surrogate define a function that NS would call? That could be done by a @ surrogate, so no need for a new type.Giorgio Maone wrote:And how should it look like?
The ref to the player embed is "YAHOO.Media.Hub.Player.player._player" and should be updatable. Where did you see this "instance" var?Giorgio Maone wrote:As far as I could see, the stored instance is a local var called "instance" which is visible only from inside some closures, and as such it's not updatable by my code.
Am I missing something obvious?
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17
- Giorgio Maone
- Site Admin
- Posts: 9524
- Joined: Wed Mar 18, 2009 11:22 pm
- Location: Palermo - Italy
- Contact:
Re: yahoo news video doesn't play on placeholder activation
Yes, because it doesn't work. It seems the player doesn't get called directly.al_9x wrote:Yes, page level, invoked on plugin activation. Are you giving up on proxying?Giorgio Maone wrote:So this should be an ad hoc per-site surrogate, right?
In fact, I changed all the code above with justal_9x wrote:It would need to receive the ref to the created plugin (player id and flashvars which could be useful can be obtained from it, right?).Giorgio Maone wrote:And how should it look like?
Code: Select all
ScriptSurrogate.execute(doc, ' YAHOO.Media.Hub.Player.player._player = document.getElementById("' + obj.id + '")')
Calling "toSource()" on functions (e.g. accessibilityFunction()) called by the player's UI elements, such asal_9x wrote: The ref to the player embed is "YAHOO.Media.Hub.Player.player._player" and should be updatable. Where did you see this "instance" var?
Code: Select all
<button id="player_access_controls_play_63299" accesskey="1" title="Play/Pause Video" value="Play/Pause Video" onclick="YEP63299.accessibilityFunction('togglePlayPause')">Play/Pause Video</button>
Mozilla/5.0 (Windows NT 5.2; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Re: yahoo news video doesn't play on placeholder activation
Their code sets innerhtml and then does getelementnyid on the same stack to get the player ref. Does it not retrieve the dummy node which forwards, this way? Then since they definitely call through that ref to load the playlist and start playback, why would forwarding not work?Giorgio Maone wrote:Yes, because it doesn't work. It seems the player doesn't get called directly.al_9x wrote:Yes, page level, invoked on plugin activation. Are you giving up on proxying?Giorgio Maone wrote:So this should be an ad hoc per-site surrogate, right?
The page polls for player readiness and then starts playback, so as long as the ref is updated before ready fires, it should work. Can you make a test build (or paste the code, so I can add it) where you invoke a content function (if present, to be set up by a surrogate) immediately after player creation (it has to be synchronous with no delays, otherwise ready will fire first). I'll play around with it, try to get it working.Giorgio Maone wrote:In fact, I changed all the code above with justal_9x wrote:It would need to receive the ref to the created plugin (player id and flashvars which could be useful can be obtained from it, right?).Giorgio Maone wrote:And how should it look like?called just after the node gets replaced. The replacement does work, but the movie does not autoplay anyway.Code: Select all
ScriptSurrogate.execute(doc, ' YAHOO.Media.Hub.Player.player._player = document.getElementById("' + obj.id + '")')
What you're seeing there is a delegate function:Giorgio Maone wrote:Calling "toSource()" on functions (e.g. accessibilityFunction()) called by the player's UI elements, such asal_9x wrote: The ref to the player embed is "YAHOO.Media.Hub.Player.player._player" and should be updatable. Where did you see this "instance" var?Code: Select all
<button id="player_access_controls_play_63299" accesskey="1" title="Play/Pause Video" value="Play/Pause Video" onclick="YEP63299.accessibilityFunction('togglePlayPause')">Play/Pause Video</button>
Code: Select all
function _delegate(instance, method) {
return function() {
return method.apply(instance, arguments)
}
}
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17
- Giorgio Maone
- Site Admin
- Posts: 9524
- Joined: Wed Mar 18, 2009 11:22 pm
- Location: Palermo - Italy
- Contact:
Re: yahoo news video doesn't play on placeholder activation
You don't need a custom build, you can just leverage DOM mutation events:
(of course run this after page's onload fires to ensure the placeholder is there)
Code: Select all
document.getElementsByClassName("__noscriptPlaceholder__")[0].parentNode.addEventListener("DOMNodeInserted", function(ev) {
if (ev.target instanceof HTMLEmbedElement) alert(YAHOO.Media.Hub.Player.player._player = ev.target);
}, false)
Mozilla/5.0 (Windows NT 5.2; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Re: yahoo news video doesn't play on placeholder activation
ok, i'll try this, is it guaranteed to be called before the plugin can fire any events?Giorgio Maone wrote:You don't need a custom build, you can just leverage DOM mutation events:(of course run this after page's onload fires to ensure the placeholder is there)Code: Select all
document.getElementsByClassName("__noscriptPlaceholder__")[0].parentNode.addEventListener("DOMNodeInserted", function(ev) { if (ev.target instanceof HTMLEmbedElement) alert(YAHOO.Media.Hub.Player.player._player = ev.target); }, false)
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17
- Giorgio Maone
- Site Admin
- Posts: 9524
- Joined: Wed Mar 18, 2009 11:22 pm
- Location: Palermo - Italy
- Contact:
Re: yahoo news video doesn't play on placeholder activation
Yes, it's called even before the next instruction in the same flow as the replaceChild() call which inserts the element.al_9x wrote:ok, i'll try this, is it guaranteed to be called before the plugin can fire any events?Giorgio Maone wrote:You don't need a custom build, you can just leverage DOM mutation events:(of course run this after page's onload fires to ensure the placeholder is there)Code: Select all
document.getElementsByClassName("__noscriptPlaceholder__")[0].parentNode.addEventListener("DOMNodeInserted", function(ev) { if (ev.target instanceof HTMLEmbedElement) alert(YAHOO.Media.Hub.Player.player._player = ev.target); }, false)
Mozilla/5.0 (Windows NT 5.2; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Re: yahoo news video doesn't play on placeholder activation
This worked. I ran it as a bookmarklet, then the plugin started playing on activation. The placeholder is not yet there onload, so one would have poll for it, or perhaps attach to another node since I think the event bubbles. Regardless, it's cumbersome to set this up using current functionality, is it worth it making it easier?Giorgio Maone wrote:You don't need a custom build, you can just leverage DOM mutation events:(of course run this after page's onload fires to ensure the placeholder is there)Code: Select all
document.getElementsByClassName("__noscriptPlaceholder__")[0].parentNode.addEventListener("DOMNodeInserted", function(ev) { if (ev.target instanceof HTMLEmbedElement) alert(YAHOO.Media.Hub.Player.player._player = ev.target); }, false)
About the proxying, the page saves the ref returned by getelementbyid, is it getting your proxy this way? If not that explains it, but if it is, then I don't see why it wouldn't work.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17
- Giorgio Maone
- Site Admin
- Posts: 9524
- Joined: Wed Mar 18, 2009 11:22 pm
- Location: Palermo - Italy
- Contact:
Re: yahoo news video doesn't play on placeholder activation
Should be fixed in latest development build (by dynamically proxying both the placeholder and the original removed element, so that custom methods are intercepted no matter how the reference had been obtained).
Mozilla/5.0 (Windows NT 5.2; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Re: yahoo news video doesn't play on placeholder activation
Ok in 4.0.1, but not working in 3.6.17, should it?Giorgio Maone wrote:Should be fixed in latest development build (by dynamically proxying both the placeholder and the original removed element, so that custom methods are intercepted no matter how the reference had been obtained).
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17