Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

In my page i am embedding youtube.
When the page is loading in two browser like firefox with flash support and chrome without flash support.

Now i need to know whether it's loaded using flash or HTML Video

HTML
<iframe id="ivideo" width="560" height="315" src="http://www.youtube.com/embed/videoname" frameborder="0" allowfullscreen></iframe>

Help me to find the player.
Posted
Updated 5-Jun-13 2:46am
v2
Comments
Mohibur Rashid 4-Jun-13 2:00am    
youtube video? then it is flash
saravana__ 4-Jun-13 2:45am    
No its played on html5 video plyer too
Sunasara Imdadhusen 4-Jun-13 6:02am    
Have try on google?
saravana__ 4-Jun-13 6:41am    
Yes tried on google but no one search like this

1 solution

Html 5 will use a media element. Flash will use an object element.

pick a starting element and do a recursive loop until you find the answer.

This is the recursive function that will check the tag name of each element.

JavaScript
function checkForPlayer(el)
{
  var result = null;

  if(el.tagName)
    if(el.tagName.toLowerCase() == 'object')
      result = 'flash';
    else if(el.tagName.toLowerCase() == 'media')
      result = 'html5';

  if(result != null)
    return result;

  for(var i = 0; i < el.childNodes.length; i++)
  {
    result = checkForPlayer(el.childNodes[i]);
    if(result != null)
      return result;
  }

}


This is how to use it.

JavaScript
var myElement = document.getElementById('myElementId');

var result = checkForPlayer(myElement);

var resultText = result == null ? 'none' : result;

alert(resultText);
 
Share this answer
 
Comments
saravana__ 6-Jun-13 0:15am    
It's not working..Tell me some other methods to find the player type.
Stephen Hewison 6-Jun-13 7:07am    
That is the method. You many have to interrogate the contents of the iframe document instead of your document.
saravana__ 7-Jun-13 2:02am    
How to get the iframe content..
I am trying some methods buts no one work perfectly in my page..

The code was
var content = parent.document.getElementById(iframe_id).contentWindow;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900