[mythtv-users] PATCH: enable mythweb streaming via .asx
Dave Pearson
lists at netsalve.com
Tue Nov 7 20:05:12 UTC 2006
Rich West wrote:
> This is modeled slightly after the TivoWebPlus functionality (for the
> Tivo, obviously. :) ) where a small .asx file is generated and
> downloaded to the client. When that file is opened (usually
> automatically), the respective player (Windows Media Player, mplayer,
> totem, etc) reads the contents of the .asx file, and accesses the media
> directly (as defined in the .asx file, which, in this case, is the
> direct URL to the media file). The client then buffers and plays the
> media as it is being downloaded.
>
> The current handler.pl implementation did not allow for this
> functionality as it required the entire mpg to be downloaded to the
> client before the client would act upon it.
>
> I started writing it thinking that this was a Windows-only solution, but
> I quickly discovered that both totem (on FC5) and my mplayer on FC5
> understood the contents of the .asx file and did the right thing. :)
>
> -Rich
>
>
> --- /var/www/html/mythweb/modules/stream/handler.pl 2006-11-06
> 12:03:37.000000000 -0500
> +++ /var/www/html/mythweb/modules/stream/handler.pl.patch 2006-11-06
> 12:02:33.000000000 -0500
> @@ -7,6 +7,53 @@
> # @author $Author: xris $
> #
>
> +##
> +# Create the small .asx file based upon the information that we have for
> +# this particular piece of media. .ASX files are pretty simplistic and are
> +# truly made for this purpose.
> +#
> +# The benefit is that the client has the ability to view/play the
> downloaded
> +# content as it is being downloaded, rather than waiting until the
> completion
> +# of the entire download.
> +#
> +# While it was originally geared towards Windows, it was discovered that
> +# Linux clients understand .asx files and can act upon them in the same
> way.
> +##
> +sub generate_asx
> +{
> + my ($title, $subtitle, $filename) = @_;
> + my ($file) = "";
> +
> + $file = "<ASX version = \"3.0\">
> +<TITLE>$title</TITLE>
> + <ENTRY>
> + <TITLE>$title - $subtitle</TITLE>
> + <AUTHOR>MythTV - MythWeb</AUTHOR>
> + <COPYRIGHT>GPL</COPYRIGHT>
> + <REF HREF =
> +\"http://" . $ENV{'HTTP_HOST'} . "/mythweb/" . $filename . "\" />
> + </ENTRY>
> +</ASX>\n";
> + return ($file)
> +}
> +
> +##
> +# Here we simply send the small asx file to the client and exit quietly.
> +##
> +sub send_asx
> +{
> + my ($title, $subtitle, $filename) = @_;
> + my ($file) = &generate_asx($title, $subtitle, $filename);
> + print header(-type => 'text/html',
> + -Content_length => length($file),
> + -Content_disposition => " attachment;
> filename=\"$title.asx\"",
> + );
> + print $file;
> + exit;
> +}
> +
> +
> +
> # Necessary constants for sysopen
> use Fcntl;
>
> @@ -45,6 +92,12 @@
> exit;
> }
>
> +&send_asx($title, $subtitle, $filename);
> +
> +#-#-#-##-#-#-##-#-#-##-#-#-##-#-#-##-#-#-##-#-#-##-#-#-##-#-#-##-#-#-#
> +#-#-#-## We don't utilize any of the code past this point. ##-#-#-#
> +#-#-#-##-#-#-##-#-#-##-#-#-##-#-#-##-#-#-##-#-#-##-#-#-##-#-#-##-#-#-#
> +
> # File size
> my $size = -s $filename;
>
>
> _______________________________________________
> mythtv-users mailing list
> mythtv-users at mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>
Rich,
I've applied your patch and I've obviously introduced an error somewhere
because the downloaded file has a .htm extension added after the .asx!
Do you have any idea what I have done to break it? Incidentally, if I
save the file and remove the .htm extension, the program plays in
Windows Media Player correctly.
Regards,
Dave.
More information about the mythtv-users
mailing list