aboutsummaryrefslogtreecommitdiff
path: root/js/video.js
blob: 4a23b5339a258cf4636771c28e8f15669582a2c4 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
 * @file
 * Adds some show/hide to the admin form to make the UXP easier.
 *
 */
(function($){

  $(document).ready(function() {
    //lets see if we have any jmedia movies
    if($.fn.media) {
      $('.jmedia').media();
    }
	
    video_hide_all_options();
    $("input[name='video_convertor']").change(function() {
      video_hide_all_options();
    });

    // change metadata options
    video_hide_all__metadata_options();
    $("input[name='video_metadata']").change(function() {
      video_hide_all__metadata_options();
    });

    // change metadata options
    video_hide_all__filesystem_options();
    $("input[name='video_filesystem']").change(function() {
      video_hide_all__filesystem_options();
    });

    $('.video_select').each(function() {
      var ext = $(this).attr('rel');
      $('select', this).change(function() {
        if($(this).val() == 'video_play_flv') {
          $('#flv_player_'+ext).show();
        } else {
          $('#flv_player_'+ext).hide();
        }
      });
      if($('select', this).val() == 'video_play_flv') {
        $('#flv_player_'+ext).show();
      }
    });
	
    if(Drupal.settings.video) {
      $.fn.media.defaults.flvPlayer = Drupal.settings.video.flvplayer;

    }
	
    //lets setup our colorbox videos
    $('.video-box').each(function() {
      var url = $(this).attr('href');
      var data = $(this).metadata();
      var width = data.width;
      var height= data.height;
      var player = Drupal.settings.video.player; //player can be either jwplayer or flowplayer.
      $(this).colorbox({
        html: '<a id="video-overlay" href="'+url+'" style="height:'+height+'; width:'+width+'; display: block;"></a>',
        onComplete:function() {
          if(player == 'flowplayer') {
            flowplayer("video-overlay", Drupal.settings.video.flvplayer, {
              clip: {
                autoPlay: Drupal.settings.video.autoplay,
                autoBuffering: Drupal.settings.video.autobuffer
              }
            });
          } else {
            $('#video-overlay').media({
              flashvars: {
                autostart: Drupal.settings.video.autoplay
              },
              width:width,
              height:height
            });
          }
        }
      });
    });
  });
})(jQuery);

function video_hide_all_options() {
  $("input[name='video_convertor']").each(function() {
    var id = $(this).val();
    $('#'+id).hide();
    if ($(this).is(':checked')) {
      $('#' + id).show();
    }
  });
}

function videoftp_thumbnail_change() {
  // Add handlers for the video thumbnail radio buttons to update the large thumbnail onchange.
  $(".video-thumbnails input").each(function() {
    var path = $(this).val();
    if($(this).is(':checked')) {
      var holder = $(this).attr('rel');
      $('.'+holder+' img').attr('src', Drupal.settings.basePath + path);
    }
  });

}

function video_hide_all__metadata_options() {
  $("input[name='video_metadata']").each(function() {
    var id = $(this).val();
    $('#'+id).hide();
    if ($(this).is(':checked')) {
      $('#' + id).show();
    }
  });
}

function video_hide_all__filesystem_options() {
  $("input[name='video_filesystem']").each(function() {
    var id = $(this).val();
    $('#'+id).hide();
    if ($(this).is(':checked')) {
      $('#' + id).show();
    }
  });
}