<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Posts extends CI_Controller {

	public function __construct()
	{ 
		parent:: __construct();
		$this->load->model('common_model');
		$this->load->library('Utility');
	}

	public function get_videos(){
		$video_id = $this->input->post('video_id');
		
		$video_details = $this->common_model->getAllRow('sys_videos', array('id'=>$video_id));
		//pr($video_details);
		$html = '';
		if($video_details){
			$video_path = 'https://d3klt2dtr6705l.cloudfront.net/'.$video_details['user_id'].'/'.$video_details['filename'];

			$this->load->library('s3_cloudfront');
			$my_config = $this->config->load('s3', true);
			$s3_config = $this->config->item('s3');
			$private_key_filename = $s3_config['cl_private_key'];
			$key_pair_id = $s3_config['cl_key_pair_id'];
			$expires = time() + 86400;
			$link = $this->s3_cloudfront->get_canned_policy_stream_name($video_path, $private_key_filename, $key_pair_id, $expires);
			$html = '<video width="200" height="160" playsinline controls autoplay="" controlsList="nodownload">
	                    <source src="'.$link.'" type="video/mp4">
	                    Your browser does not support the video tag.
	                  </video>';
		}
		echo $html;die;
	}

}	

/* End of file upload.php */
/* Location: ./application/controllers/upload.php */