Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Sep 21, 2019 3:52 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Simple mp3 player for Web Edition
PostPosted: Wed Aug 31, 2011 11:15 pm 
Offline
User avatar

Joined: Fri Jan 12, 2007 10:59 am
Posts: 136
Location: Victoriaville, QC, Canada
I've been searching for an easy way to put an mp3 player in my web edition project. I wanted something light that didn't use flash and that was reasonably compatible with browsers. I put one together that's based on javascript and that is really easy to add to any project.

So here it is.

BrunoWebPlayer is basically a WebContainer subclass that you can place in any WebPage.

It has 3 methods:
MediaPlayLocalFile ( TheFile as FolderItem ) : play an mp3 file stored locally on the server
MediaPlayURL ( TheURL as string ) : play an mp3 file stored elsewhere
MediaClear : clear the player and show the default page

...and 1 property:
DefaultPage : the HTML page to display when no mp3 file is loaded. Defaults to a blank page.

It shows either a Quicktime player or Windows Media player (depending on browser) and loads it with the mp3 and the user can play, stop, change the volume, etc. using the standard controls show by QT/WMP. The player does not open a new page or popup. It just shows in the container that you placed on your page.

Example:
- place the container in a page. Name it "MyPlayer".
- To play an mp3 file named "Test.mp3" that's on the desktop on your server:
dim f as FolderItem
f = SpecialFolder.Desktop.child("Test.mp3")
MyPlayer.MediaPlayLocalFile f


- To play an mp3 located anywhere on the web
MyPlayer.MediaPlayURL "http://someaddress/file.mp3"


That's all there is to it. It just works (for me at least). Oh, and there's a note in the class with more info.
Here's the link to the zip file (I couldn't figure out how to attach it directly to the post).

http://webcargo.pjjproductions.com/BrunoWebPlayer.zip

I don't consider myself a Realbasic guru, but I decided to share it with everyone anyways. After getting so much help from this forum, I'm really happy if this can help someone! If you use it, let me know (I'm curious to see where this goes) and if you enhance it, I'd love to have a copy of your work to look and learn! But most important, if you find bugs or flaws or better ways of doing it, please let me know.

Enjoy!

Bruno

_________________
Bruno Fréchette
PJJ Productions inc.
RealStudio Web & Desktop on OSX


Top
 Profile  
Reply with quote  
 Post subject: Re: Simple mp3 player for Web Edition
PostPosted: Thu Sep 01, 2011 1:00 am 
Offline
User avatar

Joined: Tue Jan 04, 2011 3:02 am
Posts: 1236
Location: Jönköping, Sweden
hmm, can't really get it to play :/
I used some random free mp3 file that I found on the web with this code:

MyPlayer.MediaPlayURL "http://files.radio.com/downloads/time-based/ladytron-white-elephant.mp3"

in the WebPage1.Open but nothing happens.

Any idea? :-)

_________________
Image http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
Xojo Pro 2013r1


Top
 Profile  
Reply with quote  
 Post subject: Re: Simple mp3 player for Web Edition
PostPosted: Thu Sep 01, 2011 9:14 am 
Offline
User avatar

Joined: Fri Jan 12, 2007 10:59 am
Posts: 136
Location: Victoriaville, QC, Canada
Hmmm. I tried the URL by pasting it directly in a browser, and I get the following message:

Quote:
Referral Denied

You don't have permission to access "http://files.radio.com/downloads/time-based/ladytron-white-elephant.mp3" on this server.
Reference #24.d4ea7ce.1314883382.132c2f


I think the problem is that the link you tried cannot be accessed directly.

I tried with a few links and it works. Try it with this one for example:

http://jenniferavalon.net/music/doubleexposure_album/goodoldusa.mp3

The code doesn't check if the link is valid and doesn't return any error. It just tries to load the link and play it.

Let me know.


btw, I made a small correction on the object to avoid scroll bars to show. You might want to download it again!

_________________
Bruno Fréchette
PJJ Productions inc.
RealStudio Web & Desktop on OSX


Top
 Profile  
Reply with quote  
 Post subject: Re: Simple mp3 player for Web Edition
PostPosted: Thu Sep 01, 2011 12:09 pm 
Offline

Joined: Mon May 31, 2010 5:35 am
Posts: 2412
Location: Netherlands
Thanks for this tip, keep doing the right thing!

_________________
SWORT™
- Windows Vista, Windows XP, Windows 7, Linux Mint 11 and Mac OSX Lion
- REAL Studio Enterprise(latest) and WEB Edition(latest)
- Plugins (MBS Complete, ToringoLib, Einhugur, VanHoek + Some open source plugins)
For Dutch User Groups ask me to enter!


Top
 Profile  
Reply with quote  
 Post subject: Re: Simple mp3 player for Web Edition
PostPosted: Thu Sep 01, 2011 1:13 pm 
Offline
User avatar

Joined: Tue Jan 04, 2011 3:02 am
Posts: 1236
Location: Jönköping, Sweden
BrunoFrechette wrote:
Hmmm. I tried the URL by pasting it directly in a browser, and I get the following message:

Quote:
Referral Denied

You don't have permission to access "http://files.radio.com/downloads/time-based/ladytron-white-elephant.mp3" on this server.
Reference #24.d4ea7ce.1314883382.132c2f


I think the problem is that the link you tried cannot be accessed directly.

I tried with a few links and it works. Try it with this one for example:

http://jenniferavalon.net/music/doubleexposure_album/goodoldusa.mp3

The code doesn't check if the link is valid and doesn't return any error. It just tries to load the link and play it.

Let me know.


btw, I made a small correction on the object to avoid scroll bars to show. You might want to download it again!


Ohps, you're right. That's probably it :)
Great work!

_________________
Image http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
Xojo Pro 2013r1


Top
 Profile  
Reply with quote  
 Post subject: Re: Simple mp3 player for Web Edition
PostPosted: Tue Sep 06, 2011 2:27 pm 
Offline

Joined: Thu May 13, 2010 7:27 pm
Posts: 341
Add this method and it should play in all browsers. http://www.phon.ucl.ac.uk/home/mark/audio/play4.htm


Top
 Profile  
Reply with quote  
 Post subject: Re: Simple mp3 player for Web Edition
PostPosted: Tue Sep 06, 2011 6:22 pm 
Offline
User avatar

Joined: Fri Jan 12, 2007 10:59 am
Posts: 136
Location: Victoriaville, QC, Canada
Thanks Will, I'll look into it and update the method accordingly. I'll repost whenever it's available.

_________________
Bruno Fréchette
PJJ Productions inc.
RealStudio Web & Desktop on OSX


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group