Integrated audio player

morten

Joined: 2005-03-28
Posts: 5
Posted: Sat, 2005-04-02 22:36

I would like to have audiofiles play inline, but which files should I alter to register an "audio" class, that could handle audio-mimetypes and create a player much like the video-handler ?

I'm quite familiar with PHP programming, but I just need to know where to start this project.

Looking forward to your help :-)

/Morten

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sun, 2005-04-03 03:41

1) figure out what the html should look like, ie how do you show an audio file so the browser will show the player inline?
2) create a new module that registers a factory implementation of GalleryItem called GalleryAudioItem. this class will have a render() function to generate the html from step 1.

model your code around GalleryMovieItem which is part of core module.. you new module will register GalleryAudioItem with the mime types it supports.. then whenever a file is added to G2 with one of those mime types it will be saved using your entity instead of GalleryUnknownItem. and when that item is loaded for display it will call your render() function.

i can give more detail if needed but this should give you some ideas...

 
morten

Joined: 2005-03-28
Posts: 5
Posted: Sat, 2005-04-09 17:08

I have now experienced a little creating a GalleryAudioItem class and registred it in CoreModuleExtras

But it still shows up as an unknown item with just a "Download this audio" link.

Do I need to register it somewhere else or is there any more modules I should consider ??

/Morten

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sat, 2005-04-09 19:59

it won't change the behavior for any audio files you've already added.. they are already in the db as GalleryUnknownItems.. but if you registered your GalleryAudioItem with the appropriate mime types and G2 can recognize those mime types based on file extension (Site Admin / Mime Types after activating mime module, in current G2 nightly/cvs) then newly added audio items should use your class.

 
steveparks

Joined: 2005-08-29
Posts: 25
Posted: Mon, 2005-08-29 16:10

Hi

I've been following these comments and have tried to put some of the suggestions into action, unfortunately i'm not having any luck.

I'm a complete newb to gallery, so I've probably done something daft, or just don't understand the architecture.

Here's what I've done:

1. Made of a copy of GalleryMovieItem.class and renamed it GalleryAudioItem.class.

2. Edited that to name itself correctly, select the right MIME types etc, and embed a Windows Media player to playback WMA files (I'm just testing with wma, will add mp3 and realaudio playback once i have that working.)An edited version of the file is attached in the zip file.

3. Edited CoreModuleExtras.inc to include this line near the bottom of the file:
$regs[] = array('GalleryEntity', 'GalleryAudioItem', 'class', array('audio/mpeg', 'audio/x-ms-wma', 'audio/x-pn-realaudio'));
An edited version of that file is attached in the zip file too.

Then I uploaded the files, refreshed my browser, and uploaded a new wma file.

But sadly it doesn't work. I've tried all sorts of little tweaks without success, so I'm hoping that someone more experienced with Gallery can help me out.

This was using the latest nightly build, with the MIME types editor module, on a RHEL3 with MySQL4, PHP4 and running under Plesk.

Thanks very much for any help

Steve

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-08-29 17:56

i'd have to check a few g2 files for what all is needed to make it work. but from what i see you just edited the core module.
there are more actions needed to make it work.
- you'd have to reinstall your g2 such that it runs the install core module code again and registers the audio item stuff in the database
- you'd probably have to change a few more things in your GalleryAudioItem.class and then you'd have to run gmake in your modules/core/classes/ directory such that it generates the g2_AudioItem database table creation files, which will get executed when running the g2 installer.

 
steveparks

Joined: 2005-08-29
Posts: 25
Posted: Mon, 2005-08-29 23:22

Thanks
That all seems to make sense.

As I'm new to gallery, and still learning as I go, would you mind just spelling out to me what further changes I would need to make to the GalleryAudioItem.class before I run gmake, and then is there a particular way to run gmake?

Thanks very much for your help
Steve

 
steveparks

Joined: 2005-08-29
Posts: 25
Posted: Thu, 2005-09-01 00:16

Hi

I've been studying the developer documentation to help me understand G2, and I'm coming to the conclusion that it would be best if I developed an audio module, rather than trying to adapt the core files.

Here's what I propose. Could a more experienced developer tell me if this is possible before I spend most of my life for the next few weeks trying to figure out how to do it please! And any helpful pointers, sample code from other modules, or suggestions would be very very welcome. G2 seems incredibly powerful and well designed - but a little daunting to a newbie used to basic hacking around in standard php/smarty code without your clever system of map files etc.

Anyway, here's the plan for what my module will do:
1. register with the core module to take control of the audio MIME types and any Audio Items.
2. On upload of wma and rm files, it will create a wax or ram meta-file in the same way that thumbnails are created and stored for photos. These will be created from an admin definable template.
3. provide instances of inline media players for the relevant audio MIME type in the photo display page.
4. Add display of two URLs (for users with sufficient permissions) to allow users to copy and paste a link to stream the audio file by linking to the meta-file, or a link to actually download the file itself. Like the GetURL mod for photos.

Now I have a feeling this is quite ambitious and that I might fall flat on my face pretty quickly, but I'm going to have a go, and learn about G2 in the process!

But I really would appreciate a few pointers to get me going! :)

Thanks very much
steve

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-09-01 15:35

sure it's possible, once you finished your core module changes i'd have suggested to move it into an independent audioitems module.

Quote:
1. register with the core module to take control of the audio MIME types and any Audio Items.

yep, perfectly possible and easy.

Quote:
2. On upload of wma and rm files, it will create a wax or ram meta-file in the same way that thumbnails are created and stored for photos. These will be created from an admin definable template.

yes, you can add an "item add option" which generates the wax or ram meta-files.
the question is, do you need an external binary, like netpbm for images, to generate these wax/rm files?
and what's the exact purpose of these files? low quality versions of the audio items?
not sure yet if this audio stuff would also register a toolkit (similar to netpbm, ffmpeg, ...) and toolkit actions.

Quote:
3. provide instances of inline media players for the relevant audio MIME type in the photo display page.

sure, that's analogous to showing movies inline

Quote:
4. Add display of two URLs (for users with sufficient permissions) to allow users to copy and paste a link to stream the audio file by linking to the meta-file, or a link to actually download the file itself. Like the GetURL mod for photos.

you can either try to put your embedded audio player and download link similar to the movie item in the photo.tpl template or create a whole new theme that resembles more the features and specialities of a audio album, than a photo album.

 
steveparks

Joined: 2005-08-29
Posts: 25
Posted: Thu, 2005-09-01 20:40

Thanks Valiant

I think I have 1 and 4 nearly figured out. Though I will probably have some more questions when i get deeper into it!

For number 2, wax and ram meta files are simply plain text files, in XML markup. When a media player loads one of these meta files it knows to stream the filenames within the list - in this case that will be just one file.

Here is a full featured .wax file:

<ASX version="3.0" BANNERBAR="FIXED">
<TITLE>Programme Title</TITLE>
<COPYRIGHT>Copyright (c) 2005 Owner</COPYRIGHT>
<LOGO HREF="http://website.com/logo.gif" Style="MARK" />
<LOGO HREF="http://website.com/icon.gif" Style="ICON" />
<!--Don't change any of this section.-->
<ABSTRACT>Hello world</ABSTRACT>
<MOREINFO HREF="http://website.com/info.htm" />
<BANNER HREF="http://website.com/banner.gif">
<MOREINFO HREF="http://website.com/bannerinfo.htm" />
<ABSTRACT>Click here to visit our website</ABSTRACT>
</BANNER>
<COPYRIGHT>Copyright (c)2005 owner</COPYRIGHT>
<ENTRY>
<TITLE>Track name</TITLE>
<REF HREF="track.wma" />
<MOREINFO HREF="http://website.com/info" />
<LOGO HREF="http://website.com/icon.gif" Style="ICON" />
<COPYRIGHT>(c)2005 owner</COPYRIGHT>
<PARAM NAME="Programme" VALUE="programme name" />
<PARAM NAME="Publisher" VALUE="publisher name" />
<PARAM NAME="PREBUFFER" VALUE="TRUE" />
</ENTRY>
</ASX>

But it could be as simple as:

<ASX version="3.0" BANNERBAR="FIXED">
<ENTRY>
<REF HREF="track.wma" />
</ENTRY>
</ASX>

So it should be easy to create a template that's editible by the admin, and have gallery take this template and put the file path and name in.

Would this file then be stored in the database or in the filesystem? What does gallery currently do with thumbnails?

I would want it so that the audio could be streamed from external websites by copying and pasting a URL to the meta file provided by gallery, into posts to the other website.

Thanks very much for taking the time to help me get started.

Steve

 
rubo77

Joined: 2005-09-17
Posts: 2
Posted: Sat, 2005-09-17 21:48

could you add a zip file with all the needed changes for G2 ?

i would like to add it to my gallery but i already use the new gallery 2

_________________________________________________________________________________
multiplayer online space game: www.spacetrace.org

 
rubo77

Joined: 2005-09-17
Posts: 2
Posted: Sun, 2005-09-18 10:06

there is a suggestion, that would be nice, here:
http://sourceforge.net/tracker/index.php?func=detail&aid=577892&group_id=7130&atid=357130

if you want it, you should vote for it here:
http://gallery.menalto.com/sfvote/50
(it goes up or down with the votes, so search for the topic nr 577892)

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-09-18 13:56

@voting:
on the "my votes" page, you can click on vote, and then enter the id of the feature request. this way, you don't have to search your RFE in the long list.