Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 21st, 2011, 1:49 AM   #1
bbshuanhe
Banned
 
Join Date: Sep 2011
Posts: 17
Rep Power: 0 bbshuanhe is on a distinguished road
browser and OS identifier

i'm making a page with embedded video in it but instead of have people select the format they want i'd like it just to play automatically based on their browser/OS...i've seen things in people's signatures when i've browsed forums where it tells what browser and OS you're running, so i was thinking of using code like that to have the correct video format automatically play...can anyone share a helping link or some code? thanks
bbshuanhe is offline   Reply With Quote
Old Sep 21st, 2011, 2:01 AM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Google / Kitchener
Posts: 4,154
Rep Power: 15 Sane has a spectacular aura aboutSane has a spectacular aura about
Send a message via MSN to Sane
Re: browser and OS identifier

This is done by poking into the User-Agent attribute in the HTTP Header of the request made to your server. Some browsers will send some OS information along inside, and so you can parse that out.

The problem is that there's no "standard" way to encode the OS information in the User-Agent, nor is a browser required to send that information, nor is that information even guaranteed to be accurate. Some users can even choose to fake (i.e. "spoof") the information placed into the User-Agent if they do desire.

I would suggest looking into seeing what people have wrote in terms of mapping User-Agents to OS/Browser information. Surely someone has already written a parser/mapper in PHP with some amount of success.

If you want to tackle this yourself, then take a look at $_SERVER['HTTP_USER_AGENT']. There is also a get_browser() function.
__________________
PFO's Folding@Home Team | Sane's Monthly Algorithms Challenges
Rules | How to Post a Question | How to Post Code

Becoming a good programmer requires foresight of your code's execution.
Becoming an excellent programmer requires foresight of your code's modification.
Sane is offline   Reply With Quote
Old Sep 21st, 2011, 10:30 AM   #3
NightCrawler03X
Web Developer
 
NightCrawler03X's Avatar
 
Join Date: Jan 2009
Location: England
Posts: 222
Rep Power: 6 NightCrawler03X is on a distinguished road
Send a message via MSN to NightCrawler03X
Re: browser and OS identifier

You can use PHP for detecting user agent.

You could use a small if else chain, with different codecs for different browsers.

First, check to see if it is a browser known to support HTML5 video (WebM) and use that.

Failing that, you can also check to see what plugins they have. If they have flash, you could use one of many free flash-based movie players.

Just an idea.

As Sane said though, many people can spoof their UA. I did this myself at one time.

A lot of the time, browsers might also identify differently. For example, at one time I tested a webserver by accessing it in Chrome.

I checked the Apache access logs and for that it said Safari as the User Agent, when I know it was chrome (remember that both chrome and safari use the webkit rendering engine).


hope that helps.
NightCrawler03X is offline   Reply With Quote
Old Sep 21st, 2011, 11:00 AM   #4
HttpListener
Hobbyist Programmer
 
HttpListener's Avatar
 
Join Date: Jun 2011
Location: IRAN-Zanjan
Posts: 104
Rep Power: 4 HttpListener is on a distinguished road
Send a message via Yahoo to HttpListener
Re: browser and OS identifier

use properties of navigator object in javascript
navigator.appName
navigator.platform
HttpListener is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Questions from the uninitiated - OS development project njm2 Project Ideas 3 Jan 31st, 2011 8:27 PM
Google's new OS 12mrsaturns Coder's Corner Lounge 11 Jul 10th, 2009 11:41 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:49 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC