0

I got one plugin and embeded to my webpage page, the plugin is used to play media files(.mp3,mp4,m3u8, etc).my webpage looks like:

<div id='div1'>Plugin</div>
<div id='div2'><div id='div2sub'></div></div>

Plugin created like

<object id='plugin' type='xxxx' width='xxxx' height='xxxx'></object>

the problem is: when i move plugin from div1 to div2sub like:

var x = document.getElementById('plugin');
var y = document.getElementById('div2sub');
y.appenChild(x);

then I find the result IE: the plugin still playing media file, video, audio output,it works fine(ActiveX plugin) Chrome and FireFox: No video, audio output,plugin not play media file anymore.(npapi Plugin)

I found the reason is: with IE, the Plugin just moved,not destroy then recreate, with chrome and FireFox,the plugin was destroy then recreated, I have one function to register callback event on pluin, chrome console shows my plugin never received callback event, so media file can't be played.

My question is: Is there anyway I can do just move plugin, and the plugin will not be destroyed and recreated with chrome and FireFox, just works like with IE.

Thanks for help...

Georg Fritzsche
  • 97,545
  • 26
  • 194
  • 236

2 Answers2

1

If the plugin really is getting re-created you should file a bug - re-parenting shouldn't re-spawn the plugin per the WhatWG object element and being rendered sections.

Georg Fritzsche
  • 97,545
  • 26
  • 194
  • 236
1

This is a pretty standard issue with npapi plugins, though; they don't behave reliably in any browser that I know of when you move them around in the DOM. Similar issues occur if you change the parent container to display: none, visibility: hidden, overflow: none, etc. ActiveX controls are even more fun.

The workaround I use is to put the plugin in a floating absolute positioned div. I put another div on the page where I want the plugin to be, and then whenever it needs to be moved I calculate the absolute position of the positioning div and move the floating div to be over it. It's a bit of a hack, but it works quite well.

taxilian
  • 14,229
  • 4
  • 34
  • 73
  • Yes, while ‘display:None’ used, This problem do occur. – user2638168 Aug 06 '13 at 08:13
  • when I hide a plugin I just set the width=1 and height=1 – taxilian Aug 06 '13 at 17:12
  • Hi, 'This is a pretty standard issue with npapi plugins', Can you show more details about it, for I need to show more evidence to our customer that they shouldn't use appendChild and dispaly: None and I'm newbie to npapi plugin,thanks. – user2638168 Aug 07 '13 at 03:11
  • Nope, I have no specific details other than my own experience using and writing plugins (including the FireBreath framework) for the last 4-5 years. – taxilian Aug 07 '13 at 05:08
  • @user2638168: If you still need details, see e.g. [bug 889614](https://bugzilla.mozilla.org/show_bug.cgi?id=889614) and [bug 90268](https://bugzilla.mozilla.org/show_bug.cgi?id=90268) - just two examples i remember in Firefox. I'm sure you could find more in our and Chromiums bugtracker. – Georg Fritzsche Sep 06 '13 at 19:53