Skip to content

Commit

Permalink
Control audio element sequence in web player
Browse files Browse the repository at this point in the history
This encourages browsers to use superior codecs (rather than mp3)

fixes #161
  • Loading branch information
eteubert committed Jul 27, 2013
1 parent 851abbe commit e5cb181
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
32 changes: 28 additions & 4 deletions lib/modules/podlove_web_player/printer.php
Expand Up @@ -64,13 +64,37 @@ public function render() {
);
}

// get all relevant info about media files
$media_files = array();
foreach ( $this->files as $file ) {
$mime = $file->episode_asset()->file_type()->mime_type;
$media_files[ $mime ] = array(
'file' => $file,
'mime_type' => $mime,
'url' => $file->get_file_url()
);
}

// sort files bases on mime type so preferred get output first
$sorted_files = array();
$preferred_order = array( 'audio/mp4', 'audio/aac', 'audio/opus', 'audio/ogg', 'audio/vorbis' );
foreach ( $preferred_order as $order_key ) {
if ( $media_files[ $order_key ] ) {
$sorted_files[] = $media_files[ $order_key ];
unset($media_files[ $order_key ]);
}
}
foreach ( $media_files as $file ) {
$sorted_files[] = $file;
}

// add all sources
$flash_fallback_func = function( &$xml ) {};
foreach ( $this->files as $file ) {
$mime_type = $file->episode_asset()->file_type()->mime_type;
foreach ( $sorted_files as $file ) {
$mime_type = $file['mime_type'];

$source = $xml->addChild('source');
$source->addAttribute( 'src', $file->get_file_url() );
$source->addAttribute( 'src', $file['url'] );
$source->addAttribute( 'type', $mime_type );

if ( $mime_type == 'audio/mpeg' ) {
Expand All @@ -81,7 +105,7 @@ public function render() {

$params = array(
array( 'name' => 'movie', 'value' => 'flashmediaelement.swf' ),
array( 'name' => 'flashvars', 'value' => 'controls=true&file=' . $file->get_file_url() )
array( 'name' => 'flashvars', 'value' => 'controls=true&file=' . $file['url'] )
);

foreach ( $params as $param ) {
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Expand Up @@ -80,6 +80,7 @@ Find the setting Flattr > Advanced Settings > Flattrable content > Post Types an
= 1.7.4 (2013-07-26) =
* Auphonic Module Update. You are now able to manage productions directly from within the Publisher without visiting Auphonic at all. As always, any feedback is more than welcome.
* App.net Module Update. Support for Patter, language annotations and delayed posting.
* Enhancement: Control sequence in which audio elements are printed in the web player. This encourages browsers to use superior codecs (rather than mp3).

= 1.7.3 (2013-07-18) =
* Enhancement: Show expected and actual mime type in log when an error occurs
Expand Down

0 comments on commit e5cb181

Please sign in to comment.