0

I am developing an MVC mobile web where I return an audio file depending on the URL parameters.

I want to add a condition where I return mp3 files for smartphones, and return dm files for old mobile devices that cannot stream mp3 files

Is there a standard procedure that detects old devices or should I loop through all my options?

HelpASisterOut
  • 3,085
  • 16
  • 45
  • 89
  • can maybe look at http://detectmobilebrowsers.com/ and construct a list of all the old cellphones that can't stream mp3? – Jeandre Pentz Apr 10 '14 at 07:23
  • @JeandrePentz This seems like my last resort. Keeping in consideration that I can never have a definite full list of all the devices that can't read mp3 unless I test them all – HelpASisterOut Apr 10 '14 at 07:30
  • Yes I understand what you want, but I don't believe there is way of detecting if mobile supports mp3. – Jeandre Pentz Apr 10 '14 at 07:37
  • Have a look at this: http://stackoverflow.com/a/8469184/1581026 and http://stackoverflow.com/a/1514759/1581026 – Jeandre Pentz Apr 10 '14 at 07:40
  • @JeandrePentz Very useful thanks. This function is on HTML5 though and I'm working on the controller side – HelpASisterOut Apr 10 '14 at 07:55
  • 1
    you can maybe on your page loads execute that javascript and then save the value in a cookie so you can easily get the value server side. – Jeandre Pentz Apr 10 '14 at 08:32

2 Answers2

0

Check below two links if they are useful

http://www.dotnetglobe.com/2013/04/device-detection-in-aspnet-mvc-4.html
http://techbrij.com/display-mode-mobile-tablet-tv-aspnet-mvc

Update: get device

$.browser.device = (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));
Nilesh Gajare
  • 6,302
  • 3
  • 42
  • 73
  • I already went through these links and a lot of similar others, but they all talk about how to differ between mobile devices and PC/Mac. What I need is to detect devices that can't read mp3 – HelpASisterOut Apr 10 '14 at 07:28
0

Since there is an undefined list of devices that don't play mp3, The safest way to do this is to state the devices that do play mp3, and I'll leave the rest to the Else Clause.

 If userAgent.Contains("iphone;") Or 
    userAgent.Contains("ipad;") Or 
    userAgent.Contains("symbianos;") Or
    userAgent.Contains("ipod;") Or 
    userAgent.Contains("android;") Or 
    userAgent.Contains("blackberry;") Or
    userAgent.Contains("samsung;") Or 
    userAgent.Contains("nokia;") Or 
    userAgent.Contains("sonyericsson;") Or
    userAgent.Contains("symbian;") Then
            Device = Modes.SmartPhone
 Else
            Device = Modes.OtherPhone
 End If
HelpASisterOut
  • 3,085
  • 16
  • 45
  • 89