summaryrefslogtreecommitdiff
path: root/modules/gallery/views/movieplayer-flash.html.php
blob: 12303bf402950ba2ebdef60003fbde20416eb930 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php defined("SYSPATH") or die("No direct script access.") ?>
<script type="text/javascript" src="<?= url::file("lib/flowplayer-flash/flowplayer.js") ?>"></script>
<?= html::anchor($url, "", $attrs) ?>
<script type="text/javascript">
  var id = "<?= $attrs["id"] ?>";
  var max_size = <?= $max_size ?>;
  // set the size of the movie html anchor, taking into account max_size and height of control bar
  function set_movie_size(width, height) {
    if((width > max_size) || (height > max_size)) {
      if (width > height) {
        height = Math.ceil(height * max_size / width);
        width = max_size;
      } else {
        width = Math.ceil(width * max_size / height);
        height = max_size;
      }
    }
    height += flowplayer(id).getConfig().plugins.controls.height;
    $("#" + id).css({width: width, height: height});
  };
  // setup flowplayer
  flowplayer(id,
    $.extend(true, {
      "src": "<?= url::abs_file("lib/flowplayer-flash/flowplayer.swf") ?>",
      "wmode": "transparent",
      "provider": "pseudostreaming"
    }, <?= json_encode($fp_flash_params) ?>),
    $.extend(true, {
      "plugins": {
        "pseudostreaming": {
          "url": "<?= url::abs_file("lib/flowplayer-flash/flowplayer.pseudostreaming-byterange.swf") ?>"
        },
        "controls": {
          "autoHide": "always",
          "hideDelay": 2000,
          "height": 24
        }
      },
      "clip": {
        "scaling": "fit",
        "onMetaData": function(clip) {
          // set movie size a second time using actual size from metadata
          set_movie_size(parseInt(clip.metaData.width), parseInt(clip.metaData.height));
        }
      }
    }, <?= json_encode($fp_flash_config) ?>)
  ).ipad();
  // set movie size using width and height passed from movie_img function
  $("document").ready(set_movie_size(<?= $width ?>, <?= $height ?>));
</script>