Results 1 to 5 of 5

Thread: How to play mp3 files on my mobile website

  1. #1
    Senior Member ChinaMobi's Avatar
    Join Date
    May 2010
    Posts
    1,593

    Default How to play mp3 files on my mobile website

    I have a mobile website which includes some mp3 files. In my web pages, I include the following JS code.

    <script type="text/javascript" src="http://static.delicious.com/js/playtagger.js"></script>

    The code allows users surfing the page to play an mp3 file embedded as follows:

    Play <a href="../audio/rogers-boomers.mp3"></a>

    This works fine when browsing from my PC. However, I hear no sound when viewing the same page from my Android phone.

    Suggestion please.

  2. #2
    Senior Member andymoore's Avatar
    Join Date
    Aug 2008
    Posts
    1,612

    Default

    One word: flash

    That's why it's not playing on a mobile as the JS is calling a SWF to play the mp3.
    Andy Moore
    i don't do tech / mobi anymore - why do something that annoys and stresses lol

    New: Most Minty Tooth Oil - GMO and fluoride free toothpaste alternative

    100% natural botanical extracts to whiten teeth, freshen breath and strengthen gums
    Used, recommended and sold by Harley Street private dentists

    My other websites:

    http://sellyoursongs.info/ - Sell Your Songs using Mobile Payments
    http://detectmobilebrowsers.mobi/ - Detect Mobile Browsers
    http://andymoore.info/m-commerce-php/ - M-Commerce PHP (sell stuff on the mobile web)
    http://locationdetection.mobi/ - Detect a mobile browser's latitude & longitude
    http://andymoore.info/mysql-lyrics-database/ - Half a million lyrics


  3. #3
    Senior Member ChinaMobi's Avatar
    Join Date
    May 2010
    Posts
    1,593

    Default

    Are you saying I'm using Flash? I don't see it. Also, iPhone does not like Flash.

  4. #4
    Senior Member andymoore's Avatar
    Join Date
    Aug 2008
    Posts
    1,612

    Default

    Yes, you're using flash as JavaScript alone doesn't have the ability to play media files like that.

    if(typeof(Delicious) == 'undefined') Delicious = {}
    Delicious.Mp3 = {
    playimg: null,
    player: null,
    go: function() {
    var all = document.getElementsByTagName('a')
    for (var i = 0, o; o = all[i]; i++) {
    if(o.href.match(/\.mp3$/i)) {
    var img = document.createElement('img')
    img.src = 'http://static.delicious.com/img/play.gif'; img.title = 'listen'
    img.height = img.width = 12
    img.style.border = 'none'
    img.style.marginRight = '4px'
    img.style.cursor = 'pointer'
    img.onclick = Delicious.Mp3.makeToggle(img, o.href)
    o.parentNode.insertBefore(img, o)
    }}},
    toggle: function(img, url) {
    if (Delicious.Mp3.playimg == img) Delicious.Mp3.destroy()
    else {
    if (Delicious.Mp3.playimg) Delicious.Mp3.destroy()
    var a = img.nextSibling, c=''
    if (document.defaultView && document.defaultView.getComputedStyle) c = document.defaultView.getComputedStyle(a,null).getP ropertyValue('color')
    else if (a.currentStyle) c = a.currentStyle['color']
    c = c.replace(/^rgb|[ ()]/g, '')
    var hex = c.match(/^#?([a-f0-9]{6})$/), hexSm = c.match(/^#?([a-f0-9]{3})$/), rgb = c.match(/^([0-9]+),([0-9]+),([0-9]+)$/)
    if (rgb) { var c16 = "0123456789abcdef", c=''; for(var i=1,d;d=rgb[i];i++) { var j=d%16; c=c+c16.charAt((d-j)/16)+c16.charAt(j) } }
    else if (hex) c = hex[1]
    else if (hexSm) c = hexSm[1].charAt(0) + hexSm[1].charAt(0) + hexSm[1].charAt(1) + hexSm[1].charAt(1) + hexSm[1].charAt(2) + hexSm[1].charAt(2)
    else c = "000000"
    img.src = 'http://static.delicious.com/img/stop.gif'; Delicious.Mp3.playimg = img;
    Delicious.Mp3.player = document.createElement('span')
    Delicious.Mp3.player.innerHTML = '<object style="vertical-align:bottom;margin-right:0.2em" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' +
    'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"' +
    'width="100" height="14" id="player" align="middle">' +
    '<param name="wmode" value="transparent" />' +
    '<param name="allowScriptAccess" value="sameDomain" />' +
    '<param name="flashVars" value="theLink='+url+'&amp;fontColor='+c+'" />' +
    '<param name="movie" value="http://static.delicious.com/swf/playtagger.swf" /><param name="quality" value="high" />' +
    '<embed style="vertical-align:bottom;margin-right:0.2em" src="http://static.delicious.com/swf/playtagger.swf" flashVars="theLink='+url+'&amp;fontColor='+c+'"'+
    'quality="high" wmode="transparent" width="100" height="14" name="player"' +
    'align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"' +
    ' pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>'
    img.parentNode.insertBefore(Delicious.Mp3.player, img.nextSibling)
    }},
    destroy: function() {
    Delicious.Mp3.playimg.src = 'http://static.delicious.com/img/play.gif'; Delicious.Mp3.playimg = null
    Delicious.Mp3.player.removeChild(Delicious.Mp3.pla yer.firstChild); Delicious.Mp3.player.parentNode.removeChild(Delici ous.Mp3.player); Delicious.Mp3.player = null
    },
    makeToggle: function(img, url) { return function(){ Delicious.Mp3.toggle(img, url) }}
    }

    Delicious.addLoadEvent = function(f) { var old = window.onload
    if (typeof old != 'function') window.onload = f
    else { window.onload = function() { old(); f() }}
    }

    Delicious.addLoadEvent(Delicious.Mp3.go)
    As you'll see that's calling a flash object to play the audio.
    Andy Moore
    i don't do tech / mobi anymore - why do something that annoys and stresses lol

    New: Most Minty Tooth Oil - GMO and fluoride free toothpaste alternative

    100% natural botanical extracts to whiten teeth, freshen breath and strengthen gums
    Used, recommended and sold by Harley Street private dentists

    My other websites:

    http://sellyoursongs.info/ - Sell Your Songs using Mobile Payments
    http://detectmobilebrowsers.mobi/ - Detect Mobile Browsers
    http://andymoore.info/m-commerce-php/ - M-Commerce PHP (sell stuff on the mobile web)
    http://locationdetection.mobi/ - Detect a mobile browser's latitude & longitude
    http://andymoore.info/mysql-lyrics-database/ - Half a million lyrics


  5. #5
    Senior Member ChinaMobi's Avatar
    Join Date
    May 2010
    Posts
    1,593

    Default

    Quote Originally Posted by andymoore View Post
    As you'll see that's calling a flash object to play the audio.
    Ah, I see. So how can I solve my problem? How can the code handle access from mobile phones with no Flash player?

Similar Threads

  1. Google Webmaster Tools for X Files
    By freeflow in forum News & Discussion
    Replies: 0
    Last Post: 12-03-2010, 11:12 PM
  2. New User Agentin in my log files?
    By freeflow in forum News & Discussion
    Replies: 0
    Last Post: 04-16-2010, 11:09 PM
  3. What are .l files in Xcode?
    By Scavenger in forum iPhone App Development
    Replies: 0
    Last Post: 03-02-2010, 06:08 PM
  4. mrp files
    By narmer93 in forum .mobi Newbies
    Replies: 3
    Last Post: 01-12-2010, 01:21 PM
  5. Azteca Mobile files Chapter 7 bankruptcy - Bizjournals.com
    By Scavenger in forum Mobile Industry News
    Replies: 0
    Last Post: 03-05-2009, 03:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
A Yup.mobi Mobile Site
Barcelona Walking Tours
Mobile Dating