Defining Global Options

 

Global options allow you to modify Wimpy's default environment as well as default values for all players.

If you find yourself having to set the same options for each player, you may wish to "hard-code" the options rather than doing the same thing on every Player Instance.

Global options are established with a special variable named "wimpyConfigs". Wimpy will look for this variable when it first loads. If present, these default values will be applied.

The "wimpyConfigs" variable MUST:

• Exsist in the page BEFORE wimpy.js loads.
• Be a javascript object
• Be within the same scope (context) as the core wimpyplayer object.

 

Here is a complete wimpyConfigs object:

this.wimpyConfigs = {
	disableFlash : 1 	// 1 true = always use HTML5
					// 0 false = use flash only when available

	, defaultPlayer : {
					target			: null	// Target DIV's ID attribute
					, name			: null	// String human identifier, see wimpy.getPlayerByName
					, skin			: null	// URL
					, media			: null	// URL, JSON, or String
					, startUpText	: "Click To Play"
					, coverArt		: "coverart.jpg" // URL honored, single filename will look in Wimpy installation folder.
					, coverArtFit	: 1		// 1=fit exactly, 2=contain, 3 = original
					, width			: null	// Number
					, height		: null	// Number
					, autoPlay		: 0		// 0: off, 1: on (NOTE: Some devices don't allow autoPlay)
					, random		: 0		// 0: off, 1: on
					, sort			: null 	// "shuffle" or Any Media Item Object field as string
					, sortReverse	: 0 	// Reverse the sorting order Z-A
					, loop			: 0 	// 0: off, 1: loop track, 2: loop playlist
					, volume		: 1 	// Percent (0.0 to 1.0) 
					, infoSpeed		: 10 	// Pixels per second
					, infoScroll	: 1		// 0: off, 1: on
					, limitPlayTime : null	// Seconds
					, startOnTrack	: null	// Track number (e.g. 3 = 3rd track down)
					, autoAdvance	: 1		// 0: off, 1: on
					, downloadEnable: 0		// 0: off, 1: on
					, downloadWindow: null	// String (e.g. "_blank");
					, linkEnable	: 0		// 0: off, 1: on
					, linkWindow	: null	// String (e.g. "_blank");
					, inline		: 0		//  0: block, 1: inline-block + float left
					, timeFormat	: "1 / 3"	
					, infoFormat	: "1 - 2 - 3"
					, getid3		: 0		// 0 false, 1 true
					, getid3image	: 0		// 0 false, 1 true
					, plugPlaylist	: null	// URL
					, plugEvery		: 5		// Integer
					, plugFirst		: 0		// 0 false, 1 true
					, plugDisables	: 0		// 0 false, 1 true
					, disableControls : null// String (e.g."playlist, scrubber")
					, numberTracks	: 0		// 0 false, 1 true
					, glyphFile		: "f"	// See WimpyPlayerGlyphs-map.html
					, glyphList		: "F"	// See WimpyPlayerGlyphs-map.html 
					, glyphDownload	: "D"	// See WimpyPlayerGlyphs-map.html
					, glyphLink		: "i"	// See WimpyPlayerGlyphs-map.html
				}

	, server 				: "wimpy.php"
	, mainPlayControls 		: "play,stop,pause,rewind,next,playlist,scrubber,coverPlayPause" // Used for player.enableControls( false )
	, glyphFamily 			: "WimpyPlayerGlyphs"
	, glyphCssFile 			: "WimpyPlayerGlyphs.css"
	, flashFallbackFile 	: "WimpyFlashFallback.swf"
	, fallbackExtensions 	: {audio:"mp3,ogg,wav",video:"webm"}
	, fallbackSkin 			: 'SKIN_AS_RAW_JSON_STRING'
	, assetsPath 			: null 	// Be very careful with this! Generally, 
									// wimpy will set this up to the the same folder that contains the wimpy.js file  (with trailing slash)
}

 

Global options can be set in one of two ways:

1In a <script> that preceeds the reference to wimpy.js

<!-- Wimpy Global Configs -->
<!--IMPORTANT: Must be before Wimpy Engine. -->
<script>
// NOTE: A comma is used to seperate options value-pairs. Placing the 
// comma in front of each item is simply a matter of coding style. 
this.wimpyConfigs = {
    maxGoogleFeedItems : 100
    , fallbackExtensions : {audio:"ogg,webm",video:"webm"}
};
</script>

<!-- Wimpy Engine -->
<!-- IMPORTANT: Must be after wimpyConfigs. -->
<script src="/wimpy/wimpy.js"></script>
                      

 

An alternative method for writing the configs object:

<!-- Wimpy Global Configs -->
<!--IMPORTANT: Must be before Wimpy Engine. -->
<script>
this.wimpyConfigs = {};
this.wimpyConfigs.maxGoogleFeedItems = 100;
this.wimpyConfigs.fallbackExtensions = {audio:"ogg,webm",video:"webm"}; </script> <!-- Wimpy Engine --> <!-- IMPORTANT: Must be after wimpyConfigs. --> <script src="/wimpy/wimpy.js"></script>

 

 

 

 

2Written directly into wimpy.js

Open wimpy.js with a text editor and add the following to the top of the file:

// --- Insert wimpyConfigs Object here  ----
this.wimpyConfigs = { maxGoogleFeedItems : 100, // Comma seperates configs fallbackExtensions : {audio:"ogg,webm",video:"webm"} // No comma after last item. };
// // WW WW WW // WW WW WW // WW WW WW // WWWWWWWW // __ __ _ _ _ __ _ __ _ _ // \ V V / | , , | __ \ V | // \_/\_/|_|_|_|_| .__/\_, | // |_| |___| // ----------------------------------

... the rest of the stuff...

 

 

Notes on Scope

To ensure the wimpyConfigs variable is within the same scope as the core wimpyplayer object, rather that establishing a traditional var, use "this" instead.

For example, a traditional var would be established as:

var wimpyConfigs = {};    // may or may not work!

This usually places the variable into the WINDOW object of the page. However, when Wimpy loads, we define the main wimpyplayer object with "this" in order to overcome some issues related to iframes and frames and other issues. Hence, the main wimpyplayer object is defined in the "this" object, so when establshing the wimpyConfigs variable, you shouls also use "this" as:

this.wimpyConfigs = {};    // no "var" in front

 

 

Available Global Options

Option Description

defaultPlayer

An object that contains the default values for players. This object can be populated to allow all players to "take on" the same settings, thereby eliminating the need to configure indiviual players.

This information is used as a base-line when creating new players (either via HTML or via Javascript). When an option doesn't exist when establishing a player, Wimpy will use the values contained in this "defaultPlayer".

So for example, if all you players use the same skin, you can define the "skin" field in the defaultPlayer, then when establishing your player, you'll no longer have to set the "skin" option because Wimpy will "default" to usign the value contained in this defaultPlayer field.

disableFlash

The default is 0, which allows Wimpy to automatically detect if the browser supports Flash and when a browser is incapable of playing back certain kinds of media files. For example, Firefox can't play mp4 video files "natively", hence Wimpy will use Flash in Firefox when attempting to player mp4 video files.

When this option is set to 1 (or true), Wimpy will never use Flash, and only playback medai using a browser's native capabilities (e.g. HTML-5). This is a good option because the native media playback offers a higher level of performance. However, Wimpy may not work for some users who are using an older browser, or a browser that doesn't support certain kinds of media files.

server

The file to use when players are running in "automatic playlist" mode. (When no "media" option is established).

glyphFamily

The CSS-style "font-family" string used to identify the icon character fonts.

glyphCssFile

The CSS base file name to use to represent icons on buttons and widgets.

flashFallbackFile

The base file name to use for the Adobe Flash fallback file. just use a filename here, as Wimpy automatically looks for the file in the same location as the wimpy.js file (the Wimpy installation folder).

mainPlayControls

The controls that Wimpy will disable when player.enableControls( false ) is called.

fallbackExtensions

Extensions to use for "fallback files" in case the primary media file extension does not work with a browser's native playback engine. This option is only valid if a browser is using the native controls, which is determined by Wimpy.

When a media file is requested for playback, Wimpy will first try and load the file as specified in the playlist "as is", if the browser can't handle the file, Wimpy will make a new request by modifying the original file's URL by replacing the extension with those contained in this "fallbackExtensions" list. Wimpy will run through the list (in the same sequential order specified) until an acceptable file kind is discovered.

To leverage this functionality, you'll need to have multiple files in the same location as the original file.

For example, if your original requested file is:

foo.mp3

... additional files need to exist, encoded accordingly as:

foo.mp3 <-- the original
foo.webm <-- next check
foo.ogg <-- next...
foo.bar <-- next...
... etc...

To modify the list, seperate each extension with a comma. For example, below we've added "foo" and "bar" to both the audio list and the video list

{audio:"ogg,webm,foo,bar", video:"webm,foo,bar"}

maxGoogleFeedItems Wimpy uses the Google Feed API to parse Podcasts. By default wimpy requests 12 items for each podcast. You can change (reduce or increase) the number of items returned for each Podcast by modifying this value.

 

See Also

- Scope