From 6c67c9d74550575fbc96be0baad42260c2dbcb6a Mon Sep 17 00:00:00 2001 From: Calin Burloiu Date: Thu, 21 Jul 2011 11:38:44 +0300 Subject: [PATCH] basic functionality, no estetics: videos are listed in index; can be watched with both plugins --- application/config/p2p-tube.php | 5 +- application/controllers/catalog.php | 11 ++-- application/controllers/video.php | 22 ++++++-- application/models/videos_model.php | 15 +++--- .../views/video/ns-html5_plugin_view.php | 4 ++ .../views/video/ns-vlc_plugin_view.php | 31 +++++++++++ application/views/video/watch_view.php | 36 +++++++++++-- ...C-interface.js => NextShare_VLC_plugin.js} | 51 ++++++++----------- javascript/default.js | 0 javascript/video.js | 24 +++++++++ ...interface.css => NextShare_VLC_plugin.css} | 0 11 files changed, 146 insertions(+), 53 deletions(-) create mode 100644 application/views/video/ns-html5_plugin_view.php create mode 100644 application/views/video/ns-vlc_plugin_view.php rename javascript/{NextSharePC-interface.js => NextShare_VLC_plugin.js} (85%) create mode 100644 javascript/default.js create mode 100644 javascript/video.js rename stylesheets/{NextSharePC-interface.css => NextShare_VLC_plugin.css} (100%) diff --git a/application/config/p2p-tube.php b/application/config/p2p-tube.php index ec7eb3a..6f33bec 100644 --- a/application/config/p2p-tube.php +++ b/application/config/p2p-tube.php @@ -51,13 +51,14 @@ $config['default_javascript'] = ''; | | Sets the default video file extension, which must be set without '.' prefix. | This extension is going to be added to the `name` field from the DB in -| order to deduce the video file name if not stated otherwise. Possible values: +| order to deduce the video file name if not stated otherwise in the format. +| Possible values: | | ogv | ogg | */ -$config['default_video_ext'] = 'ogg'; // TODO: Change to 'ogv'! +$config['default_video_ext'] = 'ogv'; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/catalog.php b/application/controllers/catalog.php index e748d95..37b1a6c 100644 --- a/application/controllers/catalog.php +++ b/application/controllers/catalog.php @@ -33,11 +33,12 @@ class Catalog extends CI_Controller { { $this->load->helper('url'); - $format = 'Calin Andrei '; - $pos = strpos($format, ' '); - if($pos !== FALSE) - $format = substr($format, 0, $pos); - echo $format; + echo 'link'; + } + + public function search($query_str) + { + echo $query_str; } } diff --git a/application/controllers/video.php b/application/controllers/video.php index cb19035..64a1e63 100644 --- a/application/controllers/video.php +++ b/application/controllers/video.php @@ -24,7 +24,7 @@ class Video extends CI_Controller { * * @param string $id DB id of the video * @param string $name `name` of the video from DB - * @param string $plugin video plugin ('vlc', 'html5'). If it's set + * @param string $plugin video plugin ('ns-vlc', 'ns-html5'). If it's set * to NULL or 'auto', the plugin is automatically selected. */ public function watch($id, $name = NULL, $plugin = NULL) @@ -39,8 +39,8 @@ class Video extends CI_Controller { // Display page. $params = array( 'title' => $data['video']['title'] . ' -- ' . $this->config->item('site_name'), - 'stylesheets' => array('jquery-ui.css', 'NextSharePC-interface.css'), - 'javascripts' => array('jquery.min.js', 'jquery-ui.min.js', 'NextSharePC-interface.js'), + 'stylesheets' => array('jquery-ui.css', 'NextShare_VLC_plugin.css'), + 'javascripts' => array('jquery.min.js', 'jquery-ui.min.js', 'NextShare_VLC_plugin.js', 'video.js'), //'metas' => array('description'=>'','keywords'=>'') ); $this->load->library('html_head_params', $params); @@ -52,6 +52,22 @@ class Video extends CI_Controller { $this->load->view('footer'); $this->load->view('html_end'); } + + /** + * AJAX page which retrieves a video plugin. + * + * The associated with this controller should be parameter type + * concatenated with '_plugin_view' and must be located in + * 'application/views/video'. + * + * @param string $type 'ns-vlc', 'ns-html5' + */ + public function plugin($type) + { + $data['url'] = $this->input->post('url', TRUE); + + $this->load->view('video/'. $type . '_plugin_view', $data); + } } /* End of file video.php */ diff --git a/application/models/videos_model.php b/application/models/videos_model.php index 59ff7d3..0ae47b1 100644 --- a/application/models/videos_model.php +++ b/application/models/videos_model.php @@ -46,7 +46,7 @@ class Videos_model extends CI_Model { $video['id'], $video['name'])); // Thumbnails - $video['thumbs'] = $this->getThumbs($video['name'], + $video['thumbs'] = $this->get_thumbs($video['name'], $video['thumbs_count']); } @@ -97,26 +97,27 @@ class Videos_model extends CI_Model { // Convert JSON encoded string to arrays. $video['formats'] = json_decode($video['formats'], TRUE); $video['tags'] = json_decode($video['tags'], TRUE); + asort($video['tags']); + $video['tags'] = array_reverse($video['tags'], true); // Torrents $video['torrents'] = array(); foreach ($video['formats'] as $format) { - $pos = strpos($format, ' '); - if($pos !== FALSE) - $format = substr($format, 0, $pos); + $ext = isset($format['ext']) ? + $format['ext'] : $this->config->item('default_video_ext'); $video['torrents'][] = site_url('data/torrents/'. $video['name'] . '_' - . $format . '.'. $this->config->item('default_video_ext') + . $format['def'] . '.'. $ext . '.'. $this->config->item('default_torrent_ext')); } // Thumbnails - $video['thumbs'] = $this->getThumbs($video['name'], $video['thumbs_count']); + $video['thumbs'] = $this->get_thumbs($video['name'], $video['thumbs_count']); return $video; } - public function getThumbs($name, $count) + public function get_thumbs($name, $count) { $thumbs = array(); diff --git a/application/views/video/ns-html5_plugin_view.php b/application/views/video/ns-html5_plugin_view.php new file mode 100644 index 0000000..4275b85 --- /dev/null +++ b/application/views/video/ns-html5_plugin_view.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/application/views/video/ns-vlc_plugin_view.php b/application/views/video/ns-vlc_plugin_view.php new file mode 100644 index 0000000..adcd415 --- /dev/null +++ b/application/views/video/ns-vlc_plugin_view.php @@ -0,0 +1,31 @@ +
No VLC
+ + + + + + +
+ + -
+ + \ No newline at end of file diff --git a/application/views/video/watch_view.php b/application/views/video/watch_view.php index d459378..2b01730 100644 --- a/application/views/video/watch_view.php +++ b/application/views/video/watch_view.php @@ -1,3 +1,5 @@ + +

- - + + + +
+ + + + + +
+
views
+
likes
+
dislikes
+
+ +
Tags: + $score): ?> + + + + +
+ + +
\ No newline at end of file diff --git a/javascript/NextSharePC-interface.js b/javascript/NextShare_VLC_plugin.js similarity index 85% rename from javascript/NextSharePC-interface.js rename to javascript/NextShare_VLC_plugin.js index 9db050b..dffb2cd 100644 --- a/javascript/NextSharePC-interface.js +++ b/javascript/NextShare_VLC_plugin.js @@ -1,4 +1,4 @@ -// NextSharePC plugin controls +// NextSharePC plugin controls // Author: Calin-Andrei Burloiu, calin.burloiu@gmail.com // 2011 @@ -16,6 +16,17 @@ function getURLParam( name ) return results[1]; } +function pad(number, length) +{ + var str = '' + number; + while (str.length < length) + { + str = '0' + str; + } + + return str; +} + function getPluginWidth() { return 800; @@ -68,19 +79,11 @@ function update() timerHandle = setTimeout("update()", updateInterval); } -function displayNextSharePC(torrent, html5) +function displayNextSharePC(torrent) { - if(html5 == true) - { - document.write(''); - document.write('

'); - document.write('Play video using VLC with NextSharePC

'); - - return true; - } - + //document.write('popârțac'); + //return; + if (navigator.appName == "Netscape") { document.write('' + '
' + ''); - - $("nsTable").css("width", getPluginWidth()); - - document.write('

'); - document.write('Play video using HTML5 with SwarmPlayer

'); return true; } @@ -155,17 +153,6 @@ function onSliderStop(event, ui) timerHandle = setTimeout("update()", updateInterval); } -function pad(number, length) -{ - var str = '' + number; - while (str.length < length) - { - str = '0' + str; - } - - return str; -} - function onSliderSlide(event, ui) { updateTime(true); @@ -180,11 +167,13 @@ function onVolChange(event, ui) document.vlc.audio.volume = val; } -$(document).ready(function() +function loadControls() { if(document.vlc == null) return; + $("nsTable").css("width", getPluginWidth()); + // Progress Slider $("#nsSlider").slider({ animate: true }); $("#nsSlider").slider({ min: 0 }); @@ -208,7 +197,7 @@ $(document).ready(function() $("#nsVol").slider(); timerHandle = setTimeout("update()", updateInterval); -}); +} function play() { diff --git a/javascript/default.js b/javascript/default.js new file mode 100644 index 0000000..e69de29 diff --git a/javascript/video.js b/javascript/video.js new file mode 100644 index 0000000..284e7ee --- /dev/null +++ b/javascript/video.js @@ -0,0 +1,24 @@ +// Usually replaced in PHP +siteUrl = '/'; + +function getNsVlcPlugin(videoUrl) +{ + $.post( + siteUrl + 'video/plugin/ns-vlc', + {url: videoUrl}, + function(data) { + $('#video_plugin').html(data); + } + ); +} + +function getNsHtml5Plugin(videoUrl) +{ + $.post( + siteUrl + 'video/plugin/ns-html5', + {url: videoUrl}, + function(data) { + $('#video_plugin').html(data); + } + ); +} \ No newline at end of file diff --git a/stylesheets/NextSharePC-interface.css b/stylesheets/NextShare_VLC_plugin.css similarity index 100% rename from stylesheets/NextSharePC-interface.css rename to stylesheets/NextShare_VLC_plugin.css -- 2.20.1