|
| 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';
/*
|--------------------------------------------------------------------------
{
$this->load->helper('url');
- $format = 'Calin Andrei ';
- $pos = strpos($format, ' ');
- if($pos !== FALSE)
- $format = substr($format, 0, $pos);
- echo $format;
+ echo '<a href="/">link</a>';
+ }
+
+ public function search($query_str)
+ {
+ echo $query_str;
}
}
*
* @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)
// 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);
$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 */
$video['id'], $video['name']));
// Thumbnails
- $video['thumbs'] = $this->getThumbs($video['name'],
+ $video['thumbs'] = $this->get_thumbs($video['name'],
$video['thumbs_count']);
}
// 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();
--- /dev/null
+<video controls="controls" width="800" height="600" preload="auto">
+ <source src="<?php echo $url ?>" type="video/ogg" />
+ Error: Your browser does not support HTML5 or the video format!
+</video>
\ No newline at end of file
--- /dev/null
+<div id="vlc_container">No VLC</div>
+<table id="nsTable">
+ <tr><td id="nsPlaybackCell"><input type=button value="Play" onClick="play();" />
+ <input type=button value="Pause" onClick="pause();" />
+ <input type=button value="Stop" onclick="stop();" /></td>
+ <td id="nsTimeCell"><span id="nsTime">-</span></td>
+ <td><div id="nsVol"></div></td>
+ <td><input type=button value="Fullscreen" onclick="fullscreen();" /></td></tr>
+ <tr><td colspan="4"><div id="nsSlider"></div></td></tr>
+</table>
+
+<script type="text/javascript">
+ if (navigator.appName == "Netscape")
+ {
+ $('#vlc_container').html(
+ '<embed type="application/x-ns-stream" name="vlc" id="vlc" autoplay="no" loop="no" width="' + getPluginWidth() + '" height="' + getPluginHeight() + '" target="<?php echo $url ?>" />');
+ }
+ else
+ {
+ $('$vlc_container').html(
+ '<object classid="clsid:1800B8AF-4E33-43C0-AFC7-894433C13538" codebase="http://trial.p2p-next.org/download/SwarmPlugin_IE_1.0.4.cab" width="' + getPluginWidth() + '" height="' + getPluginHeight() + '" id="vlc" name="vlc" events="True" target="">'
+ + '<param name="Src" value="<?php echo $url ?>" />'
+ + '<param name="ShowDisplay" value="True" />'
+ + '<param name="Loop" value="False" />'
+ + '<param name="AutoPlay" value="False" />'
+ + '<param name="Toolbar" value="True" />'
+ + '</object>');
+ }
+
+ loadControls();
+</script>
\ No newline at end of file
+<script type="text/javascript">siteUrl = '<?php echo site_url() ?>';</script>
+
<div id="body">
<!-- Invalid name in URL-->
<?php if (isset($video['err'])):
<!-- Correct URL-->
<?php else: ?>
<h1><?php echo $video['title'] ?></h1>
- <script type="text/javascript"> displayNextSharePC("<?php
- //echo $video['torrents'][0]; // VLC
- echo 'tribe://'. $video['torrents'][0]; // HTML5
- ?>", true); </script>
- <?php endif ?>
+
+ <ul>
+ <li><a href="javascript: void(0)" onclick="getNsVlcPlugin('<? echo $video['torrents'][0] ?>')">VLC</a></li>
+
+ <li><a href="javascript: void(0)" onclick="getNsHtml5Plugin('<?php echo 'tribe://'. $video['torrents'][0] ?>')">HTML5</a></li>
+ </ul>
+
+ <div id="video_plugin"></div>
+ <!--TODO preload user preferred plugin-->
+ <script type="text/javascript"> getNsHtml5Plugin('<?php echo 'tribe://'. $video['torrents'][0] ?>') </script>
+
+ <!--TODO user name-->
+ <!--TODO change format controls-->
+ <div id="video_date"><?php echo $video['date'] ?></div>
+ <div id="video_views"><?php echo $video['views'] ?> views</div>
+ <div id="video_likes"><?php echo $video['likes'] ?> likes</div>
+ <div id="video_dislikes"><?php echo $video['dislikes'] ?> dislikes</div>
+ <div id="video_description"><?php echo $video['description'] ?></div>
+ <!-- TODO <div id="video_category">Category: <?php echo $video['category_name'] ?></div>-->
+ <div id="video_tags">Tags:
+ <?php foreach($video['tags'] as $tag => $score): ?>
+ <a href="<?php site_url('catalog/search/'. $tag) ?>">
+ <?php echo "$tag($score)" ?>
+ </a>
+ <?php endforeach ?>
+ <div id="video_license"><?php echo $video['license'] ?></div>
+
+
+ <?php endif // if (isset($video['err'])): ?>
</div>
\ No newline at end of file
-// NextSharePC plugin controls\r
+// NextSharePC plugin controls\r
// Author: Calin-Andrei Burloiu, calin.burloiu@gmail.com\r
// 2011\r
\r
return results[1];\r
}\r
\r
+function pad(number, length) \r
+{\r
+ var str = '' + number;\r
+ while (str.length < length) \r
+ {\r
+ str = '0' + str;\r
+ }\r
+\r
+ return str;\r
+}\r
+\r
function getPluginWidth()\r
{\r
return 800;\r
timerHandle = setTimeout("update()", updateInterval);\r
}\r
\r
-function displayNextSharePC(torrent, html5)\r
+function displayNextSharePC(torrent)\r
{\r
- if(html5 == true)\r
- {\r
- document.write('<video src="'+torrent+'" controls="controls" width="800" height="600">');\r
- document.write(' Error: Your browser does not support HTML5!');\r
- document.write('</video>');\r
- document.write('<br /><br /><p><a href="' + window.location.href.replace('&html5=1', '') + '">');\r
- document.write('Play video using VLC with NextSharePC</a></p>');\r
-\r
- return true;\r
- }\r
-\r
+ //document.write('popârțac');\r
+ //return;\r
+ \r
if (navigator.appName == "Netscape")\r
{\r
document.write('<embed type="application/x-ns-stream"');\r
+ '<td><input type=button value="Fullscreen" onclick="fullscreen();" /></td></tr>'\r
+ '<tr><td colspan="4"><div id="nsSlider"></div></td></tr>'\r
+ '</table>');\r
- \r
- $("nsTable").css("width", getPluginWidth());\r
-\r
- document.write('<br /><p><a href="' + window.location.href + '&html5=1">');\r
- document.write('Play video using HTML5 with SwarmPlayer</a></p>');\r
\r
return true;\r
}\r
timerHandle = setTimeout("update()", updateInterval);\r
}\r
\r
-function pad(number, length) \r
-{\r
- var str = '' + number;\r
- while (str.length < length) \r
- {\r
- str = '0' + str;\r
- }\r
-\r
- return str;\r
-}\r
-\r
function onSliderSlide(event, ui)\r
{\r
updateTime(true);\r
document.vlc.audio.volume = val;\r
}\r
\r
-$(document).ready(function() \r
+function loadControls()\r
{\r
if(document.vlc == null)\r
return;\r
\r
+ $("nsTable").css("width", getPluginWidth());\r
+ \r
// Progress Slider\r
$("#nsSlider").slider({ animate: true });\r
$("#nsSlider").slider({ min: 0 });\r
$("#nsVol").slider();\r
\r
timerHandle = setTimeout("update()", updateInterval);\r
-}); \r
+}\r
\r
function play()\r
{\r
--- /dev/null
+// 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