Sample Video Search Control using » Google Ajax Search API | |
Loading...
When a user clicks on a thumbnail of a video within the bar, the video is displayed in a player above the list |
Google AJAX Search API key | |
To use google API's within a web-site/blog, you need to have an API KEY that is specific to the URL/URI of website/blog.
For the Google Ajax Search API, you may generate just the key for your website/blog or you can use the wizard to generate the key along with the code relating to an application based on the Ajax Search API. Video Bar, Video Search Controls are applications based on the Google Ajax Search API. Using the wizard would be a convenient alternative, where you are starting just now. |
Generate Search Control Code (including a key for your blog/website) | |
|
Generate Just the Google AJAX Search API key | |
If you intend to generate just a key specific to the URL/URI of your website/blog. This may be the case where you have collected the video bar code from elsewhere and intend to change just the key in the code.
This key would be used
You can generate the key as many times as you want, but each time a new key would be generated. » Code Generate
While displaying the generated key, you would find html code also getting generated and displayed below the key.
That code is not specific to the Videobar Application. To avoid confusion use the Videobar WIZARD to generate the code you need for the video bar.
Greater Customization of the Video Search Control
The explanation below this is for those who have an interest in hanlding programme code and are interested in learning things in detail. |
Include the code in your blog or web page | |
To make the video search control appear in your blog or web page, include the code within the html code of your web page.
In blogger blog, if you are using the modern widget based template for your blog, you can include (paste) the code within a HTML/Javascript Page Element (widget). If you have not used the wizard, ensure that the Access Key you generated is used in the code being placed. |
Positioning the Video Search Control | |
» In any Web Page
You can place the search control anywhere on your web page. The player displays the video when a user clicks on a thumbnail of a video within the bar.
When a user clicks on a thumbnail of a video within the bar, the video is displayed in a player above the list. The list and the player stay together. Place the html code relevant to division displaying the control at the location where you want them to appear. » In a blogger Blog
In blogger blog, if you are using the modern widget based template for your blog, you can position the widget where you want the video search control to appear.
Greater Customization of the Video Search Control
The explanation below this is for those who have an interest in hanlding programme code and are interested in learning things in detail. |
Loading the Ajax API & Video Search Control | |
• STEP 1
This code can be placed within the head section or the body section of the web page. If you are using a wizard to create the code, you would be placing all the code at a single place, i.e. the body section where you intend the video search results to appear. • First Two Files need not be placed
The code for including the first two files need not be placed again if it had been included in an earlier case, like in the case of including a video bar within the same page. Though there is no harm in including it a second time, it serves no purpose.
• What are they for?
|
Positioning the Division displaying the Video Search Results & Player | |
• STEP 2
The text "Loading ..." indicates the default text that is displayed within the division till it is filled with content. |
Formatting the Division | |
The style definitions are to be included within the <style> tag and placed within the web page head section preferably. When you use the wizard for creating the code, this gets placed along with all other code. The code for formatting the division with the ID videosearch is given here. Any other css formatting code that is to be used can be included within the same style element. This is only optional and is thus not marked as a step. |
Creating and Configuring the Video Search Control | |
• STEP 3 (Last)
Include this script within the web page either in the head or the body section. As far as possible place the code along with the other related code, so that you don't lose track of it.
The script is executed as when it is encountered by the browser. If it is placed within the head section of the web page, it is executed before the body content is loaded. The function GSearch.setOnLoadCallback() at the end of the script code, calls the function LoadVideoSearch() and cause the code within it to get executed. • LoadVideoSearch() execution
The execution of the function LoadVideoSearch() will result in
|
Video Search Options | |
There are a number of options that can be chosen for the video search. In the above example, these options are assigned to the variable by name "options" and passed on to the video bar object. They form the arguments for the function call creating the videobar object.
The available options are • Number of Results » largeResultSet : true
By default the video bar is set to display 4 video thumbnails. To display upto 8 video thumbnails, use the argument largeResultSet : true.
This may be set to be false or completely ignored to set the fewer number of results to be displayed. • Two Row Display Mode » twoRowMode : true
This option controls the maximum number of results presented to the user.
When the value of this option is set to true, it overrides any setting established by largeResultSize and computes the number of search results to display based on the width of the division holding the video search control.
• Custom String » string_allDone : "____"
Whenever a user clicks on the thumbnail, the video player is displayed with the phrase "i'm done watching this" at the top, which also works as display text for a link that closes the player and folds away the division holding the player.
The text can be changed to any text string of your choice using the option string_allDone : "____", the dash taking the text you want to appear in place of i'm done watching this. • Startup Delay » startupDelay : 1000
The startup delay option defers the initial search and other startup activity. You can select a value between 50ms and 2s.
This option is really designed for pages that have a log of startup activity and this allows you to defer activity created by this control. Only use this option if your page really needs it. • Query Tags
{ query : "winter olympics", label : "Olympics" }.
Query Tags are search keywords. Each tag contains both a search expression (value of query : ) as well as an optional display term (value of label : ). This array is required and supplies a default list of search expressions. The display terms are listed below the video thumbnails. Where the display term is not mentioned, the search expression itself is used as the display term. |
Multiple Video Search Controls on a Page | |
The divisions relating to each search control should be placed wherever you think them to be fit.
|
Player Size | |
|
Formatting » Form, Video Thumbnails, Text above/below the player | |
The box holding the thumbnails displaying the video within the video bar, the text displayed above the video player and the text displayed below the video player can be formatted using the CSS style properties which would override the default settings in the file "gsvideosearch.css".
Any of the style properties that are capable of being used for the relevant element can be used. |
Changing Video Search Results using Links | |
The initial display of search results is dependent on the query strings assigned to defaultTags. The strings would be displayed below the search results and a reader/user may click on the link to refresh the search results based on the query behind the label being clicked on.
The video search results can also be changed by using the search box above the thumbnails in display. The video thumbnails of the videos relating to the search terms used would be displayed.
The link can be created using the anchor tag or any other element using the html event attributes onclick, onmouseover, etc. In vsrch.execute('kids fun'), vsrch is the variable name that holds the video bar object created. The variable should have been declared as a global variable to be accessible using such a link. In the example given to the right, the variable vsrchmain is declared within the function and is thus local to that function. It can only be accessed from within the function. The variable vsrchone is declared outside the function (all functions) and is thus accessible from anywhere. |
Save & Load Search Expressions | |
Where you do not use the save and load functions for videosearch the strings used by the user for searching in a particular session would not be recorded |
Want to Know More!! | |
• About the Tech behind the Videosearch
If you have understood the functioning of the product "videosearch" and if you are proficient in javascript, viewing the javascript code that has been used for the product would be useful in getting an understanding of the tech behind the product.
You can access a copy of the code using the url within the html element used for inserting the code. gsearch: uds.js and VideoSearch: gsvideosearch.js • Formatting
If you are proficient with CSS properties and have the patience and interest to experiment, you can get greater details from this file which is the CSS file linked to videosearch and you may also get some idea from the CSS file linked to the googlesearch.
|
Author Credit : The Edifier |