Skip to content

Commit

Permalink
Customized the Flash ContextMenu, hiding defaults and adding jPlayer …
Browse files Browse the repository at this point in the history
…version.
  • Loading branch information
thepag committed Aug 9, 2011
1 parent 39d633a commit 162361f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
38 changes: 32 additions & 6 deletions actionscript/Jplayer.as
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@
* - http://www.gnu.org/copyleft/gpl.html
*
* Author: Mark J Panaghiston
* Version: 2.0.29
* Date: 8th August 2011
* Version: 2.0.32
* Date: 9th August 2011
*
* FlashVars expected: (AS3 property of: loaderInfo.parameters)
* id: (URL Encoded: String) Id of jPlayer instance
* vol: (Number) Sets the initial volume
* muted: (Boolean in a String) Sets the initial muted state
* jQuery: (URL Encoded: String) Sets the jQuery var name. Used with: someVar = jQuery.noConflict(true);
*
* Compiled using: Adobe Flash CS4 Professional
* Jplayer.fla
* Compiled using: Adobe Flex Compiler (mxmlc) Version 4.5.1 build 21328
*/

package {
Expand All @@ -41,6 +40,12 @@ package {
import flash.events.Event;
import flash.events.MouseEvent;

import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;
import flash.events.ContextMenuEvent;
import flash.net.URLRequest;
import flash.net.navigateToURL;

public class Jplayer extends Sprite {
private var jQuery:String;
private var sentNumberFractionDigits:uint = 2;
Expand Down Expand Up @@ -82,6 +87,19 @@ package {

setupListeners(!isMp3, isMp3); // Set up the listeners to the default isMp3 state.

// The ContextMenu only partially works. The menu select events never occur.
// Investigated and it is something to do with the way jPlayer inserts the Flash on the page.
// A simple test inserting the Jplayer.swf on a page using: 1) SWFObject 2.2 works. 2) AC_FL_RunContent() works.
// jPlayer Flash insertion is based on SWFObject 2.2 and the resaon behind this failure is not clear. The Flash insertion HTML on the page looks similar.
var myContextMenu:ContextMenu = new ContextMenu();
myContextMenu.hideBuiltInItems();
var menuItem_jPlayer:ContextMenuItem = new ContextMenuItem("jPlayer " + JplayerStatus.VERSION);
var menuItem_happyworm:ContextMenuItem = new ContextMenuItem("© 2009-2011 Happyworm Ltd", true);
menuItem_jPlayer.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuSelectHandler_jPlayer);
menuItem_happyworm.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuSelectHandler_happyworm);
myContextMenu.customItems.push(menuItem_jPlayer, menuItem_happyworm);
contextMenu = myContextMenu;

// Log console for dev compile option: debug
if(debug) {
txLog = new TextField();
Expand Down Expand Up @@ -298,7 +316,7 @@ package {
}
}
private function extractStatusData(data:JplayerStatus):Object {
var myStatus = {
var myStatus:Object = {
version: JplayerStatus.VERSION,
src: data.src,
paused: !data.isPlaying, // Changing this name requires inverting all assignments and conditional statements.
Expand Down Expand Up @@ -363,7 +381,15 @@ package {
jPlayerFlashEvent(new JplayerEvent(JplayerEvent.JPLAYER_CLICK, myMp4Player.myStatus, "click"))
}
}
private function log(t):void {
// This event is never called. See comments in class constructor.
private function menuSelectHandler_jPlayer(e:ContextMenuEvent):void {
navigateToURL(new URLRequest("http://jplayer.org/"), "_blank");
}
// This event is never called. See comments in class constructor.
private function menuSelectHandler_happyworm(e:ContextMenuEvent):void {
navigateToURL(new URLRequest("http://happyworm.com/"), "_blank");
}
private function log(t:String):void {
if(debug) {
txLog.text = t + "\n" + txLog.text;
}
Expand Down
4 changes: 2 additions & 2 deletions actionscript/happyworm/jPlayer/JplayerStatus.as
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
* - http://www.gnu.org/copyleft/gpl.html
*
* Author: Mark J Panaghiston
* Date: 8th August 2011
* Date: 9th August 2011
*/

package happyworm.jPlayer {
public class JplayerStatus {

public static const VERSION:String = "2.0.29"; // The version of the Flash jPlayer entity.
public static const VERSION:String = "2.0.32"; // The version of the Flash jPlayer entity.

public var volume:Number = 0.5; // Not affected by reset()
public var muted:Boolean = false; // Not affected by reset()
Expand Down
Binary file modified jquery.jplayer/Jplayer.swf
Binary file not shown.
10 changes: 5 additions & 5 deletions jquery.jplayer/jquery.jplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* - http://www.gnu.org/copyleft/gpl.html
*
* Author: Mark J Panaghiston
* Version: 2.0.31
* Date: 8th August 2011
* Version: 2.0.32
* Date: 9th August 2011
*/

/* Code verified using http://www.jshint.com/ */
Expand Down Expand Up @@ -233,8 +233,8 @@
$.jPlayer.prototype = {
count: 0, // Static Variable: Change it via prototype.
version: { // Static Object
script: "2.0.31",
needFlash: "2.0.29",
script: "2.0.32",
needFlash: "2.0.32",
flash: "unknown"
},
options: { // Instanced in $.jPlayer() constructor
Expand Down Expand Up @@ -703,7 +703,7 @@
htmlObj = document.createElement("object");
htmlObj.setAttribute("id", this.internal.flash.id);
htmlObj.setAttribute("data", this.internal.flash.swf);
htmlObj.setAttribute("type", "application/x-shockwave-flash"); // Note: This line causes a security error when used with iframes.
htmlObj.setAttribute("type", "application/x-shockwave-flash");
htmlObj.setAttribute("width", "1"); // Non-zero
htmlObj.setAttribute("height", "1"); // Non-zero
createParam(htmlObj, "flashvars", flashVars);
Expand Down

0 comments on commit 162361f

Please sign in to comment.