4 * Class Video controls video items handling: watching, commenting, rating,
8 * @author Călin-Andrei Burloiu
10 class Video extends CI_Controller {
12 public function __construct()
14 parent::__construct();
16 //$this->lang->load('video');
19 public function index()
25 * The page used for watching a video
27 * @param string $id DB id of the video
28 * @param string $name `name` of the video from DB
29 * @param string $plugin video plugin ('ns-vlc', 'ns-html5'). If it's set
30 * to NULL or 'auto', the plugin is automatically selected.
32 public function watch($id, $name = NULL, $plugin = NULL)
34 $this->load->helper('url');
39 // Retrieve video information.
40 $this->load->model('videos_model');
41 $this->videos_model->inc_video_var($id, 'views');
42 $data['video'] = $this->videos_model->get_video($id, $name);
43 $data['plugin_type'] = ($plugin === NULL ? 'auto' : $plugin);
46 $params = array( 'title' => $data['video']['title'] . ' -- '
47 . $this->config->item('site_name'),
49 'jquery.ui.nsvideo.css',
53 'jquery.ui.nsvideo.js'
55 //'metas' => array('description'=>'','keywords'=>'')
57 $this->load->library('html_head_params', $params);
59 // Preloading video plugin.
60 // TODO plugin auto: type and format
61 if ($data['plugin_type'] == 'auto')
62 $data['plugin_type'] = 'ns-html5';
63 $data['asset_index'] = 0;
65 // TODO remove old AJAX plugin content
66 // $data['plugin_content'] = $this->_plugin('ns-html5',
67 // $data['video']['url'][0], TRUE);
72 $this->load->view('html_begin', $this->html_head_params);
73 $this->load->view('header');
75 //$main_params['content'] = $this->load->view('video/watch_view', $data, TRUE);
76 $this->load->view('video/watch_view', $data);
78 $this->load->view('footer');
79 $this->load->view('html_end');
83 * AJAX page which retrieves a video plugin.
85 * The view associated with this controller should be parameter type
86 * concatenated with '_plugin_view' and must be located in
87 * 'application/views/video'.
89 * @param string $type 'ns-vlc', 'ns-html5'
91 public function plugin($type)
93 $url = $this->input->post('url', TRUE);
95 $this->_plugin($type, $url);
99 * Video plugin controller
101 * See plugin function for details. If the second parameter is TRUE
102 * the output is return instead of being displayed (used in preloading).
104 public function _plugin($type, $url, $return_output=FALSE)
106 if ($type == 'ns-html5')
107 $data['url'] = 'tribe://' . $url;
108 else if ($type == 'ns-vlc')
111 $output = $this->load->view('video/'. $type . '_plugin_view', $data,
120 /* End of file video.php */
121 /* Location: ./application/controllers/video.php */