Defvayne23

 

Posts Tagged ‘jTube’

jTube – Not Just for Javascript

My jQuery YouTube API plugin, jTube, has now been ported to a PHP class. The two work similar in the fact that you set a query type (user uploads, feed, playlist, etc.) and set some options. Below is an example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
include("jTube.Query.php");
 
$oVideos = new jTubeQuery;
$oVideos->setQuery("user", "defvayne23", "uploads");
$oVideos->setOption("limit", 5);
 
try {
	$aVideos = $oVideos->runQuery();
} catch(Exception $e) {
	die($e->getMessage());
}
 
// Use $aVideos

With the PHP class jTube can now make use of authentication and with that the entire YouTube API. The YouTube API allows for anything from uploading a video to supplying feedback on a video (rate, comment, flag). The PHP class already can make use of authentication tokens to retrieve private info for the user that belongs to the token. The first new functionality coming to the PHP class is video managing and upload.

Checkout jTube for PHP on github now.

Share

 

Using jTube – Video and Thumbnail

This is the final post of the series that has so far covered the very basics of showing a list of video titles, to paging of the list using jTube. In this post I will discuss how to embed a video using jTubeEmbed which comes with the jTube jQuery plugin, also how to show the video thumbnail provided by YouTube. To show these features off I will modify where we left off in the paging tutorial and show the video for the first entry of the page then show the thumbnail for the other videos on the page.

To show the video only on the first video we need to modify the each loop to tell us where we are in the loop. Simply add `index` as the first parameter received.

12
        $(videos).each(function(index) {

(more…)

Share

 

Using jTube – Paging

In my previous post I covered the basics of showing a users uploaded videos. In this tutorial we will go over how to implement paging. To really show off paging, I have changed the request to top rated videos.

First we need to break our video options into a variable so we can re-use them when calling the other pages. This allows us to easily change the page number and leave all the other options intact.

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var options = {
    feed: 'top_rated',
    success: function(videos, numberPages) {
        $(videos).each(function() {
            videoHTML = '<li>';
            videoHTML += '<a href="'+this.link+'" target="_blank">';
            videoHTML += this.title;
            videoHTML += '</a> - '+this.length;
            videoHTML += '</li>';
 
            $('#myVideos').append(videoHTML);
        });
    },
    error: function(error) {
        $('#myVideos').append('<li class="error">'+error+'</li>');
    }
};
 
$.jTube(options);

(more…)

Share

 

Using jTube – Basics

This is the first post in a line of uses for jTube. In this post I will show the basics of getting a users upload list and using the info. Before we start make sure that you have included the latest jQuery and latest jTube.

For jTube to work you must tell it what feed to grab by passing the info to the correct option. The only one we need to worry about today is `user`. Using the users feed has an option that accompanies it. The option userType tells what info about the user to retrieve. By default jTube loads the users uploads. Lets take a look at that.

1
2
3
4
5
<script>
$.jTube({
    user: 'defvayne23'
});
</script>

(more…)

Share