Nov. 03, 2009kisscool82
Hi !
I'm testing the audiodescription plugin. This plugin is pretty cool to add an audio track with another language.
My question is : How can I put the volume lower when I activate the audio description with the AD button ?
Does an event exist ?
Thx
Nov. 03, 2009hobbs
audiodescription plugin flashvars documentation: http://www.longtailvideo.com/support/forum/Plugins/20507/audio-description-controler
See the audiodescription.volume flashvar.
Nov. 04, 2009kisscool82
Sorry... It's not what what I mean.
Id'like to put the video's volume lower. Not the audiodescription's volume.
I try to increase the audio's volume, but it sounds very noisy...
Nov. 04, 2009hobbs
So... you want to change the volume level for the main audio if the user clicks on the "AD" button to activate the auxiliary audiodescription track?
You will have to find an event to monitor for the change, then confirm that the audiodescription plugin's state has changed, then adjust the main audio volume.
It has been my experience that the item Listener gets hit when the plugins are toggled. Here's how I monitor the HD plugin to change the player's size if the user toggles the HD state.
<script type="text/javascript">
var player = null;
var playlist = null;
var stuff = null;
var morestuff = null;
function playerReady(obj)
{
player = gid(obj.id);
addListeners();
};
function addListeners()
{
playlist = player.getPlaylist();
if(playlist.length > 0)
{
player.addControllerListener('ITEM', 'itemMonitor');
}
else
{
setTimeout("addListeners();", 100);
}
};
function itemMonitor(obj)
{
if(player.getPluginConfig('hd')['state'])
{
setFlashSize(600, 370);
}
else
{
setFlashSize(500, 313);
}
/*...only for testing
stuff = '<br />Item:';
for(var j in obj)
{
stuff += '<li>' + j + ': ' + obj[j] + '</li>';
}
stuff += '<li>hd.state: ' + player.getPluginConfig('hd')['state'] + '</li>';
gid('item').innerHTML = stuff;
setTimeout("gid('item').innerHTML = '';", 5000);
*/
/*...only for testing
var plugconfig = player.getPluginConfig('hd');
morestuff = '<br />HD Plugin Config:';
for(var j in plugconfig)
{
morestuff += '<li>' + j + ': ' + plugconfig[j] + '</li>';
}
gid('plugconfig').innerHTML = morestuff;
setTimeout("gid('plugconfig').innerHTML = '';", 5000);
*/
};
function setFlashSize(newW, newH)
{
gid('playercontainer').style.width = newW + 'px';
gid('playercontainer').style.height = newH + 'px';
player.width = newW;
player.height = newH;
//...DO NOT comment out this code
//...for some unknown reason,
//...the player won't re-size the first time,
//...unless the player config object is read
//...Internet Explorer only
var config = '<br />Config:';
for(var j in player)
{
config += '<li>' + j + ': ' + player[j] + '</li>';
}
//gid('config').innerHTML = config;
};
function gid(name)
{
return document.getElementById(name);
};
</script>
If the item Listener is indeed getting hit when the audiodescription state changes (you will have to do some testing to confirm this), then you would adjust the volume like this:
function itemMonitor(obj)
{
if(player.getPluginConfig('audiodescription')['state'])
{
player.sendEvent('VOLUME', '40');
}
else
{
player.sendEvent('VOLUME', '80');
}
Nov. 04, 2009kisscool82
It's exactly what I want to do.
I'll try your solution tomorrow.
It's a good idea to change player size when the HD button is pressed. I'll try this to
Thank you.
Nov. 04, 2009kisscool82
I can change the player size with the HD button thankyou
But the item event is not send when I press the AD button.
Is another event send ?
It's seems to be the same for captions.
Nov. 04, 2009hobbs
I couldn't find any event that changed when the audiodescription.state changes,
so I just used a simple looping timer.
<script type="text/javascript">
var player = null;
var playlist = null;
function playerReady(obj)
{
player = gid(obj.id);
addListeners();
};
function addListeners()
{
playlist = player.getPlaylist();
if(playlist.length > 0)
{
adChecker();
}
else
{
setTimeout("addListeners();", 100);
}
};
function adChecker(obj)
{
if(player.getPluginConfig('audiodescription')['state'])
{
player.sendEvent('VOLUME', '40');
}
else
{
player.sendEvent('VOLUME', '80');
}
setTimeout("adChecker();", 500);
//...only for testing
gid('adchecker').innerHTML = '<br />AudioDescription State: ' + player.getPluginConfig('audiodescription')['state'] + ' Player Volume: ' + player.getConfig()['volume'];
};
function gid(name)
{
return document.getElementById(name);
};
</script>
Throw this somewhere in your HTML for testing.
<div id="adchecker"></div>
Nov. 05, 2009kisscool82
Thank you for your advices.
I thought the same solution but i found it very ugly :p
Maybe it could be a good idea to add a spcial event for plugins
Nov. 05, 2009hobbs
It would be useful to have every plugin fire an event when it was toggled/activated/whatever, which could be monitored. Then, knowing that the plugin had changed, you could check the plugin's config file to see what had changed.
As it is now, the only way to do this is to look for an event that is being fired (like the HD plugin seems to always fire the ITEM event), but if there is no existing event being fired, then the only alternative is to run a loop, checking the plugin's config to see if something has changed. OR — alter the plugin, if the source is available.
Zach — comments???
Nov. 16, 2009Zachary Ozer
The ability to update the volume of the player when AD is enabled totally makes sense - we'll look into adding this in a future release. (Or, feel free to implement it and we'll add it into the source.)
As for plugin interaction (plugins sending events or calling methods on one another), we still haven't decided about the best way to handle this. Expect something more formalized for Player 5.
Here are some helpful links to learn more about the JW Player™:
Earn money with ads from LongTail's AdSolution. Watch our demos and sign up now!
If you don’t buy a commercial license, you cannot use a JW Player™ on (i) a site that has ads; (ii) a corporate site; or a (iii) CMS. Our licenses are very inexpensive, so what are you waiting for? Buy a license today.