Correct Embedded Video Code - ASF / ASX / WMV / MOV / etc.


Joined: 2004-02-16
Posts: 23
Posted: Wed, 2005-10-05 16:32


I need Gallery to fully support actual streaming video.
By this I mean allowing properly formatted (ASF/ASX/WMV/MOV/etc.) and properly taggged/hinted/etc. video to be properly
embedded in the Gallery pages where
the client media player will automatically start
playing the video file as a streaming media file
instead of just embedding the video file inside of the
webpage and causing the client to download the entire
video in the background before playing.

Proper media types should be signaled with their
proper streaming format...RTP/RSTP, etc.

In the interm, if this is *not* scheduled for a fix/patch
sometime soon, is it possible to edit this information
yourself directly as or after you upload the video into the Gallery?

This is needed soon.



Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-10-05 17:00

that's too vague. and streaming works...
if you submitted a patch, i'd understand better the issue and you'd speed up the whole process.
if a patch, what about posting the HTML you'd expect to be served by G2?
or is it actually about the DownloadItem request?

there are two G2 requests involved here:
- ShowItem request, returns a HTML page with an embedded movie player. it has the proper mime types in html source etc.
- DownloadItem request, returns the movie file with proper mime type as http header etc.

see modules/core/classes/GalleryMovieItem.class function render, which is responsible for outputting the relevant ShowItem view request html


Joined: 2004-02-16
Posts: 23
Posted: Wed, 2005-10-05 17:30

Right, I appreciate your comment, let me re-comment my first post further...

Right now Gallery2 appears to use only generic "progressive downloading" regardless of the video file type. What is happening is that even when I have, for example, a ASF/WMV or MOV which is properly hinted for "streaming", G2 simply embeds it into the webpage as an embedded progressive download instead of outputting the proper HTML for an embedded streaming video. I have not tried Macromedia Flash Video or Real Video formats, but I am looking into using the streaming Flash Video format in the very near future. What I need is true proper streaming video support.

The HTML code that I am asking for can be found at:

Have I more clearly explained what the problem is and what is needed? If this is not currently possible, is there a place to manually add the HTML code which is needed to properly tell the client to stream the video instead of progressively download it? It would be convenient to be able to add/edit the appropriate HTML (if this is not currently able to be done in G2) while the admin is uploading the video to the Gallery or when the video is already in the Gallery.

I will look into the GalleryMovieItem.class function renderer as well to see if I can figure out a solution.


Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-10-05 22:13 seems to be a fine page.

i'm a little lazy, that to say, i have tons of other stuff to do.
could you please tell me what's the difference between the HTML generated by for embedding videos and the html we have?

and do you actually use the g2 ffmpeg module?
and btw: GalleryMovieItem.class is certainly the right place to edit stuff.


Joined: 2004-02-16
Posts: 23
Posted: Wed, 2005-11-23 08:31

I have been revisiting this problem and I am not sure how to proceed. I have a project which requires using an MMS stream served from another webhost to be embedded and presented in Gallery 2. The MMS stream can be played directly as an MMS stream or embedded within an ASX file. Gallery 2 does not appear to support ASX files or the direct linking/embedding of MMS streams.

What would be the proper way to get Gallery 2 to support ASX files?


Joined: 2004-02-16
Posts: 23
Posted: Wed, 2005-11-23 08:56

To add to my comment above, here is exactly what I am talking about (for example):


2) [url=mms:// rim2005/rim2005day2race2.wmv?media=1953418&package=1845933&event=0.mpg]mms:// rim2005/rim2005day2race2.wmv?media=1953418&package=1845933&event=0.mpg[/url]

3) ASX File (expanded below for explanation purposes)

<asx version="3">
<title>Paladin Rally - 2005 Rim of the World Rally - Day 2 Stage 2</title>
<entry><ref href="mms:// rim2005/rim2005day2race2.wmv?media=1953418&package=1845933&event=0.mpg"/>

Now, how do you get ANY of those same three links/files to embed properly within Gallery 2? That is what I have been trying to explain and fix/implement. Thanks.


Joined: 2004-02-16
Posts: 23
Posted: Wed, 2005-11-23 08:59

This is how the ASX should be properly handled (using the website link I posted above):

<!-- begin embedded WindowsMedia file... -->
<table border='0' cellpadding='0' align="center">
<OBJECT id='mediaPlayer' width="320" height="285"
standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>
<param name='fileName' value="">
<param name='animationatStart' value='true'>
<param name='transparentatStart' value='true'>
<param name='autoStart' value="true">
<param name='showControls' value="true">
<param name='loop' value="false">
<EMBED type='application/x-mplayer2'
id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1'
bgcolor='darkblue' showcontrols="true" showtracker='-1'
showdisplay='0' showstatusbar='-1' videoborder3d='-1' width="320" height="285"
src="" autostart="true" designtimesp='5311' loop="false">
<!-- ...end embedded WindowsMedia file -->
<!-- begin link to launch external media player... -->
<tr><td align='center'>
<a href="" style='font-size: 85%;' target='_blank'>Launch in external player</a>
<!-- ...end link to launch external media player... -->


Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-11-23 13:21
 <object classid="CLSID:05589FA1-C356-11CE-BF01-00AA0055595A"
			 width="320" height="290" id="IFid1" class="ImageFrame_none">
			   <param name="ShowDisplay" value="0"/>
			   <param name="ShowControls" value="1"/>
			   <param name="AutoStart" value="1"/>
			   <param name="AutoRewind" value="-1"/>
			   <param name="Volume" value="0"/>
			   <param name="FileName" value=""/>
			   <embed src="" width="320" height="290" type="video/x-ms-wmv"
				  controller="true" autoplay="true" loop="false"/>
			   <noembed><a href="">	      Download movie	    </a></noembed>

that's what we're already using.
it does autostart.

please browse to and check if it works for you. also check it in multiple browsers and on multiple computers, if it doesn't work.

if you think the above HTML is not what is needed, please file a bug or RFE on and specify exactly what change is needed.


Joined: 2004-02-16
Posts: 23
Posted: Wed, 2005-11-23 19:12


Thanks. Do I need to add this code to GalleryMovieItem.class? I checked out your website and saw that the funny_cats_1.wmv file does stream like it is supposed to. I also noticed that this file is a self-contained WMV file and located on your local server (not streamed from a seperate media server). I need to be able to stream video from another outside server (a media server hosting service for client) in Gallery 2, which is ONLY available to me in the three formats I gave above. And there is no place in Gallery 2 to enter an HTTP, MMS, or ASX file which will work. If there is, how do you do it? The ASX file simply gives a download link instead of any embedded video and the HTTP and MMS links are not possible to enter.

If I change your code above to ASX instead of WMV, will this work for what I need?



Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-11-23 23:48

this fuuny cats thing is a normal G2 page on a stock G2 install on my ISPs server. the above HTNL was generated by a stock G2 installed with ffmpeg support.

so what exactly would be needed for you?
you want to add an "ASX item" to g2 instead of a actual movie file. correct?
you could create a module to handle asx files... or tell us how to improve the movieitem class. or maybe we need to add a streamingmediaitem.


Joined: 2004-02-16
Posts: 23
Posted: Wed, 2005-11-30 20:28

I have been looking at this problem and I need some more information on how Gallery2 works.

Here is what I have tried so far...

In the file GalleryMovieItem.class starting on Line 117 I added 'video/x-ms-asx',

* @see GalleryDataItem::canBeViewedInline()
function canBeViewedInline() {
$mimeType = $this->getMimeType();
/* The mimeTypes listed here should provide a render() output */
$canBeViewedInline = array(
return ($this->getWidth() != 0 && $this->getHeight() != 0
&& in_array($mimeType, $canBeViewedInline));

on Line 276 I added case 'video/x-ms-asx':

case 'video/mpeg':
case 'video/x-msvideo':
case 'video/x-ms-wmv':
case 'video/x-ms-asx':

I also added the video/x-ms-asx MIME Type to the Gallery Admin MIME Types module.

The following ASX file was created:

<asx version="3">
<title>Paladin Rally - 2005 Rim of the World Rally - Day 2 Stage 2</title>
<ref href="mms:// rim2005/rim2005day2race2.wmv?media=1953418&package=1845933&event=0.mpg"/>

In all cases Gallery2 puts a link in the Gallery labeled "Download unknown". What class file lists which file types Gallery2 will recognize? What file will allow Gallery2 to simply load up the ASX file like a normal embedded video? The GalleryMovieItem.class embedding code looks correct, as was discussed, but Gallery2 does not recognize the ASX file as being an embeddable format. I do not care if Gallery2 needs me to enter the video dimensions manually, since the ASX file is not directly renderable, but Gallery2 does not even recognize it as a known file type at all.


Joined: 2004-02-16
Posts: 23
Posted: Wed, 2005-11-30 21:46

I am also looking in GalleryUnknownItem.class and GalleryDataItem.class, but I do not currently know enough about the internal structure of Gallery2 to edit these files. I see that there is a method to determine whether a file is viewable inline (photo/video) or not (text/DOC/XLS), but I do not see where to edit that method directly to ASX files (which are text) to the items which can be viewed inline. Or even how to add ASX files so that Gallery2 does not mark them as Unknown.



Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-12-01 00:04

modules/core/ search for MovieItem
only the listed mimetypes there are recognized as movies.
if you change this list, you'll have to reinstall g2.

of course you could manipulate the entry in db table g2_FactoryMap manually.
or write a module to manage these mimetypes.

maybe add this functionality to the mimetype module. that would be cool! DO IT! :)


Joined: 2003-09-29
Posts: 31
Posted: Wed, 2006-05-17 21:39

Any news on this topic? Would be interested in embedding real videos in my gallery too...

mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2006-08-01 19:00

When I was working on flash video I put in some changes regarding asf/asx. I don't actually know if it will help with what you're trying to do, but it would help if someone interested in this functionality can get current svn or nightly snapshot and reevaluate what is missing in G2 for this (or maybe it will work, who knows :) )'s picture

Joined: 2004-12-05
Posts: 14
Posted: Sat, 2007-01-06 21:49

I try Flash Video with Gallery RC1 en external url :

The first item is a local flv file and it's working very fine localy (upload brandwith is very slow)
The second item is a external file (url: the brandwith is very good but don't work : I don't have a embedded video.
The third item : a simple picture (external file). When I click on it, I receive the picture in a new window.

My question : why it'snt working properly with external file ?


Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2007-01-06 22:49


when you use "links" (add item -> link"), then all it does is showing a link in your gallery to that URL. it doesn't use gallery's flash features etc.


Joined: 2007-06-11
Posts: 190
Posted: Wed, 2007-06-13 05:50

I just uploaded a new module today that I created called "Embed Videos". I believe it could be used to properly embed the file types you describe above. Take a look at my post and let me know what you think: