Q: Display content based on browser language or IP address to show either youtube or youku video I was wondering what would be the best way to display a youtube embed to users from all over the world but show a youku player or JW player embed to visitors where Youtube is blocked (like China)...
I think a way would be to do it either based on IP or on browser/OS language.
Which do you think that would be the best option and can anyone suggest how to do this most effectively?
(I think that browser language or preferably even OS language would be a good option..)
Thanks!
Wick.

A: What you wanna do is to dynamically change the HTML content according to the user's Geo location.
You can do either of the way below:


*

*Use HTML5's Geolocation feature. Embed two videos into the same HTML page and use javascript to decide which one of them to show;

*Use server side to detect the Geo location (like you said, using IP address detection), and write HTML using whatever server-side technology you're using. For example if you're using JavaEE, this link might help you.


A: Here's my solution. It retrieves the browser's language preference, and performs a different function if the detected language preference is "zh-cn" (the language code for Chinese (PRC)). It should work in Chrome, Firefox, Safari, and IE.
var language = window.navigator.userLanguage || window.navigator.language;
if (language == "zh-cn") {
     //Non-YouTube code here
} else {
     //YouTube code here
}

http://jsfiddle.net/IronFlare/94q2L4wm/
If you want to use the alternative player for other languages, too, the list of codes I used is available here:
http://4umi.com/web/html/languagecodes.php
