SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I Have MP3's Stored in DB as blob. How can I stream them?

    Is there a way to use say XML to stream mp3's from a blob field? I've tried other ways but it doesn't seam to work. I can get them to download from blob but not stream. Does anyone have any suggestions?

    Elfmuse

  2. #2
    SitePoint Guru kish's Avatar
    Join Date
    Jun 2003
    Location
    UK
    Posts
    923
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Flash!
    make a flash mp3 player and pass the mp3 blob data to it. You can set the mp3 to stream in the actionscript.
    Fast Fwd Multimedia
    Web, IT & Cloud Computing Consultancy
    Currently looking for web freelancers. Get in touch!

  3. #3
    SHIZA
    Join Date
    Apr 2003
    Location
    Great White North
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Like Kish said flash would be your best bet since it's low resource overhead.Iam almost certain xml can't stream anything at all without using windoze mediaplayer.All though flash makes an annoying clicking sound on some comps it's still the better way to stream it.
    Pixel Engineer

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well that's the thing I've tried using the flash and it doesn't seem to work that way. You can use a database to point to the file in a file folder to stream it but it won't stream directly out of the database. I was wondering if you could use xml to grab the mp3 from the blob then send it too the flash player? I don't know a thing about xml but was trying to hunt for this solution since I want to keep the files stored safe.
    Any other suggestions?

  5. #5
    SitePoint Guru kish's Avatar
    Join Date
    Jun 2003
    Location
    UK
    Posts
    923
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Elfmuse
    . You can use a database to point to the file in a file folder to stream it
    hmm, i have done that too in the past and its very simple. have never tried it with blobs though. just out of interest, why are you storing the mp3s as blobs... sound like its more trouble than its worth.
    still i'd be interested to know a simple method for feeding the mp3 blob to a swf mp3 player...
    Fast Fwd Multimedia
    Web, IT & Cloud Computing Consultancy
    Currently looking for web freelancers. Get in touch!

  6. #6
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With the help of a PHP programmer I found here I have created a site for independent musicians to sell their mp3's. The PHP guy talked me into storing them as blobs for the best security. The only problem is that in doing so steaming was lost. So I have to make artists upload an additional sample for stream. Now a couple months later I'm regretting giving into it and I am dreading converting the blobs over to a folder for storing the mp3's. And I agree there most be a simple method for feeding the blobs to the player but how?LOL.

  7. #7
    SitePoint Guru kish's Avatar
    Join Date
    Jun 2003
    Location
    UK
    Posts
    923
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok elfmuse, have a solution for you.
    I was chatting about it with a programmer friend of mine and here's what we came up with...

    You already know that you can't stream the blob becaue the query to the DB will deliver the file data en masse which is no good for streaming because that only requires a bit of data at a time.

    So what you need is this: 2 PHP scripts and one flash mp3 player with some well thought out actionscript.
    When the user clicks "play" on the flash mp3 player, the actionscript should call the first PHP script which will create a temporary file from the blob data. The player can stream from that temp file. When the track finishes or the user clicks "stop", the actionscript will call the second PHP script which will delete the temp file.

    Problem's will arise when a user closes the browser window or navigates away from the page before the track finishes or without clicking "stop" because the 2nd PHP script won't have been called on to delete the temp file. So you'll end up with a whole load of redundant temp files.
    I guess you may be able to use some Javascript to call the PHP script when the user navigates away from the page or closes the window but that's likely to be very problematic.
    The other option (if its a windows server) is to use the Task Scheduler to routinely delete old temp files. However you'll need ur own server or a friendly host to sort this out for you. If you're using a linux box then there are similar schedulers available.

    If you can do all this then it could be a pretty good way, however i think it'd be easier to just use actual mp3 files rather than blobs. I reckon it'll greatly save server resources and also save you a lot of headache.

    good luck; let us know what you decide and how it goes!
    Fast Fwd Multimedia
    Web, IT & Cloud Computing Consultancy
    Currently looking for web freelancers. Get in touch!

  8. #8
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Simple sollution, write the blobs out to files, storing data like that in a DB is such a waste of resources it's unreal. I remember when SPF stopped storing Avatars in the vBulletin DB, the server was good for another 50 or 60 online users at a time after that.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  9. #9
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I'm gonna write the blobs out to files, in which case their is only about 160 which isn't too bad in my opinion.
    Bottom line you should always do what your gut tells you.lol
    I'll let you all know how everything is when I finally get done.

    Thanks
    Elfmuse

  10. #10
    SitePoint Guru kish's Avatar
    Join Date
    Jun 2003
    Location
    UK
    Posts
    923
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    aww you mean i typed all that for nuthin?!
    j/k
    Fast Fwd Multimedia
    Web, IT & Cloud Computing Consultancy
    Currently looking for web freelancers. Get in touch!

  11. #11
    SitePoint Addict
    Join Date
    Aug 2002
    Location
    Ottawa, Ontario, Canada
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Elfmuse
    The PHP guy talked me into storing them as blobs for the best security.
    You should be able to make it fairly secure in the sense of preventing people from directly DLing the files... either move them out from under the webroot path, or store them in a directory starting with a period (assuming a unix host) ".daStuff" and use .htaccess to ensure no requests can be made to it. Etc, etc, there are a bunch of ways....

    Cheers,
    Keith.


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
  •