<?php

/**
 * include some common code (like we did in the 90s)
 * People still do this? ;)
 */
$rep = $_REQUEST['rep'];
include_once dirname(__FILE__).'/'.$rep.'/config.php';
// configuration
include 'common.php';

// todo :
// - gestion du parent.document.location mediafragment
// - limite taille vertical embed
// - ajouter la polemic timline en dessous de la video

if (is_array($config['metadata'])) {
    if (array_key_exists("metadata",$_GET) && array_key_exists($_GET['metadata'], $config['metadata'])) {
        $metadata_url = $config['metadata'][$_GET['metadata']]['url'];
    } else {
        $keys = array_keys($config['metadata']);
        $metadata_url = $config['metadata'][$keys[0]]['url'];
    }
} else {
    $metadata_url = $config['metadata'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Polemic Tweet Embedded Player</title>
    <script type="text/javascript" src="<?php echo(registry_url('metadataplayer','js'));?>"></script>
    
    <script type="text/javascript">
    IriSP.libFiles.defaultDir = "<?php echo(registry_url('libdir','js'));?>";
    IriSP.widgetsDir = "<?php echo(registry_url('ldtwidgets','js'));?>";
    IriSP.libFiles.locations.jwPlayerSWF = "<?php echo(URL_ROOT); ?>res/mediaplayer/player.swf";
    IriSP.language = "<?php echo($actual) ?>";
    
    var _metadata = {
        url: '<?php echo $metadata_url ?>?callback=?',
        format: 'ldt'
    };
    var _config = {            
        gui: {
            width: 630,
            container: 'LdtPlayer',
            default_options: {
                metadata: _metadata
            },
            css:'<?php echo(registry_url('metadataplayer','css'));?>',
            widgets: [
                { type: "Polemic" },
                { type: "Slider" },
                {
                    type: "Controller",
                    disable_annotate_btn: true
                },
                {
                    type: "Segments",
                    annotation_type: [ "chap", "découpage" ]
                },
                { type: "Arrow" },
                { type: "Annotation" },
                { type: "Tweet" },
                { type: "Mediafragment"},
                {
                    type: "Trace",
                    default_subject: "PolemicTweet-player"
                }
            ]
        },
        player:{
            type:'jwplayer', // player type
            live: true, 
            height: 300, 
            width: 630, 
            provider: "rtmp",
            autostart: true,
            metadata: _metadata
        }
    };
    </script>
    <script type="text/javascript">
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-23581291-1']);
        _gaq.push(['_trackPageview', location.pathname + location.search + location.hash]);
        _gaq.push(['_setAllowAnchor', true]);
      
        (function() {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();
    </script>
	<style type="text/css">
		body{
			padding:0px;
			margin:0px;
		}
    	#LdtPlayer {
    	    margin-bottom: 2px;
    	}
	</style>
	<script type="text/javascript">
		var _gaq = _gaq || [];
		_gaq.push(['_setAccount', 'UA-23581291-1']);
		_gaq.push(['_trackPageview', location.pathname + location.search + location.hash]);
		_gaq.push(['_setAllowAnchor', true]);
	  
		(function() {
		    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
		})();
	</script>
  </head>
  
        <div id="LdtPlayer"></div>
<script type="text/javascript">
    var _myPlayer = new IriSP.Metadataplayer(_config);
</script>
  </body>
</html>
