diff --git a/t3lib/js/flowplayer/express-install.css b/t3lib/js/flowplayer/express-install.css new file mode 100644 index 0000000000000000000000000000000000000000..ea0fc666a324e7ae939fd470561f85138a6906ba --- /dev/null +++ b/t3lib/js/flowplayer/express-install.css @@ -0,0 +1,7 @@ +/* Selector for Flash express install div section*/ + +.flash-install-info div { + padding-top: 105px; + background-image: url("flashplayerlogo.jpg"); + background-repeat: no-repeat; +} \ No newline at end of file diff --git a/t3lib/js/flowplayer/flashplayerlogo.jpg b/t3lib/js/flowplayer/flashplayerlogo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..594a8bba60a0946bc29d41a245e6869f7cb47709 Binary files /dev/null and b/t3lib/js/flowplayer/flashplayerlogo.jpg differ diff --git a/t3lib/js/videojs/audio-description.js b/t3lib/js/videojs/audio-description.js new file mode 100644 index 0000000000000000000000000000000000000000..6d94c5cb695d9ad1895c770d639f12f5f380624a --- /dev/null +++ b/t3lib/js/videojs/audio-description.js @@ -0,0 +1,64 @@ +/*************************************************************** + * Copyright notice + * + * (c) 2011 Stanislas Rolland <typo3@sjbr.ca> + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * A copy is found in the textfile GPL.txt and important notices to the license + * from the author is found in LICENSE.txt distributed with these scripts. + * + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ +/* Audio description Toggle Behaviors for videoJS */ +VideoJS.player.newBehavior("audioDescriptionToggle", function(element) { + _V_.addListener(element, "click", this.onAudioDescriptionToggleClick.context(this)); + },{ + // When the user clicks on the audioDesription button, update audioDesription state + onAudioDescriptionToggleClick: function(event) { + if (this.audioDescriptionEnabled) { + this.disableAudioDescription(); + } else { + this.enableAudioDescription(); + } + } + } +); +VideoJS.player.extend({ + // Audio description state variable + audioDescriptionEnabled: false, + // Reference to the audio description audio element + audioDescription: null, + // Enable audio description + enableAudioDescription: function (event) { + // Set reference if not yet done + if (!this.audioDescription) { + var id = this.video.id.replace("video_js", "audio_element"); + this.audioDescription = document.getElementById(id); + } + if (this.audioDescription && this.audioDescription.nodeName == 'AUDIO') { + this.audioDescription.muted = false; + this.audioDescriptionEnabled = true; + } + }, + // Disable audio description + disableAudioDescription: function (event) { + if (this.audioDescription && this.audioDescription.nodeName == 'AUDIO') { + this.audioDescription.muted = true; + this.audioDescriptionEnabled = false; + } + } +}); \ No newline at end of file diff --git a/t3lib/js/videojs/audio-description.png b/t3lib/js/videojs/audio-description.png new file mode 100644 index 0000000000000000000000000000000000000000..2150c5ddb642b4c3387442fd1cec420f2f5f2069 Binary files /dev/null and b/t3lib/js/videojs/audio-description.png differ diff --git a/t3lib/js/videojs/captions.js b/t3lib/js/videojs/captions.js new file mode 100644 index 0000000000000000000000000000000000000000..38e35c4c75117be5da0f4241bb489d34d6d29ea5 --- /dev/null +++ b/t3lib/js/videojs/captions.js @@ -0,0 +1,59 @@ +/*************************************************************** + * Copyright notice + * + * (c) 2011 Stanislas Rolland <typo3@sjbr.ca> + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * A copy is found in the textfile GPL.txt and important notices to the license + * from the author is found in LICENSE.txt distributed with these scripts. + * + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ +/* Captions Toggle Behaviors for videoJS */ +VideoJS.player.newBehavior("captionsToggle", + function(element) { + _V_.addListener(element, "click", this.onCaptionsToggleClick.context(this)); + },{ + // When the user clicks on the subtitles button, update subtitles setting + onCaptionsToggleClick: function(event) { + if (this.subtitlesDisplay.style.visibility != "hidden") { + this.hideCaptions(); + } else { + this.showCaptions(); + } + } + } +); +VideoJS.player.extend({ + // Override to use captions kind of track rather than subtitles + getSubtitles: function(){ + var tracks = this.video.getElementsByTagName("TRACK"); + for (var i=0,j=tracks.length; i<j; i++) { + if (tracks[i].getAttribute("kind") == "captions" && tracks[i].getAttribute("src")) { + this.subtitlesSource = tracks[i].getAttribute("src"); + this.loadSubtitles(); + this.buildSubtitles(); + } + } + }, + showCaptions: function (event) { + this.subtitlesDisplay.style.visibility = "visible"; + }, + hideCaptions: function (event) { + this.subtitlesDisplay.style.visibility = "hidden"; + } +}); \ No newline at end of file diff --git a/t3lib/js/videojs/captions.png b/t3lib/js/videojs/captions.png new file mode 100644 index 0000000000000000000000000000000000000000..33a56b1fa0aa8e0f8dcdc0262532f9c05e96e8e9 Binary files /dev/null and b/t3lib/js/videojs/captions.png differ diff --git a/t3lib/js/videojs/control-bar.css b/t3lib/js/videojs/control-bar.css new file mode 100644 index 0000000000000000000000000000000000000000..abfc66a6a8ed7ae45ea446f721c433438f7d1df2 --- /dev/null +++ b/t3lib/js/videojs/control-bar.css @@ -0,0 +1,27 @@ +/* Placement of Control Items + - Left side of pogress bar, use left & width + - Rigth side of progress bar, use right & width + - Expand with the video (like progress bar) use left & right */ +.vjs-controls > div.vjs-play-control { left: 5px; width: 25px; } +.vjs-controls > div.vjs-progress-control { left: 35px; right: 221px; } /* Using left & right so it expands with the width of the video */ +.vjs-controls > div.vjs-time-control { width: 75px; right: 156px; } /* Time control and progress bar are combined to look like one */ +.vjs-controls > div.vjs-volume-control { width: 50px; right: 101px; } +.vjs-controls > div.vjs-captions-control { width: 31px; right: 65px; } +.vjs-controls > div.vjs-audio-description-control { width: 25px; right: 35px; } +.vjs-controls > div.vjs-fullscreen-control { width: 25px; right: 5px; } + /* Sub titles toggle*/ +.vjs-captions-control div { cursor: pointer !important; } +.vjs-captions-control div { + padding: 0; text-align: left; vertical-align: top; cursor: pointer !important; + margin: 5px 0 0 5px; /* Placement within the fullscreen control item */ + width: 20px; height: 20px; +} +.vjs-captions-control div { background-image: url("captions.png"); background-repeat:no-repeat; background-position: center center;} + /* Audio description toggle*/ +.vjs-audio-description-control div { cursor: pointer !important; } +.vjs-audio-description-control div { + padding: 0; text-align: left; vertical-align: top; cursor: pointer !important; + margin: 5px 0 0 5px; /* Placement within the fullscreen control item */ + width: 20px; height: 20px; +} +.vjs-audio-description-control div { background-image: url("audio-description.png"); background-repeat:no-repeat; } \ No newline at end of file diff --git a/t3lib/js/videojs/control-bar.js b/t3lib/js/videojs/control-bar.js new file mode 100644 index 0000000000000000000000000000000000000000..1af1f7b24012651dc401b9184754535c06d9ac64 --- /dev/null +++ b/t3lib/js/videojs/control-bar.js @@ -0,0 +1,166 @@ +/*************************************************************** + * Copyright notice + * + * (c) 2011 Stanislas Rolland <typo3@sjbr.ca> + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * A copy is found in the textfile GPL.txt and important notices to the license + * from the author is found in LICENSE.txt distributed with these scripts. + * + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ +/* Extended control bar for videoJS */ +VideoJS.player.extend({ + /* Control Bar override to add the subtitles control + ================================================================================ */ + buildAndActivateControlBar: function(){ + /* Creating this HTML + <div class="vjs-controls"> + <div class="vjs-play-control"> + <span></span> + </div> + <div class="vjs-progress-control"> + <div class="vjs-progress-holder"> + <div class="vjs-load-progress"></div> + <div class="vjs-play-progress"></div> + </div> + </div> + <div class="vjs-time-control"> + <span class="vjs-current-time-display">00:00</span><span> / </span><span class="vjs-duration-display">00:00</span> + </div> + <div class="vjs-volume-control"> + <div> + <span></span><span></span><span></span><span></span><span></span><span></span> + </div> + </div> + <div class="vjs-subtitles-control"> + <div> + <span></span><span></span><span></span><span></span> + </div> + </div> + <div class="vjs-audio-description-control"> + <div> + <span></span><span></span><span></span><span></span> + </div> + </div> + <div class="vjs-fullscreen-control"> + <div> + <span></span><span></span><span></span><span></span> + </div> + </div> + </div> + */ + + // Create a div to hold the different controls + this.controls = _V_.createElement("div", { className: "vjs-controls" }); + // Add the controls to the video's container + this.box.appendChild(this.controls); + this.activateElement(this.controls, "controlBar"); + this.activateElement(this.controls, "mouseOverVideoReporter"); + + // Build the play control + this.playControl = _V_.createElement("div", { className: "vjs-play-control", innerHTML: "<span></span>" }); + this.controls.appendChild(this.playControl); + this.activateElement(this.playControl, "playToggle"); + + // Build the progress control + this.progressControl = _V_.createElement("div", { className: "vjs-progress-control" }); + this.controls.appendChild(this.progressControl); + + // Create a holder for the progress bars + this.progressHolder = _V_.createElement("div", { className: "vjs-progress-holder" }); + this.progressControl.appendChild(this.progressHolder); + this.activateElement(this.progressHolder, "currentTimeScrubber"); + + // Create the loading progress display + this.loadProgressBar = _V_.createElement("div", { className: "vjs-load-progress" }); + this.progressHolder.appendChild(this.loadProgressBar); + this.activateElement(this.loadProgressBar, "loadProgressBar"); + + // Create the playing progress display + this.playProgressBar = _V_.createElement("div", { className: "vjs-play-progress" }); + this.progressHolder.appendChild(this.playProgressBar); + this.activateElement(this.playProgressBar, "playProgressBar"); + + // Create the progress time display (00:00 / 00:00) + this.timeControl = _V_.createElement("div", { className: "vjs-time-control" }); + this.controls.appendChild(this.timeControl); + + // Create the current play time display + this.currentTimeDisplay = _V_.createElement("span", { className: "vjs-current-time-display", innerHTML: "00:00" }); + this.timeControl.appendChild(this.currentTimeDisplay); + this.activateElement(this.currentTimeDisplay, "currentTimeDisplay"); + + // Add time separator + this.timeSeparator = _V_.createElement("span", { innerHTML: " / " }); + this.timeControl.appendChild(this.timeSeparator); + + // Create the total duration display + this.durationDisplay = _V_.createElement("span", { className: "vjs-duration-display", innerHTML: "00:00" }); + this.timeControl.appendChild(this.durationDisplay); + this.activateElement(this.durationDisplay, "durationDisplay"); + + // Create the volumne control + this.volumeControl = _V_.createElement("div", { + className: "vjs-volume-control", + innerHTML: "<div><span></span><span></span><span></span><span></span><span></span><span></span></div>" + }); + this.controls.appendChild(this.volumeControl); + this.activateElement(this.volumeControl, "volumeScrubber"); + + this.volumeDisplay = this.volumeControl.children[0]; + this.activateElement(this.volumeDisplay, "volumeDisplay"); + + // Create the captions control + this.captionsControl = _V_.createElement("div", { + className: "vjs-captions-control", + innerHTML: "<div><span></span><span></span><span></span><span></span></div>" + }); + this.controls.appendChild(this.captionsControl); + // Hide the control if there are no tracks + var tracks = this.video.getElementsByTagName("TRACK"); + if (tracks.length) { + this.activateElement(this.captionsControl, "captionsToggle"); + } else { + this.captionsControl.style.display = "none"; + } + + // Create the audio description control + this.audioDescriptionControl = _V_.createElement("div", { + className: "vjs-audio-description-control", + innerHTML: "<div><span></span><span></span><span></span><span></span></div>" + }); + // Look for the audio description associated with this video element + // We could look for audio with same mediagroup... + var id = this.video.id.replace("video_js", "audio_element"); + var audioDescription = document.getElementById(id); + if (!!audioDescription) { + this.controls.appendChild(this.audioDescriptionControl); + this.activateElement(this.audioDescriptionControl, "audioDescriptionToggle"); + } else { + this.audioDescriptionControl.style.display = "none"; + } + + // Crete the fullscreen control + this.fullscreenControl = _V_.createElement("div", { + className: "vjs-fullscreen-control", + innerHTML: "<div><span></span><span></span><span></span><span></span></div>" + }); + this.controls.appendChild(this.fullscreenControl); + this.activateElement(this.fullscreenControl, "fullscreenToggle"); + } +}); \ No newline at end of file diff --git a/typo3/contrib/flowplayer/LICENSE-exception.txt b/typo3/contrib/flowplayer/LICENSE-exception.txt new file mode 100644 index 0000000000000000000000000000000000000000..2b4b6332975f42e7dbe3d6041ce82708df2a9bff --- /dev/null +++ b/typo3/contrib/flowplayer/LICENSE-exception.txt @@ -0,0 +1,23 @@ +Return-Path: <anssip@gmail.com> +Message-ID: <4EB24F4B.9010707@gmail.com> +Date: Thu, 03 Nov 2011 10:22:35 +0200 +From: Anssi Piirainen <anssip@gmail.com> +To: Oliver Hader <oliver.hader@typo3.org> +CC: info@flowplayer.org +Subject: Re: Flowplayer: Question on GPLv3/GPLv2 FLOSS Exception +References: <4EB12708.8030406@typo3.org> +In-Reply-To: <4EB12708.8030406@typo3.org> + + +Hi Oliver, + +You can use our Free version that is under our GPL 2 based license. You +have my blessing for this and you can archive this email for any future +needs. + +Let me know if you need something more from us. I think it would make +sense for us to include this kind of exception in our website, just like +Sencha does. + +Regards, +Anssi diff --git a/typo3/contrib/flowplayer/LICENSE.txt b/typo3/contrib/flowplayer/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..2a00962f22935d2719aea860183914ffb62a6486 --- /dev/null +++ b/typo3/contrib/flowplayer/LICENSE.txt @@ -0,0 +1,721 @@ +The Flowplayer Free version is released under the +GNU GENERAL PUBLIC LICENSE Version 3 (GPL). + +The GPL requires that you not remove the Flowplayer copyright notices +from the user interface. See section 5.d below. + +Commercial licenses are available. The commercial player version +does not require any Flowplayer notices or texts and also provides +some additional features. + +======================================================================== + +ADDITIONAL TERM per GPL Section 7 +If you convey this program (or any modifications of it) and assume +contractual liability for the program to recipients of it, you agree +to indemnify Flowplayer, Ltd. for any liability that those contractual +assumptions impose on Flowplayer, Ltd. + +Except as expressly provided herein, no trademark rights are granted in +any trademarks of Flowplayer, Ltd. Licensees are granted a limited, +non-exclusive right to use the mark Flowplayer and the Flowplayer logos +in connection with unmodified copies of the Program and the copyright +notices required by section 5.d of the GPL license. For the purposes +of this limited trademark license grant, customizing the Flowplayer +by skinning, scripting, or including PlugIns provided by Flowplayer, Ltd. +is not considered modifying the Program. + +Licensees that do modify the Program, taking advantage of the open-source +license, may not use the Flowplayer mark or Flowplayer logos and must +change the fullscreen notice (and the non-fullscreen notice, if that +option is enabled), the copyright notice in the dialog box, and the +notice on the Canvas as follows: + +the full screen (and non-fullscreen equivalent, if activated) notice +should read: "Based on Flowplayer source code"; in the context menu +(right-click menu), the link to "About Flowplayer free version #.#.#" +can remain. The copyright notice can remain, but must be supplemented with +an additional notice, stating that the licensee modified the Flowplayer. +A suitable notice might read "Flowplayer Source code modified by ModOrg 2009"; +for the canvas, the notice should read "Based on Flowplayer source code". +In addition, licensees that modify the Program must give the modified +Program a new name that is not confusingly similar to Flowplayer and +may not distribute it under the name Flowplayer. + +======================================================================== + + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. \ No newline at end of file diff --git a/typo3/contrib/flowplayer/README.txt b/typo3/contrib/flowplayer/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..4609c6d7c70cb7774c443a7e81877f16b20b0297 --- /dev/null +++ b/typo3/contrib/flowplayer/README.txt @@ -0,0 +1,350 @@ +Version history: + +3.2.7 +----- + +- Loads the new controlbar plugin version 3.2.5. No other functional changes. + +3.2.6 +----- +- linkUrl should now work better with popup blockers: http://code.google.com/p/flowplayer-core/issues/detail?id=31 +- new linkWindow value "_popup" opens the linked page in a popup browser window +- added new onClipResized event +- Added new onUnload event, can be only listened in Flash and not triggered to JS +- API: Added new url property to plugin objects +Fixes: +- it was not possible to call play() in an onFinish listener +- fix to preserve the infoObject for custom netStream and netConnection clients in cases where the infoObject is a + primitive object without properties +- does not show the error dialog in the debugger player when showErrors: false +- fixed to correctly handle xx.ca subdomains when validating the license key +- a custom logo is now sized correctly according to the configured size +- does not show the buffer animation any more when the player receives the onBufferEmpty message from the netStream. + The animation was unnecessarily shown in some situations. +- fixed #155. added new urlEncoding property to Clip for url ncoding ut8 urls + +3.2.5 +----- +- added new scaling option 'crop' that resizes to fill all available space, cropping on top/bottom or left/right +- improvements to RSS file parsing +- Now displays a hand cursor when a linkUrl is used in clips + +3.2.4 +----- +- new flowplayer.js version, with Apple iDevice fixes + +3.2.3 +----- +- a new 'type' clip property exposed to JS +- changed the clip type property to better work as a read-write property. Now accepts 'video', 'audio', + 'image' and 'api' as configuration values. +- moved parallel rtmp connection mechanism from the RTMP plugin to Core so other plugins can use it (ie: securestreaming) +Fixes: +- fixed #112, wrong URL computation when using clip with relative URL on a page with a / after a # in its url +- fixed #111, wrong behavior of pre/post roll images with duration 0 +- fixed multiple license keys logic +Fixes: +- correct verification of license keys in *.ca domains +- fix to make playback to always reach end of video +- fixed resuming of live streams + +3.2.2 +----- +Fixes: +- Now recognizes following kind of urls as audio clips: 'mp3:audiostreamname' (ulrs with mp3 prefix and no extension) +- Now ignores the duration from metadata if we already got one. Fix required for pseudostreaming +- Fix to reuse buffered data when replaying a clip + +3.2.1 +--------- +- Support for RTMP redirects (tested with Wowza loadbalancing) +- Fixed video size when no size info available in clip metadata + +Fixes: +- Fix to correctly detect if the player SWF name contains a version number and if it does also use the version number +when it automatically loads the controls plugin. + +3.2.0 +----- +- canvas, controlbar and the content plugin backgound color and border color can be now given with rgb() and rgba() CSS style syntax +- Added onMouseOver() and onMouseOut() listener registration methods to the Flowplayer API +- enhancements to RSS playlist. Converted parsing to E4X, yahoo media and flowplayer namespace support. +- added feature to obtain bitrate and dimension information to a new clip custom property "bitrates" for future support for bitrate choosing. +- added getter for playerSwfName config +- if clip.url has the string "mp3:" in it, the clip.type will report 'audio' +- added setKeyboardShortcutsEnabled(), addKeyListener(), removeKeyListener() to FlowplayerBase +Fixes: +- onSeek() was not fired when seeking while paused and when using RTMP. An extra onStart was fired too. +- fireErrorExternal() was not working properly with an error PlayerEvent +- countPlugins() was throwing an error when a plugin was not found +- external swf files were not scaled properly +- the logo was unnecessary shown when going fullscreen if logo.displayTime was being used +- added a loadPluginWithConfig method to FlowplayerBase, accessible from javascript. Fixed double onload callback call. +- now handles cuepoint parameters injected using the Adobe Media Encoder +- showPlugin was not working when config.play was null +- handles 3-part duration values included in FLV metadata, like "500.123.123" +- player wasn't always reaching end of video +- fixed broken buffering: false +- fixed event dispatching when embedding flowplayer without flowplayer.js (=without playlist config field) +- fixed safari crashes when unloading player +- fixed scrubber behaviour with a playlist containing 2 images (or swf) in a row +- fixed errors in logs when using an RSS playlist +- fixed OverlayPlayButton that was showing even if it shouldn't on some cases +- fixed wrong behavior when onBeforeFinish was returning false within playlists +- /!\ Don't use the fadeIn / fadeOut controlbar's API while using autoHide. +- fixed play state button with images +- fixed splash image flickering + +3.1.5 +----- +Fixes: +- The player went to a locked state when resuming playback after a period that was long enought to send the +netConnection to an invalid state. Now when resuming playback on an invalid connection the clip starts again from +the beginning. This is only when using RTMP connections and does not affect progressive download playback. +- Custom netConnect and netStream events did not pass the info object to JS listeners + +3.1.4 +----- +Fixes: +- player did not initialize if the controlbar plugin was disabled and if the play button overlay was disabled with play: null +- works properly without cachebusting on IE +- RSS playlist parsing now respects the isDefault attribute used in mRSS media group items +- Fixed passing of connection arguments + +3.1.3 +----- +- enhancements to RSS playlist parsing: Now skips all media:content that have unsupported types. Now the type attribute +of the media:content element is mandatory and has to be present in the RSS file +- Possibility to pass a RSS file name with playFeed("playlist.rss") and setPlaylist("playlist.rss") calls. +- changes to the ConnectionProvider and URLResolver APIs +- Now automatically uses a plugin that is called 'rtmp' for all clips that have the rtmp-protocol in their URLs. +- Added possibility to specify all clip properties in an RSS playlist + +Fixes: +- the result of URL resolvers in now cached, and the resolvers will not be used again when a clip is replayed +- some style properties like 'backgroundGradient' had no effect in config +- video goes tiny on Firefox: http://flowplayer.org/forum/8/23226 +- RSS playlists: The 'type' attribute value 'audio/mp3' in the media:content element caused an error. +- Dispatches onMetadata() if an URL resolver changes the clip URL (changes to a different file) +- error codes and error message were not properly passed to onEvent JS listeners + +3.1.2 +----- +- The domain of the logo url must the same domain from where the player SWF is loaded from. +- Fullscreen can be toggled by doublclick on the video area. +Fixes: +- Player was not initialized correctly when instream playlists were used and the provider used in the instream clips was defined in the common clip. +- A separator in the Context Menu made the callbacks in the following menu items out of order. Related forum post: http://flowplayer.org/forum/8/22541 +- the width and height settings of a logo were ignored if the logo was a sWF file +- volume control and mute/unmute were not working after an instream clip had been played +- now possible to use RTMP for mp3 files +- Issue 12: cuepointMultiplier was undefined in the clip object set to JS event listeners +- Issue 14: onBeforeStop was unnecessarily fired when calling setPlaylist() and the player was not playing, + additionally onStop was never fired even if onBeforeStop was +- fixed screen vertical placement problems that reappeared with 3.1.1 +- The rotating animation now has the same size and position as it has after initialized + +3.1.1 +----- +- External configuration files +- Instream playback +- Added toggleFullscreen() the API +- Possibility to specify controls configuration in clips +- Seek target position is now sent in the onBeforeSeek event +Fixes: +- The screen size was initially too small on Firefox (Mac) +- Did not persist a zero volume value: http://www.flowplayer.org/forum/8/18413 + +3.1.0 +----- +New features: +- clip's can have urlResolvers and connectionProviders +- Added new configuration options 'connectionCallbacks' and 'streamCallbacks'. Both accept an Array of event names as a value. + When these events get fired on the connection or stream object, corresponding Clip events will be fired by the player. + This can be used for example when firing custom events from RTMP server apps +- Added new clip event types: 'onConnectionEvent' and 'onStreamEvent' these get fired when the predefined events happen on the connection and stream objects. +- Added Security.allowDomain() to allow loaded plugins to script the player +- Added addClip(clip, index) to the API, index is optional +- Possibility to view videos without metadata, using clip.metaData: false +- Now the player's preloader uses the rotating animation instead of a percent text to indicate the progress + of loading the player SWF. You can disable the aninamtion by setting buffering: false +- calling close() now does not send the onStop event +- Clip's custom properties are now present in the root of the clip argument in all clip events that are sent to JS. + +Bug fixes: +- The preloader sometimes failed to initialize the player +- Allow seeking while in buffering state: http://flowplayer.org/forum/8/16505 +- Replay of a RTMP stream was failing after the connection had expired +- Security error when clicking on the screen if there is an image in the playlist loaded from a foreign domain +- loadPlugin() was not working +- now fullscreen works with Flash versions older than 9.0.115, in versions that do not support hardware scaling +- replaying a RTMP stream with an image in front of the stream in the playlist was not working (video stayed hidden). Happened + because the server does not send metadata if replaying the same stream. +- the scrubber is disabled if the clip is not seekable in the first frame: http://flowplayer.org/forum/8/16526 + By default if the clip has one of following extensions (the typical flash video extensions) it is seekable + in the first frame: 'f4b', 'f4p', 'f4v', 'flv'. Added new clip property seekableOnBegin that can be used to override the default. + +3.0.6 +----- +- added possibility to associate a linkUrl and linkWindow to the canvas +Fixes: +- fix for entering fullscreen for Flash versions that don't support the hardware scaled fullscreen-mode +- when showing images the duration tracking starts only after the image has been completely loaded: http://flowplayer.org/forum/2/15301 +- fix for verifying license keys for domains that have more than 4 labels in them +- if plugin loading failis because of a IO error, the plugin will be discarded and the player initialization continues: + +3.0.4 +----- +- The "play" pseudo-plugin now supports fadeIn(), fadeOut(), showPlugin(), hidePlugin() and + additionally you can configure it like this: + // make only the play button invisible (buffering animation is still used) + play: { display: 'none' } + // disable the play button and the buffering animation + play: null + // disable the buffering animation + buffering: null +- Added possibility to seek when in the buffering state: http://flowplayer.org/forum/3/13896 +- Added copyright notices and other GPL required entries to the user interface + +Fixes: +- clip urls were not resolved correctly if the HTML page URL had a query string starting with a question mark (http://flowplayer.org/forum/8/14016#post-14016) +- Fixed context menu for with IE (commercial version) +- a cuepoint at time zero was fired several times +- screen is now arranged correctly even when only bottom or top is defined for it in the configuration +- Fixed context menu for with IE (commercial version) +- a cuepoint at time zero was fired several times +- screen is now arranged correctly even when only bottom or top is defined for it in the configuration +- Now possible to call play() in an onError handler: http://flowplayer.org/forum/8/12939 +- Does not throw an error if the player cannot persist the volume on the client computer: http://flowplayer.org/forum/8/13286#post-13495 +- Triggering fullscreen does not pause the player in IE +- The play button overlay no longer has a gap between it's pieces when a label is used: http://flowplayer.org/forum/8/14250 +- clip.update() JS call now resets the duration +- a label configured for the play button overlay did not work in the commercial version + +3.0.3 +----- +- fixed cuepoint firing: Does not skip cuepoints any more +- Plugins can now be loaded from a different domain to the flowplayer.swf +- Specifying a clip to play by just using the 'clip' node in the configuration was not working, a playlist definition was required. This is now fixed. +- Fixed: A playlist with different providers caused the onMetadata event to fire events with metadata from the previous clip in the playlist. Occurred when moving in the playlist with next() and prev() +- the opacity setting now works with the logo +- fadeOut() call to the "screen" plugin was sending the listenerId and pluginName arguments in wrong order +- stop(), pause(), resume(), close() no longer return the flowplayer object to JS +- changing the size of the screen in a onFullscreen listener now always works, there was a bug that caused this to fail occasionally +- fixed using arbitrary SWFs as plugins +- the API method setPlaylist() no longer starts playing if autoPlay: true, neither it starts buffering if autoBuffering: true +- the API method play() now accepts an array of clip objects as an argument, the playlist is replaced with the specified clips and playback starts from the 1st clip + +3.0.2 +----- +- setting play: null now works again +- pressing the play again button overlay does not open a linkUrl associated with a clip +- now displays a live feed even when the RTMP server does not send any metadata and the onStart method is not therefore dispatched +- added onMetaData clip event +- fixed 'orig' scaling: the player went to 'fit' scaling after coming back from fullscreen. This is now fixed and the original dimensions are preserved in non-fullscreen mode. +- cuepoint times are now given in milliseconds, the firing precision is 100 ms. All cuepoint times are rounded to the nearest 100 ms value (for example 1120 rounds to 1100) +- backgroundGradient was drawn over the background image in the canvas and in the content and controlbar plugins. Now it's drawn below the image. +- added cuepointMultiplier property to clips. This can be used to multiply the time values read from cuepoint metadata embedded into video files. +- the player's framerate was increased to 24 FPS, makes all animations smoother + +3.0.1 +----- +- Fixed negative cuepoints from common clip. Now these are properly propagated to the clips in playlist. +- buffering animation is now the same size as the play button overlay +- commercial version now supports license keys that allows the use of subdomains +- error messages are now automatically hidden after a 4 second delay. They are also hidden when a new clips + starts playing (when onBeforeBegin is fired) +- added possibility to disable the buffering animation like so: buffering: false +- pressing the play button overlay does not open a linkUrl associated with a clip +- license key verification failed if a port number was used in the URL (like in this url: http://mydomain.com:8080/video.html) +- added audio support, clip has a new "image" property +- workaround for missing "NetStream.Play.Start" notfication that was happending with Red5. Because of this issue the video was not shown. +- commercial version has the possibility to change the zIndex of the logo + +3.0.0 +----- +- Removed security errors that happened when loading images from foreign domains (domains other than the domain of the core SWF). + Using a backgroundImage on canvas, in the content plugin, and for the controls is also possible to be loaded + from a foreign domain - BUT backgroundRepeat cannot be used for foreign images. +- Now allows the embedding HTML to script the player even if the player is loaded from another domain. +- Added a 'live' property to Clips, used for live streams. +- A player embedded to a foreign domain now loads images, css files and other resources from the domain where the palyer SWF was loaded from. This is to generate shorter embed-codes. +- Added linkUrl and linkWindow properties to the logo, in commercial version you can set these to point to a linked page. The linked page gets opened + when the logo is clicked. Possible values for linkWindow: + * "_self" specifies the current frame in the current window. + * "_blank" specifies a new window. + * "_parent" specifies the parent of the current frame. + * "_top" specifies the top-level frame in the current window. +- Added linkUrl and linkWindow properties to clips. The linked page is opened when the video are is clicked and the corresponding clip has a linkUrl specified. +- Made the play button overlay and the "Play again" button slightly bigger. + +RC4 +--- +- Now shows a "Play again" button at the end of the video/playlist +- Commercial version shows a Flowplayer logo if invalidKey was supplied, but the otherwise the player works +- setting play: null in configuration will disable the play button overlay +- setting opacity for "play" also sets it for the buffering animation +- Fixed firing of cuepoints too early. Cuepoint firing is now based on stream time and does not rely on timers +- added onXMPData event listener +- Should not stop playback too early before the clip is really completed +- The START event is now delayed so that the metadata is available when the event is fired, METADATA event was removed, + new event BEGIN that is dispatched when the playback has been successfully started. Metadata is not normally + available when BEGIN is fired. + +RC3 +--- +- stopBuffering() now dispatches the onStop event first if the player is playing/paused/buffering at the time of calling it +- fixed detection of images based on file extensions +- fixed some issues with having images in the playlist +- made it possible to autoBuffer next video while showing an image (image without a duration) + +RC2 +--- +- fixed: setting the screen height in configuration did not have any effect + +RC1 +----- +- better error message if plugin loading fails, shows the URL used +- validates our redesigned multidomain license key correctly +- fix to prevent the play button going visible when the onBufferEmpty event occurs +- the commercial swf now correctly loads the controls using version information +- fixed: the play button overlay became invisible with long fadeOutSpeeds + +beta6 +----- +- removed the onFirstFramePause event +- playing a clip for the second time caused a doubled sound +- pausing on first frame did not work on some FLV files + +beta5 +----- +- logo only uses percentage scaling if it's a SWF file (there is ".swf" in it's url) +- context menu now correctly builds up from string entries in configuration +-always closes the previous connection before starting a new clip + +beta4 +----- +- now it's possible to load a plugin into the panel without specifying any position/dimensions + information, the plugin is placed to left: "50%", top: "50%" and using the plugin DisplayObject's width & height +- The Flowplayer API was not fully initialized when onLoad was invoked on Flash plugins + +beta3 +----- +- tweaking logo placement +- "play" did not show up after repeated pause/resume +- player now loads the latest controls SWF version, right now the latest SWF is called 'flowplayer.controls-3.0.0-beta2.swf' + +beta2 +----- +- fixed support for RTMP stream groups +- changed to loop through available fonts in order to find a suitable font also in IE +- Preloader was broken on IE: When the player SWf was in browser's cache it did not initialize properly +- Context menu now correctly handles menu items that are configured by their string labels only (not using json objects) +- fixed custom logo positioning (was moved to the left edge of screen in fullscreen) +- "play" now always follows the position and size of the screen +- video was stretched below the controls in fullscreen when autoHide: 'never' +- logo now takes 6.5% of the screen height, width is scaled so that the aspect ratio is preserved + +beta1 +----- +- First public beta release diff --git a/typo3/contrib/flowplayer/build.properties b/typo3/contrib/flowplayer/build.properties new file mode 100644 index 0000000000000000000000000000000000000000..d60d3f06c807df35028f5a6f91030daf9e761aab --- /dev/null +++ b/typo3/contrib/flowplayer/build.properties @@ -0,0 +1,54 @@ + +# you need to adjust following to point to your Flex SDK +flex3dir=/Users/Api/flex_sdk_4 + +# change following to point to .exe files when running on Windows +mxmlc_bin= ${flex3bindir}/mxmlc +compc_bin= ${flex3bindir}/compc +asdoc_bin= /Users/Api/flex_sdk_3/bin/asdoc + +devkit-dir=../flowplayer.devkit +plugins.dir=../ +deploy.dir=/Users/api/flowplayer.org/out/artifacts/setup_war_exploded/swf + + +# 3.2.4 +#plugin.buildfiles=rtmp/build.xml,pseudostreaming/build.xml + +#plugin.buildfiles=bwcheck/build.xml, \ +# analytics/build.xml, \ +# audio/build.xml, \ +# captions/build.xml, \ +# cluster/build.xml, \ +# controls/build.xml,controls/build-air.xml,controls/build-tube.xml,controls/build-skinless.xml, \ +# pseudostreaming/build.xml, \ +# securestreaming/build.xml, \ +# viralvideos/build.xml, \ +# sharing/build.xml +# +plugin.buildfiles=bwcheck/build.xml,controls/build.xml,controls/build-air.xml,controls/build-tube.xml,controls/build-skinless.xml, \ + viralvideos/build.xml,pseudostreaming/build.xml,securestreaming/build.xml,smil/build.xml,sharing/build.xml + + +for plugins that can be built inside the player + +plugin-classes=${plugins.dir}controls/src/actionscript ${plugins.dir}content/src/actionscript \ + ${plugins.dir}akamai/src/actionscript ${plugins.dir}rtmp/src/actionscript ${plugins.dir}pseudostreaming/src/actionscript \ + ${plugins.dir}audio/src/actionscript ${plugins.dir}bwcheck/src/actionscript ${plugins.dir}cluster/src/actionscript \ + ${plugins.dir}captions/src/actionscript ${plugins.dir}securestreaming/src/actionscript ${plugins.dir}smil/src/actionscript \ + ${plugins.dir}common/src/actionscript + +plugin-swc=../controls/src/flash ../content/src/flash ../viralvideos/src/flash ../pseudostreaming/lib + +controls-dir=../controls + +# following can usually be left as they are +flex3bindir=${flex3dir}/bin +flex3libsdir=${flex3dir}/frameworks/libs +flashplayer_bin= +framerate=24 +bgcolor=0xFFFFFF +width=500 +height=350 + +Str \ No newline at end of file diff --git a/typo3/contrib/flowplayer/build.xml b/typo3/contrib/flowplayer/build.xml new file mode 100644 index 0000000000000000000000000000000000000000..4e3ff34791e6f9b0002e81d333836ce7bfd2ac11 --- /dev/null +++ b/typo3/contrib/flowplayer/build.xml @@ -0,0 +1,519 @@ +<project name="Flowplayer" default="build"> + <property file="build.generated.properties"/> + <property file="build.properties"/> + + <property name="version-1" value="3"/> + <property name="version-2" value="2"/> + <property name="version-3" value="7"/> + <property name="version-status" value=""/> + <property name="controls-version-info" value="3.2.5"/> + <property name="audio-version-info" value="3.2.2"/> + <property name="flowplayer-js-version-info" value="3.2.6"/> + <property name="source-dist-root-folder" value="flowplayer"/> + + <property name="version-status-quoted" value=""'${version-status}'""/> + <condition property="version-info" value="${version-1}.${version-2}.${version-3}" + else="${version-1}.${version-2}.${version-3}-${version-status}"> + <equals arg1="${version-status}" arg2=""/> + </condition> + + <property name="controls-version-info-quoted" value=""'${controls-version-info}'""/> + <property name="audio-version-info-quoted" value=""'${audio-version-info}'""/> + + <property name="src" value="src"/> + <property name="src-as" value="${src}/actionscript"/> + <property name="src-flash" value="${src}/flash"/> + <property name="src-as-commercial" value="${src}/actionscript-commercial"/> + <property name="src-as-builtin" value="${src}/actionscript-builtin"/> + <property name="src-js" value="${src}/javascript"/> + <property name="src-test" value="test"/> + <property name="src-html" value="${src}/html"/> + <property name="build-dir" value="build"/> + <property name="dist-dir" value="dist"/> + <property name="apidoc-dir" value="build/apidoc"/> + <property name="lib-dir" value="lib"/> + <property name="locale" value="en_US"/> + + <condition property="plugin-skin" value="${controls}" else="modern"> + <isset property="controls"/> + </condition> + + <condition property="has-slowmotion-buttons" value="true" else="false"> + <equals arg1="${plugin-skin}" arg2="modern"/> + </condition> + + <condition property="plugin-libs" value="${controls-dir}/src/flash/${plugin-skin}" else=""> + <available file="${controls-dir}/build.xml"/> + </condition> + + <property name="libs-path" value="${flex3libsdir} ${lib-dir}/thunderbolt ${plugin-libs} ${plugin-swc}"/> + <property name="classes-for-lib" + value="org.flowplayer.view.Flowplayer org.flowplayer.util.PropertyBinder org.flowplayer.util.Arrange org.flowplayer.util.Assert org.flowplayer.model.PluginEvent org.flowplayer.util.TextUtil org.flowplayer.view.AbstractSprite org.flowplayer.view.AnimationEngine org.flowplayer.controller.NetStreamControllingStreamProvider org.flowplayer.controller.NetStreamClient org.flowplayer.controller.NetConnectionClient"/> + <property name="doc-classes" + value="${classes-for-lib} org.flowplayer.view.FlowplayerBase org.flowplayer.view.StyleableSprite org.flowplayer.model.Plugin org.flowplayer.model.PluginModel org.flowplayer.model.DisplayPluginModel org.flowplayer.model.ProviderModel org.flowplayer.model.Cloneable org.flowplayer.model.DisplayProperties org.flowplayer.model.Identifiable org.flowplayer.model.Callable org.flowplayer.model.Clip org.flowplayer.model.Playlist org.flowplayer.model.AbstractEvent org.flowplayer.model.ClipEvent org.flowplayer.model.PlayerEvent org.flowplayer.model.PluginEvent org.flowplayer.model.ClipEventDispatcher org.flowplayer.model.ClipEventSupport org.flowplayer.model.EventType org.flowplayer.model.ClipEventType org.flowplayer.model.PlayerEventType org.flowplayer.model.PluginEventType org.flowplayer.view.Styleable org.flowplayer.controller.StreamProvider org.flowplayer.model.PluginFactory org.flowplayer.controller.ClipURLResolver org.flowplayer.controller.ConnectionProvider org.flowplayer.util.Log"/> + + <condition property="classpath-temp" value="${lib-dir}/corelib/src ${lib-dir}/goasp/src_go ${plugin-classes}" + else="${lib-dir}/corelib/src ${lib-dir}/goasp/src_go"> + <isset property="plugin-classes"/> + </condition> + + <condition property="classpath" value="${classpath-temp} ${plugins}" else="${classpath-temp} ${src-as-builtin}"> + <isset property="plugins"/> + </condition> + + <property name="library-binary" value="flowplayer.swc"/> + <property name="library-binary-versioned" value="flowplayer-${version-info}.swc"/> + + <property name="player-binary" value="flowplayer.swf"/> + <property name="debug-player-binary" value="flowplayer.debug.swf"/> + <property name="commercial-debug-player-binary" value="flowplayer.commercial.debug.swf"/> + <property name="commercial-player-binary" value="flowplayer.commercial.swf"/> + <property name="player-binary-versioned" value="flowplayer-${version-info}.swf"/> + <property name="commercial-player-binary-versioned" value="flowplayer.commercial-${version-info}.swf"/> + + <property name="dist-name" value="flowplayer-${version-info}.zip"/> + <property name="commercial-dist-name" value="flowplayer.commercial-${version-info}.zip"/> + <property name="multidomain-dist-name" value="flowplayer.multidomain-${version-info}.zip"/> + <property name="devkit-dist-name" value="flowplayer.devkit-${version-info}.zip"/> + <property name="apidoc-dist-name" value="flowplayer.asdoc-${version-info}.zip"/> + <property name="source-dist-name" value="flowplayer-${version-info}-src.zip"/> + + <target name="clean" depends="clean-plugins"> + <delete dir="${build-dir}"> + <include name="*swf"/> + <include name="*swc"/> + </delete> + <delete dir="${build-dir}/example"></delete> + </target> + + <target name="dobuild" depends="check-uptodate, build-lib, plugins" unless="uptodate.main"> + <antcall target="prepare"/> + <property name="licenselib" value="${lib-dir}/licensekey"/> + <antcall target="compile"/> + <example player-swf="${player-binary-versioned}" example-dir="example-free"/> + </target> + + <target name="deploy" if="deploy.dir"> + <copy todir="${deploy.dir}"> + <fileset dir="${build-dir}"> + <include name="*swf"/> + </fileset> + </copy> + </target> + + <target name="build" description="builds all" depends="dobuild, deploy" /> + + <target name="build-biz" description="builds all" depends="check-uptodate, build-lib, plugins" + unless="uptodate.commercial"> + <antcall target="prepare"/> + <property name="licenselib" value="${lib-dir}/licensekey"/> + <antcall target="compile-commercial"/> + <example player-swf="${commercial-player-binary-versioned}" example-dir="example-biz"/> + </target> + + <target name="build-all" description="builds all" depends="build, build-biz"/> + + <target name="zip-bundled"> + <antcall target="prepare"/> + + <compile-player binary="${bundled-basename}.swf" commercial="true" free="false" + license-lib="${bundled-license-lib}" debug="false"/> + <copy file="${build-dir}/${bundled-basename}.swf" + tofile="${build-dir}/${bundled-basename}-${version-info}.swf"/> + <example player-swf="${bundled-basename}-${version-info}.swf" example-dir="examble-bundled"/> + <zip-player license="LICENSE_UNLIMITED.txt" player-swf="${bundled-basename}-${version-info}.swf" + player-swf-dir="${build-dir}" zip-name="${bundled-basename}-${version-info}.zip" + example-dir="examble-bundled"/> + </target> + + <target name="compile"> + <compile-player binary="${player-binary}" commercial="false" free="true" license-lib="${licenselib}" + debug="false"/> + <copy file="${build-dir}/${player-binary}" tofile="${build-dir}/${player-binary-versioned}"/> + </target> + + <target name="build-debug" description="builds the debug version of the player" depends="prepare"> + <property name="licenselib" value="${lib-dir}/licensekey"/> + <compile-player binary="${debug-player-binary}" commercial="false" free="true" license-lib="${licenselib}" + debug="true"/> + <compile-player binary="${commercial-debug-player-binary}" commercial="true" free="false" + license-lib="${licenselib}" debug="true"/> + </target> + + <target name="compile-commercial"> + <compile-player binary="${commercial-player-binary}" debug="false" commercial="true" free="false" + license-lib="${licenselib}"/> + <copy file="${build-dir}/${commercial-player-binary}" + tofile="${build-dir}/${commercial-player-binary-versioned}"/> + </target> + + <macrodef name="example"> + <attribute name="player-swf"/> + <attribute name="example-dir"/> + <sequential> + <echo message="building example"/> + <delete dir="${build-dir}/@{example-dir}"/> + <copy todir="${build-dir}/@{example-dir}" overwrite="true"> + <fileset dir="example"> + <include name="*.tmpl"/> + </fileset> + <mapper type="glob" from="*.tmpl" to="*"/> + <filterset begintoken="@" endtoken="@"> + <filter token="FLOWPLAYER_JS_VERSION_INFO" value="${flowplayer-js-version-info}"/> + <filter token="PLAYER_SWF" value="../@{player-swf}"/> + </filterset> + </copy> + <copy todir="${build-dir}/@{example-dir}"> + <fileset dir="example"> + <include name="*.js"/> + <include name="*.html"/> + <include name="*.css"/> + </fileset> + </copy> + </sequential> + </macrodef> + + <macrodef name="compile-player"> + <attribute name="binary"/> + <attribute name="commercial"/> + <attribute name="free"/> + <attribute name="license-lib"/> + <attribute name="debug"/> + <sequential> + <echo message="Building binary @{binary}, mxmlc is ${mxmlc_bin}"/> + <exec executable="${mxmlc_bin}" failonerror="true"> + <arg line="-define=CONFIG::commercialVersion,'@{commercial}'"/> + <arg line="-define+=CONFIG::freeVersion,'@{free}'"/> + <arg line="-define+=CONFIG::version1,'${version-1}'"/> + <arg line="-define+=CONFIG::version2,'${version-2}'"/> + <arg line="-define+=CONFIG::version3,'${version-3}'"/> + <arg line="-define+=CONFIG::versionStatus,${version-status-quoted}"/> + <arg line="-define+=CONFIG::controlsVersion,${controls-version-info-quoted}"/> + <arg line="-define+=CONFIG::audioVersion,${audio-version-info-quoted}"/> + <arg line="-define+=CONFIG::skin,true"/> + <arg line="-define+=CONFIG::hasSlowMotion,'${has-slowmotion-buttons}'"/> + <arg line="-define+=CONFIG::debug,'@{debug}'"/> + <arg line="-define+=CONFIG::enableByteRange,'false'"/> + <arg line="-keep-as3-metadata=Value,External"/> + <arg line="-source-path ${src-as} ${src-as-commercial} ${classpath} ${plugin-libs}"/> + <arg line="-static-link-runtime-shared-libraries=true" /> + <!--<arg line="-link-report build/link-report.xml" />--> + <arg line="-library-path ${libs-path} ${src-flash} @{license-lib}"/> + + <arg line="-default-frame-rate=${framerate}"/> + <arg line="-default-background-color=${bgcolor}"/> + <arg line="-strict=true"/> + <arg line="-incremental=true"/> + <arg line="-debug=@{debug}"/> + + <arg line="-frame 'player' org.flowplayer.view.Launcher"/> + + <arg line="-file-specs '${src-as}/org/flowplayer/view/Preloader.as'"/> + <arg line="-output '${build-dir}/@{binary}'"/> + <arg line="-target-player '10.1.0'"/> + </exec> + </sequential> + </macrodef> + + + <target name="build-lib" description="builds the FlowPlayer library" depends="check-uptodate" unless="uptodate.lib"> + <antcall target="prepare"/> + <antcall target="compile-lib"/> + <copy file="${build-dir}/${library-binary}" tofile="${build-dir}/${library-binary-versioned}"/> + <copy file="${build-dir}/${library-binary}" todir="${devkit-dir}"/> + </target> + + <target name="compile-lib"> + <exec executable="${compc_bin}" failonerror="true"> + <arg line="-source-path ${src-as} ${src-as-commercial} ${classpath}"/> + <arg line="-compute-digest=false"/> + <arg line="-output '${build-dir}/${library-binary}'"/> + <arg line="-namespace http://flowplayer.org/flowplayer/2008 ${basedir}/manifest.xml -include-namespaces http://flowplayer.org/flowplayer/2008"/> + <arg line="-library-path ${libs-path} ${src-flash} "/> + <arg line="-default-frame-rate=${framerate}"/> + <arg line="-default-background-color=${bgcolor}"/> + <arg line="-strict=true"/> + <arg line="-incremental=true"/> + <arg line="-define+=CONFIG::debug,'false'"/> + </exec> + </target> + + <target name="copyhtml" description="copies html and javascript to the build folder"> + <copy todir="${build-dir}"> + <fileset dir="${src-html}"> + <include name="*.html"/> + </fileset> + <fileset dir="${src-js}"> + <include name="*.js"/> + </fileset> + </copy> + </target> + + <target name="test" description="build testrunner"> + <exec executable="${mxmlc_bin}" failonerror="true"> + <arg line="-source-path ${src-as} ${src-test} ${classpath} -library-path ${libs-path} ${lib-dir}/flexunit -default-frame-rate=${framerate} -default-background-color=${bgcolor} -strict=true '${src-test}/org/flowplayer/css/CssTest.as' -output '${build-dir}/Test.swf'"/> + </exec> + </target> + + <target name="prepare"> + <mkdir dir="${build-dir}/example"/> + <mkdir dir="${dist-dir}"/> + </target> + + <target name="check-uptodate"> + <uptodate property="uptodate.main" targetfile="${build-dir}/${player-binary}"> + <srcfiles dir="${src-as}"> + <include name="**/*.as"/> + </srcfiles> + <srcfiles dir="${src-as-commercial}"> + <include name="**/*.as"/> + </srcfiles> + <srcfiles dir="${src-as-builtin}"> + <include name="**/*.as"/> + </srcfiles> + <srcfiles dir="${basedir}"> + <include name="*.xml"/> + <include name="*.properties"/> + <include name="*.txt"/> + <include name="*.as"/> + </srcfiles> + <srcfiles dir="${lib-dir}"> + <include name="**/*.as"/> + <include name="**/*.swc"/> + </srcfiles> + </uptodate> + <echo message="main up-to-date: ${uptodate.main}"/> + + <uptodate property="uptodate.commercial" targetfile="${build-dir}/${commercial-player-binary}"> + <srcfiles dir="${src-as}"> + <include name="**/*.as"/> + </srcfiles> + <srcfiles dir="${src-as-commercial}"> + <include name="**/*.as"/> + </srcfiles> + <srcfiles dir="${src-as-builtin}"> + <include name="**/*.as"/> + </srcfiles> + <srcfiles dir="${basedir}"> + <include name="*.xml"/> + <include name="*.properties"/> + <include name="*.txt"/> + </srcfiles> + <srcfiles dir="${lib-dir}"> + <include name="**/*.as"/> + <include name="**/*.swc"/> + </srcfiles> + </uptodate> + <echo message="main up-to-date: ${uptodate.commercial}"/> + + <uptodate property="uptodate.lib" targetfile="${build-dir}/${library-binary}"> + <srcfiles dir="${src-as}"> + <include name="**/*.as"/> + </srcfiles> + <srcfiles dir="${src-as-commercial}"> + <include name="**/*.as"/> + </srcfiles> + </uptodate> + <echo message="lib up-to-date: ${uptodate.lib}"/> + </target> + + <target name="plugins" description="Build all plugins"> + <iterate-plugins target="deploy"/> + </target> + + <target name="plugin-names" description="Echoes all plugin names"> + <iterate-plugins target="echo-name"/> + </target> + + <target name="clean-plugins" description="Cleans all plugins"> + <iterate-plugins target="clean"/> + </target> + + <macrodef name="iterate-plugins"> + <attribute name="target"/> + <sequential> + <subant target="@{target}"> + <fileset dir="${plugins.dir}" includes="${plugin.buildfiles}"/> + <property name="remotedir" value="${remotedir}"/> + <property name="all-swf-zip" value="${basedir}/dist/latest.zip"/> + <property name="swfremotedir" value="${swfremotedir}"/> + <property name="aws-accessId" value="${aws-accessId}"/> + <property name="aws-secretKey" value="${aws-secretKey}"/> + <property name="keyfile" value="${keyfile}"/> + <property name="url-file" value="${url-file}"/> + <property name="devkit-dir" value="${devkit-dir}"/> + </subant> + </sequential> + </macrodef> + + <target name="release-plugin" description="releases one plugin, specify the plugin name with -Dplugin="> + <ant antfile="../${plugin}/build.xml" target="release-remote" dir="../${plugin}"> + <property name="remotedir" value="${remotedir}"/> + <property name="all-swf-zip" value="${basedir}/dist/latest.zip"/> + <property name="swfremotedir" value="${swfremotedir}"/> + <property name="aws-accessId" value="${aws-accessId}"/> + <property name="aws-secretKey" value="${aws-secretKey}"/> + <property name="url-file" value="${url-file}"/> + <property name="keyfile" value="${keyfile}"/> + </ant> + </target> + + <target name="doc" description="generates the apidocs"> + <!--<exec executable="${asdoc_bin}" failonerror="true">--> + <!--<arg line="-source-path ${src-as} ${classpath}"/>--> + <!--<arg line="-library-path ${libs-path} ${src-flash}"/>--> + <!--<arg line="-doc-classes ${doc-classes}"/>--> + <!--<arg line="-exclude-dependencies"/>--> + <!--<arg line="-output ${apidoc-dir}"/>--> + <!--<arg line="-main-title 'FlowPlayer ${version-1}.${version-2}.${version-3} API documentation'"/>--> + <!--<arg line="-window-title 'FlowPlayer ${version-1}.${version-2}.${version-3} API documentation'"/>--> + <!--<arg line="-define+=CONFIG::debug,'false'"/>--> + <!--</exec>--> + </target> + + <target name="zip" description="creates a distribution zip package" depends="build"> + <zip-player zip-name="${dist-name}" player-swf-dir="${build-dir}" player-swf="${player-binary-versioned}" + license="LICENSE.txt" example-dir="example-free"/> + </target> + + <target name="zip-biz" description="creates a Commercial distribution zip package" depends="build-biz"> + <zip-player zip-name="${commercial-dist-name}" player-swf-dir="${build-dir}" + player-swf="${commercial-player-binary-versioned}" license="LICENSE_COMMERCIAL.txt" + example-dir="example-biz"/> + <zip-player zip-name="${multidomain-dist-name}" player-swf-dir="${build-dir}" + player-swf="${commercial-player-binary-versioned}" license="LICENSE_MULTIDOMAIN.txt" + example-dir="example-biz"/> + </target> + + <macrodef name="zip-player"> + <attribute name="zip-name"/> + <attribute name="player-swf"/> + <attribute name="player-swf-dir"/> + <attribute name="license"/> + <attribute name="example-dir"/> + <sequential> + <echo message="++ Zipping @{zip-name} +++"></echo> + + <zip destfile="${dist-dir}/@{zip-name}"> + <zipfileset prefix="flowplayer" dir="."> + <include name="@{license}"/> + <include name="README.txt"/> + </zipfileset> + <zipfileset prefix="flowplayer" dir="@{player-swf-dir}"> + <include name="@{player-swf}"/> + </zipfileset> + <zipfileset prefix="flowplayer" dir="${dist-dir}"> + <include name="flowplayer.controls-${controls-version-info}.swf"/> + </zipfileset> + <zipfileset prefix="flowplayer/example" dir="${build-dir}/@{example-dir}"> + <include name="*"/> + <exclude name="index.html.tmpl"/> + </zipfileset> + </zip> + <verify-zip zip-name="@{zip-name}" player-swf="@{player-swf}" license="@{license}"/> + </sequential> + </macrodef> + + <target name="source-dist" description="prepares the source distribution package"> + <zip zipfile="${dist-dir}/${source-dist-name}"> + <zipfileset prefix="${source-dist-root-folder}" dir="." + includes="${src-as}/**/*.as, ${src-as-commercial}/**/*.as, ${src-as-builtin}/**/*.as, ${src-flash}/**/*"/> + <zipfileset prefix="${source-dist-root-folder}" dir="." includes="example/**/*"/> + <zipfileset prefix="${source-dist-root-folder}" dir="." includes="lib/**/*"/> + <zipfileset prefix="${source-dist-root-folder}" dir="."> + <include name="LICENSE*.txt"/> + <include name="README.txt"/> + <include name="build.xml"/> + <include name="manifest.xml"/> + <include name="build.properties"/> + </zipfileset> + </zip> + </target> + + <macrodef name="verify-zip"> + <attribute name="zip-name"/> + <attribute name="player-swf"/> + <attribute name="license"/> + <sequential> + <echo message="verifying @{zip-name} contents"/> + <delete dir="${dist-dir}/flowplayer"/> + <unzip src="${dist-dir}/@{zip-name}" dest="${dist-dir}"/> + <condition property="${resources-available}" value="true"> + <and> + <available file="${dist-dir}/flowplayer/@{player-swf}"/> + <available file="${dist-dir}/flowplayer/flowplayer.controls-${controls-version-info}.swf"/> + <available file="${dist-dir}/flowplayer/@{license}"/> + <available file="${dist-dir}/flowplayer/README.txt"/> + <available file="${dist-dir}/flowplayer/example/index.html"/> + <available file="${dist-dir}/flowplayer/example/style.css"/> + <available file="${dist-dir}/flowplayer/example/flowplayer-${flowplayer-js-version-info}.min.js"/> + </and> + </condition> + <fail unless="${resources-available}" message="Not all required resources present in @{zip-name}"/> + </sequential> + </macrodef> + + <target name="zip-devkit" depends="doc, build-lib"> + <zip destfile="${dist-dir}/${devkit-dist-name}"> + <zipfileset prefix="flowplayer.devkit" dir="${devkit-dir}"> + <include name="LICENSE.txt"/> + <include name="README.txt"/> + <include name="*.properties"/> + <include name="*.xml"/> + </zipfileset> + <zipfileset prefix="flowplayer.devkit" dir="${build-dir}"> + <include name="${library-binary}"/> + </zipfileset> + <zipfileset prefix="flowplayer.devkit/example" dir="${devkit-dir}/example"> + <include name="*.xml"/> + <include name="*.fla"/> + <include name="*.properties"/> + <include name="src/**/*"/> + </zipfileset> + <zipfileset prefix="flowplayer.devkit/doc" dir="${apidoc-dir}"> + <include name="**/*"/> + </zipfileset> + </zip> + </target> + + <target name="dist" description="Create distribution packages"> + <iterate-plugins target="dist"/> + <ant target="zip"/> + <ant target="zip-biz"/> + <ant target="zip-devkit"/> + <ant target="source-dist"/> + </target> + + <!-- following is used when building from a webapp in our compile farm --> + <target name="copy" if="copy-source"> + <copy file="${copy-source}" tofile="${copy-target}" verbose="true"/> + </target> + + <target name="quick" description="builds the player quickly" depends="prepare"> + <property name="licenselib" value="${lib-dir}/licensekey"/> + <antcall target="compile"/> + </target> + + <target name="quick-biz" description="builds the player quickly" depends="prepare"> + <property name="licenselib" value="${lib-dir}/licensekey"/> + <antcall target="compile-commercial"/> + </target> + + <target name="echo-version" description="echos the flowpalyer version number"> + <echo message="version-1: ${version-1}"/> + <echo message="version-2: ${version-2}"/> + <echo message="version-3: ${version-3}"/> + <echo message="version-status: ${version-status}"/> + </target> + + + <target name="debug-js"> + <get src="http://flowplayer.org/js/tools/tools.flashembed-1.0.4.js" dest="${dist-dir}/flowplayer-debug.js"/> + + <concat destfile="${dist-dir}/flowplayer-debug.js" append="true"> + + <fileset dir="${src-js}/flowplayer.js" includes="flowplayer-src.js"/> + </concat> + </target> + +</project> \ No newline at end of file diff --git a/typo3/contrib/flowplayer/example/flowplayer-3.2.6.min.js b/typo3/contrib/flowplayer/example/flowplayer-3.2.6.min.js new file mode 100644 index 0000000000000000000000000000000000000000..500492e297789717ab506954af1f715cbb450785 --- /dev/null +++ b/typo3/contrib/flowplayer/example/flowplayer-3.2.6.min.js @@ -0,0 +1,24 @@ +/* + * flowplayer.js 3.2.6. The Flowplayer API + * + * Copyright 2009-2011 Flowplayer Oy + * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + * + * Date: 2011-02-04 05:45:28 -0500 (Fri, 04 Feb 2011) + * Revision: 614 + */ +(function(){function g(o){console.log("$f.fireEvent",[].slice.call(o))}function k(q){if(!q||typeof q!="object"){return q}var o=new q.constructor();for(var p in q){if(q.hasOwnProperty(p)){o[p]=k(q[p])}}return o}function m(t,q){if(!t){return}var o,p=0,r=t.length;if(r===undefined){for(o in t){if(q.call(t[o],o,t[o])===false){break}}}else{for(var s=t[0];p<r&&q.call(s,p,s)!==false;s=t[++p]){}}return t}function c(o){return document.getElementById(o)}function i(q,p,o){if(typeof p!="object"){return q}if(q&&p){m(p,function(r,s){if(!o||typeof s!="function"){q[r]=s}})}return q}function n(s){var q=s.indexOf(".");if(q!=-1){var p=s.slice(0,q)||"*";var o=s.slice(q+1,s.length);var r=[];m(document.getElementsByTagName(p),function(){if(this.className&&this.className.indexOf(o)!=-1){r.push(this)}});return r}}function f(o){o=o||window.event;if(o.preventDefault){o.stopPropagation();o.preventDefault()}else{o.returnValue=false;o.cancelBubble=true}return false}function j(q,o,p){q[o]=q[o]||[];q[o].push(p)}function e(){return"_"+(""+Math.random()).slice(2,10)}var h=function(t,r,s){var q=this,p={},u={};q.index=r;if(typeof t=="string"){t={url:t}}i(this,t,true);m(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),function(){var v="on"+this;if(v.indexOf("*")!=-1){v=v.slice(0,v.length-1);var w="onBefore"+v.slice(2);q[w]=function(x){j(u,w,x);return q}}q[v]=function(x){j(u,v,x);return q};if(r==-1){if(q[w]){s[w]=q[w]}if(q[v]){s[v]=q[v]}}});i(this,{onCuepoint:function(x,w){if(arguments.length==1){p.embedded=[null,x];return q}if(typeof x=="number"){x=[x]}var v=e();p[v]=[x,w];if(s.isLoaded()){s._api().fp_addCuepoints(x,r,v)}return q},update:function(w){i(q,w);if(s.isLoaded()){s._api().fp_updateClip(w,r)}var v=s.getConfig();var x=(r==-1)?v.clip:v.playlist[r];i(x,w,true)},_fireEvent:function(v,y,w,A){if(v=="onLoad"){m(p,function(B,C){if(C[0]){s._api().fp_addCuepoints(C[0],r,B)}});return false}A=A||q;if(v=="onCuepoint"){var z=p[y];if(z){return z[1].call(s,A,w)}}if(y&&"onBeforeBegin,onMetaData,onStart,onUpdate,onResume".indexOf(v)!=-1){i(A,y);if(y.metaData){if(!A.duration){A.duration=y.metaData.duration}else{A.fullDuration=y.metaData.duration}}}var x=true;m(u[v],function(){x=this.call(s,A,y,w)});return x}});if(t.onCuepoint){var o=t.onCuepoint;q.onCuepoint.apply(q,typeof o=="function"?[o]:o);delete t.onCuepoint}m(t,function(v,w){if(typeof w=="function"){j(u,v,w);delete t[v]}});if(r==-1){s.onCuepoint=this.onCuepoint}};var l=function(p,r,q,t){var o=this,s={},u=false;if(t){i(s,t)}m(r,function(v,w){if(typeof w=="function"){s[v]=w;delete r[v]}});i(this,{animate:function(y,z,x){if(!y){return o}if(typeof z=="function"){x=z;z=500}if(typeof y=="string"){var w=y;y={};y[w]=z;z=500}if(x){var v=e();s[v]=x}if(z===undefined){z=500}r=q._api().fp_animate(p,y,z,v);return o},css:function(w,x){if(x!==undefined){var v={};v[w]=x;w=v}r=q._api().fp_css(p,w);i(o,r);return o},show:function(){this.display="block";q._api().fp_showPlugin(p);return o},hide:function(){this.display="none";q._api().fp_hidePlugin(p);return o},toggle:function(){this.display=q._api().fp_togglePlugin(p);return o},fadeTo:function(y,x,w){if(typeof x=="function"){w=x;x=500}if(w){var v=e();s[v]=w}this.display=q._api().fp_fadeTo(p,y,x,v);this.opacity=y;return o},fadeIn:function(w,v){return o.fadeTo(1,w,v)},fadeOut:function(w,v){return o.fadeTo(0,w,v)},getName:function(){return p},getPlayer:function(){return q},_fireEvent:function(w,v,x){if(w=="onUpdate"){var z=q._api().fp_getPlugin(p);if(!z){return}i(o,z);delete o.methods;if(!u){m(z.methods,function(){var B=""+this;o[B]=function(){var C=[].slice.call(arguments);var D=q._api().fp_invoke(p,B,C);return D==="undefined"||D===undefined?o:D}});u=true}}var A=s[w];if(A){var y=A.apply(o,v);if(w.slice(0,1)=="_"){delete s[w]}return y}return o}})};function b(q,G,t){var w=this,v=null,D=false,u,s,F=[],y={},x={},E,r,p,C,o,A;i(w,{id:function(){return E},isLoaded:function(){return(v!==null&&v.fp_play!==undefined&&!D)},getParent:function(){return q},hide:function(H){if(H){q.style.height="0px"}if(w.isLoaded()){v.style.height="0px"}return w},show:function(){q.style.height=A+"px";if(w.isLoaded()){v.style.height=o+"px"}return w},isHidden:function(){return w.isLoaded()&&parseInt(v.style.height,10)===0},load:function(J){if(!w.isLoaded()&&w._fireEvent("onBeforeLoad")!==false){var H=function(){u=q.innerHTML;if(u&&!flashembed.isSupported(G.version)){q.innerHTML=""}if(J){J.cached=true;j(x,"onLoad",J)}flashembed(q,G,{config:t})};var I=0;m(a,function(){this.unload(function(K){if(++I==a.length){H()}})})}return w},unload:function(J){if(this.isFullscreen()&&/WebKit/i.test(navigator.userAgent)){if(J){J(false)}return w}if(u.replace(/\s/g,"")!==""){if(w._fireEvent("onBeforeUnload")===false){if(J){J(false)}return w}D=true;try{if(v){v.fp_close();w._fireEvent("onUnload")}}catch(H){}var I=function(){v=null;q.innerHTML=u;D=false;if(J){J(true)}};setTimeout(I,50)}else{if(J){J(false)}}return w},getClip:function(H){if(H===undefined){H=C}return F[H]},getCommonClip:function(){return s},getPlaylist:function(){return F},getPlugin:function(H){var J=y[H];if(!J&&w.isLoaded()){var I=w._api().fp_getPlugin(H);if(I){J=new l(H,I,w);y[H]=J}}return J},getScreen:function(){return w.getPlugin("screen")},getControls:function(){return w.getPlugin("controls")._fireEvent("onUpdate")},getLogo:function(){try{return w.getPlugin("logo")._fireEvent("onUpdate")}catch(H){}},getPlay:function(){return w.getPlugin("play")._fireEvent("onUpdate")},getConfig:function(H){return H?k(t):t},getFlashParams:function(){return G},loadPlugin:function(K,J,M,L){if(typeof M=="function"){L=M;M={}}var I=L?e():"_";w._api().fp_loadPlugin(K,J,M,I);var H={};H[I]=L;var N=new l(K,null,w,H);y[K]=N;return N},getState:function(){return w.isLoaded()?v.fp_getState():-1},play:function(I,H){var J=function(){if(I!==undefined){w._api().fp_play(I,H)}else{w._api().fp_play()}};if(w.isLoaded()){J()}else{if(D){setTimeout(function(){w.play(I,H)},50)}else{w.load(function(){J()})}}return w},getVersion:function(){var I="flowplayer.js 3.2.6";if(w.isLoaded()){var H=v.fp_getVersion();H.push(I);return H}return I},_api:function(){if(!w.isLoaded()){throw"Flowplayer "+w.id()+" not loaded when calling an API method"}return v},setClip:function(H){w.setPlaylist([H]);return w},getIndex:function(){return p},_swfHeight:function(){return v.clientHeight}});m(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,ClipAdd,Fullscreen*,FullscreenExit,Error,MouseOver,MouseOut").split(","),function(){var H="on"+this;if(H.indexOf("*")!=-1){H=H.slice(0,H.length-1);var I="onBefore"+H.slice(2);w[I]=function(J){j(x,I,J);return w}}w[H]=function(J){j(x,H,J);return w}});m(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,toggleFullscreen,reset,close,setPlaylist,addClip,playFeed,setKeyboardShortcutsEnabled,isKeyboardShortcutsEnabled").split(","),function(){var H=this;w[H]=function(J,I){if(!w.isLoaded()){return w}var K=null;if(J!==undefined&&I!==undefined){K=v["fp_"+H](J,I)}else{K=(J===undefined)?v["fp_"+H]():v["fp_"+H](J)}return K==="undefined"||K===undefined?w:K}});w._fireEvent=function(Q){if(typeof Q=="string"){Q=[Q]}var R=Q[0],O=Q[1],M=Q[2],L=Q[3],K=0;if(t.debug){g(Q)}if(!w.isLoaded()&&R=="onLoad"&&O=="player"){v=v||c(r);o=w._swfHeight();m(F,function(){this._fireEvent("onLoad")});m(y,function(S,T){T._fireEvent("onUpdate")});s._fireEvent("onLoad")}if(R=="onLoad"&&O!="player"){return}if(R=="onError"){if(typeof O=="string"||(typeof O=="number"&&typeof M=="number")){O=M;M=L}}if(R=="onContextMenu"){m(t.contextMenu[O],function(S,T){T.call(w)});return}if(R=="onPluginEvent"||R=="onBeforePluginEvent"){var H=O.name||O;var I=y[H];if(I){I._fireEvent("onUpdate",O);return I._fireEvent(M,Q.slice(3))}return}if(R=="onPlaylistReplace"){F=[];var N=0;m(O,function(){F.push(new h(this,N++,w))})}if(R=="onClipAdd"){if(O.isInStream){return}O=new h(O,M,w);F.splice(M,0,O);for(K=M+1;K<F.length;K++){F[K].index++}}var P=true;if(typeof O=="number"&&O<F.length){C=O;var J=F[O];if(J){P=J._fireEvent(R,M,L)}if(!J||P!==false){P=s._fireEvent(R,M,L,J)}}m(x[R],function(){P=this.call(w,O,M);if(this.cached){x[R].splice(K,1)}if(P===false){return false}K++});return P};function B(){if($f(q)){$f(q).getParent().innerHTML="";p=$f(q).getIndex();a[p]=w}else{a.push(w);p=a.length-1}A=parseInt(q.style.height,10)||q.clientHeight;E=q.id||"fp"+e();r=G.id||E+"_api";G.id=r;t.playerId=E;if(typeof t=="string"){t={clip:{url:t}}}if(typeof t.clip=="string"){t.clip={url:t.clip}}t.clip=t.clip||{};if(q.getAttribute("href",2)&&!t.clip.url){t.clip.url=q.getAttribute("href",2)}s=new h(t.clip,-1,w);t.playlist=t.playlist||[t.clip];var I=0;m(t.playlist,function(){var K=this;if(typeof K=="object"&&K.length){K={url:""+K}}m(t.clip,function(L,M){if(M!==undefined&&K[L]===undefined&&typeof M!="function"){K[L]=M}});t.playlist[I]=K;K=new h(K,I,w);F.push(K);I++});m(t,function(K,L){if(typeof L=="function"){if(s[K]){s[K](L)}else{j(x,K,L)}delete t[K]}});m(t.plugins,function(K,L){if(L){y[K]=new l(K,L,w)}});if(!t.plugins||t.plugins.controls===undefined){y.controls=new l("controls",null,w)}y.canvas=new l("canvas",null,w);u=q.innerHTML;function J(L){var K=w.hasiPadSupport&&w.hasiPadSupport();if(/iPad|iPhone|iPod/i.test(navigator.userAgent)&&!/.flv$/i.test(F[0].url)&&!K){return true}if(!w.isLoaded()&&w._fireEvent("onBeforeClick")!==false){w.load()}return f(L)}function H(){if(u.replace(/\s/g,"")!==""){if(q.addEventListener){q.addEventListener("click",J,false)}else{if(q.attachEvent){q.attachEvent("onclick",J)}}}else{if(q.addEventListener){q.addEventListener("click",f,false)}w.load()}}setTimeout(H,0)}if(typeof q=="string"){var z=c(q);if(!z){throw"Flowplayer cannot access element: "+q}q=z;B()}else{B()}}var a=[];function d(o){this.length=o.length;this.each=function(p){m(o,p)};this.size=function(){return o.length}}window.flowplayer=window.$f=function(){var p=null;var o=arguments[0];if(!arguments.length){m(a,function(){if(this.isLoaded()){p=this;return false}});return p||a[0]}if(arguments.length==1){if(typeof o=="number"){return a[o]}else{if(o=="*"){return new d(a)}m(a,function(){if(this.id()==o.id||this.id()==o||this.getParent()==o){p=this;return false}});return p}}if(arguments.length>1){var t=arguments[1],q=(arguments.length==3)?arguments[2]:{};if(typeof t=="string"){t={src:t}}t=i({bgcolor:"#000000",version:[9,0],expressInstall:"http://static.flowplayer.org/swf/expressinstall.swf",cachebusting:false},t);if(typeof o=="string"){if(o.indexOf(".")!=-1){var s=[];m(n(o),function(){s.push(new b(this,k(t),k(q)))});return new d(s)}else{var r=c(o);return new b(r!==null?r:o,t,q)}}else{if(o){return new b(o,t,q)}}}return null};i(window.$f,{fireEvent:function(){var o=[].slice.call(arguments);var q=$f(o[0]);return q?q._fireEvent(o.slice(1)):null},addPlugin:function(o,p){b.prototype[o]=p;return $f},each:m,extend:i});if(typeof jQuery=="function"){jQuery.fn.flowplayer=function(q,p){if(!arguments.length||typeof arguments[0]=="number"){var o=[];this.each(function(){var r=$f(this);if(r){o.push(r)}});return arguments.length?o[arguments[0]]:new d(o)}return this.each(function(){$f(this,k(q),p?k(p):{})})}}})();(function(){var e=typeof jQuery=="function";var i={width:"100%",height:"100%",allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:null,onFail:null,expressInstall:null,w3c:false,cachebusting:false};if(e){jQuery.tools=jQuery.tools||{};jQuery.tools.flashembed={version:"1.0.4",conf:i}}function j(){if(c.done){return false}var l=document;if(l&&l.getElementsByTagName&&l.getElementById&&l.body){clearInterval(c.timer);c.timer=null;for(var k=0;k<c.ready.length;k++){c.ready[k].call()}c.ready=null;c.done=true}}var c=e?jQuery:function(k){if(c.done){return k()}if(c.timer){c.ready.push(k)}else{c.ready=[k];c.timer=setInterval(j,13)}};function f(l,k){if(k){for(key in k){if(k.hasOwnProperty(key)){l[key]=k[key]}}}return l}function g(k){switch(h(k)){case"string":k=k.replace(new RegExp('(["\\\\])',"g"),"\\$1");k=k.replace(/^\s?(\d+)%/,"$1pct");return'"'+k+'"';case"array":return"["+b(k,function(n){return g(n)}).join(",")+"]";case"function":return'"function()"';case"object":var l=[];for(var m in k){if(k.hasOwnProperty(m)){l.push('"'+m+'":'+g(k[m]))}}return"{"+l.join(",")+"}"}return String(k).replace(/\s/g," ").replace(/\'/g,'"')}function h(l){if(l===null||l===undefined){return false}var k=typeof l;return(k=="object"&&l.push)?"array":k}if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}})}function b(k,n){var m=[];for(var l in k){if(k.hasOwnProperty(l)){m[l]=n(k[l])}}return m}function a(r,t){var q=f({},r);var s=document.all;var n='<object width="'+q.width+'" height="'+q.height+'"';if(s&&!q.id){q.id="_"+(""+Math.random()).substring(9)}if(q.id){n+=' id="'+q.id+'"'}if(q.cachebusting){q.src+=((q.src.indexOf("?")!=-1?"&":"?")+Math.random())}if(q.w3c||!s){n+=' data="'+q.src+'" type="application/x-shockwave-flash"'}else{n+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'}n+=">";if(q.w3c||s){n+='<param name="movie" value="'+q.src+'" />'}q.width=q.height=q.id=q.w3c=q.src=null;for(var l in q){if(q[l]!==null){n+='<param name="'+l+'" value="'+q[l]+'" />'}}var o="";if(t){for(var m in t){if(t[m]!==null){o+=m+"="+(typeof t[m]=="object"?g(t[m]):t[m])+"&"}}o=o.substring(0,o.length-1);n+='<param name="flashvars" value=\''+o+"' />"}n+="</object>";return n}function d(m,p,l){var k=flashembed.getVersion();f(this,{getContainer:function(){return m},getConf:function(){return p},getVersion:function(){return k},getFlashvars:function(){return l},getApi:function(){return m.firstChild},getHTML:function(){return a(p,l)}});var q=p.version;var r=p.expressInstall;var o=!q||flashembed.isSupported(q);if(o){p.onFail=p.version=p.expressInstall=null;m.innerHTML=a(p,l)}else{if(q&&r&&flashembed.isSupported([6,65])){f(p,{src:r});l={MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title};m.innerHTML=a(p,l)}else{if(m.innerHTML.replace(/\s/g,"")!==""){}else{m.innerHTML="<h2>Flash version "+q+" or greater is required</h2><h3>"+(k[0]>0?"Your version is "+k:"You have no flash plugin installed")+"</h3>"+(m.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='http://www.adobe.com/go/getflashplayer'>here</a></p>");if(m.tagName=="A"){m.onclick=function(){location.href="http://www.adobe.com/go/getflashplayer"}}}}}if(!o&&p.onFail){var n=p.onFail.call(this);if(typeof n=="string"){m.innerHTML=n}}if(document.all){window[p.id]=document.getElementById(p.id)}}window.flashembed=function(l,m,k){if(typeof l=="string"){var n=document.getElementById(l);if(n){l=n}else{c(function(){flashembed(l,m,k)});return}}if(!l){return}if(typeof m=="string"){m={src:m}}var o=f({},i);f(o,m);return new d(l,o,k)};f(window.flashembed,{getVersion:function(){var m=[0,0];if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){var l=navigator.plugins["Shockwave Flash"].description;if(typeof l!="undefined"){l=l.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var n=parseInt(l.replace(/^(.*)\..*$/,"$1"),10);var r=/r/.test(l)?parseInt(l.replace(/^.*r(.*)$/,"$1"),10):0;m=[n,r]}}else{if(window.ActiveXObject){try{var p=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")}catch(q){try{p=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");m=[6,0];p.AllowScriptAccess="always"}catch(k){if(m[0]==6){return m}}try{p=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(o){}}if(typeof p=="object"){l=p.GetVariable("$version");if(typeof l!="undefined"){l=l.replace(/^\S+\s+(.*)$/,"$1").split(",");m=[parseInt(l[0],10),parseInt(l[2],10)]}}}}return m},isSupported:function(k){var m=flashembed.getVersion();var l=(m[0]>k[0])||(m[0]==k[0]&&m[1]>=k[1]);return l},domReady:c,asString:g,getHTML:a});if(e){jQuery.fn.flashembed=function(l,k){var m=null;this.each(function(){m=flashembed(this,l,k)});return l.api===false?this:m}}})(); \ No newline at end of file diff --git a/typo3/contrib/flowplayer/example/index.html.tmpl b/typo3/contrib/flowplayer/example/index.html.tmpl new file mode 100644 index 0000000000000000000000000000000000000000..a89192bc1db0cfaafcdba8ad9a10f75496d17a59 --- /dev/null +++ b/typo3/contrib/flowplayer/example/index.html.tmpl @@ -0,0 +1,74 @@ +<html><head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8"> +<!-- A minimal Flowplayer setup to get you started --> + + + <!-- + include flowplayer JavaScript file that does + Flash embedding and provides the Flowplayer API. + --> + <script type="text/javascript" src="flowplayer-@FLOWPLAYER_JS_VERSION_INFO@.min.js"></script> + + <!-- some minimal styling, can be removed --> + <link rel="stylesheet" type="text/css" href="style.css"> + + <!-- page title --> + <title>Minimal Flowplayer setup</title> + +</head><body> + + <div id="page"> + + <h1>Minimal Flowplayer setup</h1> + + <p>View commented source code to get familiar with Flowplayer installation.</p> + + <!-- this A tag is where your Flowplayer will be placed. it can be anywhere --> + <a + href="http://pseudo01.hddn.com/vod/demo.flowplayervod/flowplayer-700.flv" + style="display:block;width:520px;height:330px" + id="player"> + </a> + + <!-- this will install flowplayer inside previous A- tag. --> + <script> + flowplayer("player", "@PLAYER_SWF@"); + </script> + + + + <!-- + after this line is purely informational stuff. + does not affect on Flowplayer functionality + --> + + <p> + If you are running these examples <strong>locally</strong> and not on some webserver you must edit your + <a href="http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html"> + Flash security settings</a>. + </p> + + <p class="less"> + Select "Edit locations" > "Add location" > "Browse for files" and select + flowplayer-x.x.x.swf you just downloaded. + </p> + + + <h2>Documentation</h2> + + <p> + <a href="http://flowplayer.org/documentation/installation/index.html">Flowplayer installation</a> + </p> + + <p> + <a href="http://flowplayer.org/documentation/configuration/index.html">Flowplayer configuration</a> + </p> + + <p> + See this identical page on <a href="http://flowplayer.org/demos/example/index.htm">Flowplayer website</a> + </p> + + </div> + + +</body></html> \ No newline at end of file diff --git a/typo3/contrib/flowplayer/example/style.css b/typo3/contrib/flowplayer/example/style.css new file mode 100644 index 0000000000000000000000000000000000000000..98f090c3c76d15cf968c34a215d687f1a54f6208 --- /dev/null +++ b/typo3/contrib/flowplayer/example/style.css @@ -0,0 +1,41 @@ + +body { + background-color:#fff; + font-family:"Lucida Grande","bitstream vera sans","trebuchet ms",verdana,arial; + text-align:center; +} + +#page { + background-color:#efefef; + width:600px; + margin:50px auto; + padding:20px 150px 20px 50px; + min-height:600px; + border:2px solid #fff; + outline:1px solid #ccc; + text-align:left; +} + +h1, h2 { + letter-spacing:-1px; + color:#2D5AC3; + font-weight:normal; + margin-bottom:-10px; +} + +h1 { + font-size:22px; +} + +h2 { + font-size:18px; +} + +.less { + color:#999; + font-size:12px; +} + +a { + color:#295c72; +} diff --git a/typo3/contrib/flowplayer/expressinstall.swf b/typo3/contrib/flowplayer/expressinstall.swf new file mode 100644 index 0000000000000000000000000000000000000000..bdc3437856cb0ae54bb9423700ba6ec89f35282c Binary files /dev/null and b/typo3/contrib/flowplayer/expressinstall.swf differ diff --git a/typo3/contrib/flowplayer/flowplayer-3.2.7.swf b/typo3/contrib/flowplayer/flowplayer-3.2.7.swf new file mode 100644 index 0000000000000000000000000000000000000000..20a41193f5ba6f63745632946e8ff6c1e52313ca Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer-3.2.7.swf differ diff --git a/typo3/contrib/flowplayer/flowplayer.audio-3.2.2.swf b/typo3/contrib/flowplayer/flowplayer.audio-3.2.2.swf new file mode 100644 index 0000000000000000000000000000000000000000..16aef5c70c6e876ccd9d3eb74e61e7525c78830c Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.audio-3.2.2.swf differ diff --git a/typo3/contrib/flowplayer/flowplayer.audio/LICENSE.txt b/typo3/contrib/flowplayer/flowplayer.audio/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..bab38cb72d259c5e3fb965912a138a62c0dc2c1a --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.audio/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2008, 2009 Flowplayer Oy + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/typo3/contrib/flowplayer/flowplayer.audio/README.txt b/typo3/contrib/flowplayer/flowplayer.audio/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..815e0ee8a18075cd5eefe6809ec7849c49c99a9d --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.audio/README.txt @@ -0,0 +1,57 @@ +Version history: + +3.2.2 +----- +Fixes: +- Now can download cover images from different domains without cross-domain security errors + +3.2.1 +----- +Changes: +- Supports cover images via a 'coverImage' configuration option +- now works with securestreaming plugin +Fixes: +- fix to work properly if accessing the ID3 tag fails because Flash security prevents it +- works better if the file does not have the ID3 tag + +3.2.0 +----- +- added a new plugin event "onDuration" that is dispatched whenever a new duration value is estimated and the +clip.duration value was changed. The new duration value is passed as event argument. + +3.1.3 +----- +- added timeProvider setter as required by the changed StreamProvider interface +- now checks the crossdomain.xml file to allow reading of the ID3 tag when this file is present in the domain + hosting the audio file + +3.1.2 +----- +- compatible with the new ConnectionProvider and URLResolver API + +3.1.1 +----- +Fixes: +- calling closeBuffering() after the audio had finished caused an exception + +3.1.0 +----- +- compatibility with core 3.1 StreamProvider interface + +3.0.4 +----- +- fixed to stop audio when stop() is called + +3.0.3 +----- +- changed to recalculate the duration until the end of the file has been reached, + this is needed to correctly estimate the duration of variable bitrate MP3's + +3.0.2 +----- +- dispatches the LOAD event when initialized (needed for flowplayer 3.0.2 compatibility) +- fixed crashes of Mac Safari when navigating out of a page that had a playing audio + +3.0.1 +----- +- First public beta release diff --git a/typo3/contrib/flowplayer/flowplayer.audio/build.properties b/typo3/contrib/flowplayer/flowplayer.audio/build.properties new file mode 100644 index 0000000000000000000000000000000000000000..87eaa3990ce76ac19defad6791e700de13743cd7 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.audio/build.properties @@ -0,0 +1,2 @@ +version=3.2.2 +devkit-dir=../flowplayer.devkit \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.audio/build.xml b/typo3/contrib/flowplayer/flowplayer.audio/build.xml new file mode 100644 index 0000000000000000000000000000000000000000..6692d0e062cd737d0f1837422dc4f8a20bd35e59 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.audio/build.xml @@ -0,0 +1,28 @@ +<project name="Audio plugin for flowplayer" default="deploy"> + <property file="build.generated.properties"/> + <property file="${user.home}/plugin.properties" /> + <property file="build.properties" /> + + <property file="${devkit-dir}/plugin-build.properties" /> + <import file="${devkit-dir}/plugin-build.xml"/> + <property name="flowplayer_lib" value="${devkit-dir}/flowplayer.swc" /> + + <property name="basename" value="flowplayer.audio" /> + <property name="releasedir" value="flowplayer.audio" /> + <property name="plugin-binary" value="${basename}.swf" /> + <property name="plugin-binary-versioned" value="${basename}-${version}.swf" /> + <property name="plugin-swc" value="${basename}.swc" /> + + <property name="plugin-main-class" value="org/flowplayer/audio/AudioProviderFactory.as" /> + + <target name="release" description="makes a release" depends="build"> + <copyrelease targetdir="flowplayer.audio"> + <releasefiles> + <fileset dir="${build-dir}"> + <include name="${plugin-binary-versioned}"/> + </fileset> + </releasefiles> + </copyrelease> + </target> + +</project> \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.audio/src/actionscript/org/flowplayer/audio/AudioProvider.as b/typo3/contrib/flowplayer/flowplayer.audio/src/actionscript/org/flowplayer/audio/AudioProvider.as new file mode 100644 index 0000000000000000000000000000000000000000..0eefb8f0324c381f45aa249a5133a375eb1c168f --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.audio/src/actionscript/org/flowplayer/audio/AudioProvider.as @@ -0,0 +1 @@ +/* * Copyright (c) 2008-2011 Flowplayer Oy * * This file is part of FlowPlayer. * * FlowPlayer is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * FlowPlayer is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. */ package org.flowplayer.audio { import flash.display.DisplayObject; import flash.display.Loader; import flash.events.Event; import flash.events.IOErrorEvent; import flash.events.ProgressEvent; import flash.events.TimerEvent; import flash.media.ID3Info; import flash.media.Sound; import flash.media.SoundChannel; import flash.media.SoundLoaderContext; import flash.net.NetConnection; import flash.net.NetStream; import flash.net.URLRequest; import flash.utils.Dictionary; import flash.utils.Timer; import org.flowplayer.controller.ClipURLResolverHelper; import org.flowplayer.controller.ConnectionProvider; import org.flowplayer.controller.ResourceLoader; import org.flowplayer.controller.StreamProvider; import org.flowplayer.controller.TimeProvider; import org.flowplayer.controller.VolumeController; import org.flowplayer.model.Clip; import org.flowplayer.model.ClipEvent; import org.flowplayer.model.ClipEventType; import org.flowplayer.model.DisplayProperties; import org.flowplayer.model.Playlist; import org.flowplayer.model.Plugin; import org.flowplayer.model.PluginEventType; import org.flowplayer.model.PluginModel; import org.flowplayer.util.Log; import org.flowplayer.view.Flowplayer; /** * @author api */ public class AudioProvider implements StreamProvider, Plugin { private var log:Log = new Log(this); private var _sound:Sound; private var _playing:Boolean; private var _paused:Boolean; private var _durationSeconds:Number; private var _clip:Clip; private var _pausedPosition:Number; private var _channel:SoundChannel; private var _playlist:Playlist; private var _progressTimer:Timer; private var _seeking:Boolean; private var _started:Boolean; private var _volumeController:VolumeController; private var _pauseAfterStart:Boolean; private var _bufferFullDispatched:Boolean; private var _timeProvider:TimeProvider; private var _model:PluginModel; private var _lastDurationDispatched:Number = 0; private var _imageLoader:ResourceLoader; private var _imageDisplay:Loader = null; private var context:SoundLoaderContext; private var _screen:DisplayProperties; private var _clipUrlResolverHelper:ClipURLResolverHelper; public function stopBuffering():void { closeSound(); resetState(); } public function stop(event:ClipEvent, closeStream:Boolean = false):void { seek(null, 0); if (_channel) { log.debug("in stop(), stopping channel"); _channel.stop(); } if (closeStream) { closeSound(); } resetState(); if (event && _clip) { _clip.dispatchEvent(event); } } private function closeSound():void { try { _sound.close(); } catch (e:Error) { // ignore } } private function resetState():void { _playing = false; _paused = false; _started = false; _bufferFullDispatched = false; _durationSeconds = 0; _pausedPosition = 0; if (_progressTimer) { _progressTimer.stop(); } } public function attachStream(video:DisplayObject):void { } private function doLoad():void { } public function load(event:ClipEvent, clip:Clip, pauseAfterStart:Boolean = true):void { log.debug("load()"); resetState(); if (_clip == clip) { log.debug("load() reusing existing sound object"); addListeners(_sound); play(0); _clip.dispatch(ClipEventType.BEGIN); _clip.dispatch(ClipEventType.START); } else { log.debug("load() creating new sound object"); _clip = clip; _sound = new Sound(); context = new SoundLoaderContext(1000, true); if (clip.getCustomProperty("coverImage")) { var cover:Object = getCoverImage(clip); log.debug("Loading Artwork For Audio " + cover.url); // _imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageComplete); // _imageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onImageError); _imageLoader.load(cover.url, onImageComplete); } else { playAudio(); } } _pauseAfterStart = pauseAfterStart; } private function getCoverImage(clip:Clip):Object { var cover:Object = clip.getCustomProperty("coverImage"); if (cover is String) return { url: "" + cover }; if (cover.hasOwnProperty("scaling")) { _clip.setScaling(cover["scaling"]); } return cover; } private function playAudio():void { addListeners(_sound); _clipUrlResolverHelper.resolveClipUrl(_clip, function onClipUrlResolved(clip:Clip):void { _sound.load(new URLRequest(clip.url), context); play(0); }); } private function onImageError(error:IOErrorEvent):void { log.debug("Cover artwork doesn't exist playing now"); playAudio(); } private function onImageComplete(loader:ResourceLoader):void { log.debug("Cover image loaded playing now"); _imageDisplay = loader.getContent() as Loader; _clip.originalWidth = _imageDisplay.width; _clip.originalHeight = _imageDisplay.height; playAudio(); } private function addListeners(sound:Sound):void { sound.addEventListener(ProgressEvent.PROGRESS, onProgress); sound.addEventListener(Event.SOUND_COMPLETE, onComplete); sound.addEventListener(IOErrorEvent.IO_ERROR, onIoError); sound.addEventListener(Event.ID3, onId3); _progressTimer = new Timer(200); _progressTimer.addEventListener(TimerEvent.TIMER, onProgressTimer); _progressTimer.start(); } private function onIoError(event:IOErrorEvent):void { log.error("Unable to load audio file: " + event.text); //dispatching this error causes crashes in Safari: // _clip.dispatch(ClipEventType.ERROR, "Unable to load audio file: " + event.text); } private function addId3Metadata():void { var metadata:Object = new Object(); try { var tag:ID3Info = _sound.id3; } catch (e:Error) { log.warn("unable to access ID3 tag: " + e); } for (var prop:String in tag) { log.debug(prop + ": " + _sound.id3[prop]); metadata[prop] = _sound.id3[prop]; } _clip.metaData = metadata; } private function onId3(event:Event):void { log.debug("onId3(), _started == " + _started); addId3Metadata(); if (_started) return; log.debug("dispatching START"); _clip.dispatch(ClipEventType.METADATA); _clip.dispatch(ClipEventType.START); _started = true; if (_pauseAfterStart) { pause(new ClipEvent(ClipEventType.PAUSE)); } } private function onProgress(event:ProgressEvent):void { if (_playing) return; _playing = true; _clip.dispatch(ClipEventType.BEGIN); if (!_clip.metaData) { _clip.dispatch(ClipEventType.START); } } private function onProgressTimer(event:TimerEvent):void { estimateDuration(); if (! _sound.bytesTotal > 0) return; if (! _sound.bytesLoaded > 0) return; if(_sound.isBuffering == true && _sound.bytesTotal > _sound.bytesLoaded) { _clip.dispatch(ClipEventType.BUFFER_EMPTY); } else if (! _bufferFullDispatched){ _clip.dispatch(ClipEventType.BUFFER_FULL); _bufferFullDispatched = true; } } private function estimateDuration():void { var durationSecs:Number = (_sound.length/(_sound.bytesLoaded/_sound.bytesTotal))/1000; if (Math.abs(_lastDurationDispatched - durationSecs) >= 0.5) { _lastDurationDispatched = durationSecs; log.debug("dispatching onDuration(), " + durationSecs); _model.dispatch(PluginEventType.PLUGIN_EVENT, "onDuration", durationSecs); } _clip.durationFromMetadata = durationSecs; } private function onComplete(event:Event):void { // dispatch a before event because the finish has default behavior that can be prevented by listeners _clip.dispatchBeforeEvent(new ClipEvent(ClipEventType.FINISH)); } public function getVideo(clip:Clip):DisplayObject { log.debug("getVideo() " + _imageDisplay); return _imageDisplay; } public function resume(event:ClipEvent):void { log.debug("resume"); _paused = false; play(_pausedPosition); if (event) { _clip.dispatchEvent(event); } } public function pause(event:ClipEvent):void { log.debug("pause"); _paused = true; _pausedPosition = _channel.position; _channel.stop(); if (event) { _clip.dispatchEvent(event); } } public function seek(event:ClipEvent, seconds:Number):void { if (! _channel) return; _channel.stop(); _seeking = true; play(seconds * 1000); if (event && _clip) { _clip.dispatchEvent(event); } if (_paused) { _pausedPosition = _channel.position; _channel.stop(); } } private function play(posMillis:Number):void { _channel = _sound.play(posMillis, 0); _volumeController.soundChannel = _channel; } public function get stopping():Boolean { return false; } public function get allowRandomSeek():Boolean { return false; } public function get bufferStart():Number { return 0; } public function get playlist():Playlist { return _playlist; } public function get time():Number { if (_timeProvider) { return _timeProvider.getTime(null); } return _channel ? _channel.position / 1000 : 0; } public function get bufferEnd():Number { return _sound && _clip ? _sound.bytesLoaded / _sound.bytesTotal * _clip.duration : 0; } public function get fileSize():Number { return _sound ? _sound.bytesLoaded : 0; } public function set playlist(playlist:Playlist):void { _playlist = playlist; } public function set netStreamClient(client:Object):void { } public function set volumeController(controller:VolumeController):void { _volumeController = controller; } public function onConfig(model:PluginModel):void { _model = model; model.dispatchOnLoad(); } public function getDefaultConfig():Object { return null; } public function onLoad(player:Flowplayer):void { _imageLoader = player.createLoader(); _screen = player.pluginRegistry.getPlugin("screen") as DisplayProperties; _clipUrlResolverHelper = new ClipURLResolverHelper(player, this); } public function addConnectionCallback(name:String, listener:Function):void { } public function addStreamCallback(name:String, listener:Function):void { } public function get netStream():NetStream { return null; } public function get netConnection():NetConnection { return null; } public function getDefaultConnectionProvider():ConnectionProvider { return null; } public function set timeProvider(timeProvider:TimeProvider):void { _timeProvider = timeProvider; } /** * the value of this property is "audio" */ public function get type():String { return "audio"; } public function switchStream(event:ClipEvent, clip:Clip, netStreamPlayOptions:Object = null):void { } public function get streamCallbacks():Dictionary { return null; } } } \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.audio/src/actionscript/org/flowplayer/audio/AudioProviderFactory.as b/typo3/contrib/flowplayer/flowplayer.audio/src/actionscript/org/flowplayer/audio/AudioProviderFactory.as new file mode 100644 index 0000000000000000000000000000000000000000..88e6c874b6d345c75e90f0309f7ebcaa7f5d01f3 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.audio/src/actionscript/org/flowplayer/audio/AudioProviderFactory.as @@ -0,0 +1 @@ +/* * Copyright (c) 2008-2011 Flowplayer Oy * * This file is part of FlowPlayer. * * FlowPlayer is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * FlowPlayer is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. */ package org.flowplayer.audio { import org.flowplayer.model.PluginFactory; import flash.display.Sprite; /** * @author api */ public class AudioProviderFactory extends Sprite implements PluginFactory { public function newPlugin():Object { return new AudioProvider(); } } } \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.captions-3.2.3.swf b/typo3/contrib/flowplayer/flowplayer.captions-3.2.3.swf new file mode 100644 index 0000000000000000000000000000000000000000..5f1d773cebadc3acfe508f56e718e44a10d391dc Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions-3.2.3.swf differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/LICENSE.txt b/typo3/contrib/flowplayer/flowplayer.captions/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..7f04a6280468d5adb90d194b72a8cf5246a2e66b --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2009 Flowplayer Ltd + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/typo3/contrib/flowplayer/flowplayer.captions/README.txt b/typo3/contrib/flowplayer/flowplayer.captions/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..3301f7fd2c9c0a6cc5ebcaa32275be8c3aa2bc58 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/README.txt @@ -0,0 +1,52 @@ +Version history: + +3.2.3 +----- +- The external method names are now loadCaptions() and addCaptions() + +3.2.2 +----- +- Added support for MP4 embedded captions, issue #122. Demo: http://ec2-75-101-198-99.compute-1.amazonaws.com:8080/plugins/flash/captions.html + +3.2.1 +----- +- Added ability to have line breaks with timed text caption files: +<p begin = "00:00:00.01" dur="04.00"> + A lazy fox jumps<br/>over a busy cat +</p> + +3.2.0 +----- +- Fixed visibility issue +- Fixed multiple lines subtitles (#36) +- Increasing font size when going fullscreen (#37) +- Clip's autoPlay field wasn't taken in account (#66) +- Wrong resize when going fullscreen if caption view was not displayed + +3.1.4 +----- +- Timed Text parsing was fixed + +3.1.3 +----- +Fixes: +- loadCaptions() now removes all previous captions before adding the loaded ones + +3.1.2 +------ +- Now the captions can be initially made invisible by just specifying display: 'none' in the content plugin that is used + to show the captions + +3.1.1 +----- +- added a file extension parameter to the loadCaptions external method + +3.1.0 +----- +- added a button to toggle the captions, new config option 'button' can be used to control it +- fixed error appearing in Firebug console with Timed Text captions: http://flowplayer.org/forum/8/16030) + + +3.0.0 +----- +- the first release diff --git a/typo3/contrib/flowplayer/flowplayer.captions/build.properties b/typo3/contrib/flowplayer/flowplayer.captions/build.properties new file mode 100644 index 0000000000000000000000000000000000000000..fd0a52f8d2591ac734089d344da234ba359b00e6 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/build.properties @@ -0,0 +1,2 @@ +devkit-dir=../flowplayer.devkit +version=3.2.3 \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.captions/build.xml b/typo3/contrib/flowplayer/flowplayer.captions/build.xml new file mode 100644 index 0000000000000000000000000000000000000000..a26abb7ebe29f6e242b44754f58f9e909d604ceb --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/build.xml @@ -0,0 +1,28 @@ +<project name="Flowplayer captions" default="deploy"> + <property file="build.generated.properties"/> + <property file="${user.home}/plugin.properties" /> + <property file="build.properties" /> + + <property file="${devkit-dir}/plugin-build.properties" /> + <import file="${devkit-dir}/plugin-build.xml"/> + <property name="flowplayer_lib" value="${devkit-dir}/flowplayer.swc" /> + + <property name="basename" value="flowplayer.captions" /> + <property name="releasedir" value="flowplayer.captions" /> + <property name="plugin-binary" value="${basename}.swf" /> + <property name="plugin-binary-versioned" value="${basename}-${version}.swf" /> + <property name="plugin-swc" value="${basename}.swc" /> + + <property name="plugin-main-class" value="org/flowplayer/captions/Caption.as" /> + + <target name="release" description="makes a release" depends="build"> + <copyrelease targetdir="flowplayer.captions"> + <releasefiles> + <fileset dir="${build-dir}"> + <include name="${plugin-binary-versioned}"/> + </fileset> + </releasefiles> + </copyrelease> + </target> + +</project> \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/casa.dfxp.xml b/typo3/contrib/flowplayer/flowplayer.captions/example/casa.dfxp.xml new file mode 100644 index 0000000000000000000000000000000000000000..855b7e91f9b7b7f8902ce89a99bc11ef1c91ac0c --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/example/casa.dfxp.xml @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?> <tt xml:lang="en" xmlns="http://www.w3.org/2006/10/ttaf1" xmlns:tts="http://www.w3.org/2006/10/ttaf1#styling"> <head> <styling> <style id="1" tts:textAlign="left" tts:fontFamily="_sans" tts:color="#ffffff" tts:backgroundColor="#00000050" /> </styling> </head> <body id="text"> <div xml:lang="en" > <p begin="0:00:05.59" end="0:00:10.46" style="1">Ive heard of other programs like this but most of them are all geared toward the engineers</p> <p begin="0:00:05.59" end="0:00:10.46" style="1">I've heard of other programs like this but most of them are all geared toward the engineers</p> <p begin="0:00:10.46" end="0:00:16.48" style="1">or it's the final year of the engineer that you finally get to build a project</p> <p begin="0:00:16.48" end="0:00:20.07" style="1">some culmination for all your work we've been doing that the whole four years</p> <p begin="0:00:20.07" end="0:00:25.58" style="1">that we've been here and it really does make for an incredible learning environment</p> <p begin="0:00:25.58" end="0:00:29.72" style="1">The professors are very one on one with the students and individualize with us</p> <p begin="0:00:29.72" end="0:00:33.89" style="1">it's more of a friendship with the teachers instead of just a professor</p> <p begin="0:00:33.89" end="0:00:38.14" style="1">in a regular lecture hall or something it's more one on one</p> <p begin="0:00:38.14" end="0:00:43.70" style="1"> You got your different majors in CASA I'm in EST and then there's like four areas of study</p> <p begin="0:00:43.70" end="0:00:49.30" style="1">that go into that your biomedical networking communications and industrial electronics technology</p> <p begin="0:00:49.30" end="0:00:52.64" style="1">I plan to work in a dental office as a dental hygienist</p> <p begin="0:00:52.64" end="0:00:57.90" style="1">Southern was the only dental hygiene school in Illinois that has a bachelor's degree</p> <p begin="0:00:57.90" end="0:01:05.13" style="1">in dental hygiene and we perform cleanings on children at schools, visit nursing homes</p> <p begin="0:01:05.13" end="0:01:10.46" style="1">and perform cleanings there We just get alot of experience outside of school</p> <p begin="0:01:10.46" end="0:01:11.80" style="1">to get us ready for the real world</p> <p begin="0:01:11.80" end="0:01:15.63" style="1">I have a really good time with this especially when we do work in the 737</p> <p begin="0:01:15.63" end="0:01:21.72" style="1">Our professors and instructors push us to get things going like this plane we pretty much</p> <p begin="0:01:21.72" end="0:01:27.36" style="1">got it running a couple of years ago and now its pretty much fully operational Its great</p> <p begin="0:01:27.36" end="0:01:32.35" style="1">and you learn so much you get a lot of hands on experience working on live aircraft like this</p> <p begin="0:01:32.35" end="0:01:37.30" style="1">The glass cockpit is two 15 inch screens those screens provide you with all the information</p> <p begin="0:01:37.30" end="0:01:41.10" style="1">that each gauge used to provide and it provides it in one centralized location</p> <p begin="0:01:41.10" end="0:01:45.00" style="1">besides that it also provides a moving map like GPS type display</p> <p begin="0:01:45.00" end="0:01:48.90" style="1">I would definitely say it’s a very good option they are providing us now</p> <p begin="0:01:48.90" end="0:01:53.86" style="1">The club is an organization of students that kind of wanted to go beyond the classroom</p> <p begin="0:01:53.86" end="0:01:59.28" style="1">The whole point of it was you know this is what we do with what we learn every concept</p> <p begin="0:01:59.28" end="0:02:04.57" style="1">that they picked up in all their classes digital analog discreet everything they applied in</p> <p begin="0:02:04.57" end="0:02:08.90" style="1">in the dawgzooka project They started looking around at parts they asked the SIU Police</p> <p begin="0:02:08.90" end="0:02:13.76" style="1">department they donated several old bomb disposal chassis that they could build on</p> <p begin="0:02:13.76" end="0:02:19.17" style="1">and these principles they apply is what culminates into that final product</p> <p begin="0:02:19.17" end="0:02:23.66" style="1">it’s great just build of everything that you learn</p> <p begin="0:02:23.66" end="0:02:26.90" style="1">SIU is one of the only state schools that offers this program</p> <p begin="0:02:26.90" end="0:02:29.64" style="1">that’s one of the main reasons is because it is a bachelors degree program</p> <p begin="0:02:29.64" end="0:02:34.06" style="1">and it’s got the option for three different specializations</p> <p begin="0:02:34.06" end="0:02:38.37" style="1">you’ve got CTMRI ultrasound and then you’ve got radiation therapy</p> <p begin="0:02:38.37" end="0:02:43.75" style="1">I see it as the ability to pursue different job opportunities and also job security</p> <p begin="0:02:43.75" end="0:02:47.50" style="1">mostly we’r e all really excited about clinicals because you don’t have to take any classes</p> <p begin="0:02:47.50" end="0:02:51.95" style="1">when your doing it and it’s just kind of a real relief to be out working rather than</p> <p begin="0:02:51.95" end="0:02:53.67" style="1">taking classes all the time</p> <p begin="0:02:53.67" end="0:02:57.91" style="1">That second semester when you got out to clinics and you actually had a real patient</p> <p begin="0:02:57.91" end="0:03:05.25" style="1">you had real life scenarios and your working with real people that were trained to do the same</p> <p begin="0:03:05.25" end="0:03:10.91" style="1">thing and you’re their as a student but your being treated essentially as an equal</p> <p begin="0:03:10.91" end="0:03:15.92" style="1">and you get that real life experience and it just adds to your education</p> <p begin="0:03:15.92" end="0:03:24.07" style="1"></p> </div> </body> </tt> \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/casa.dfxp.xml.1 b/typo3/contrib/flowplayer/flowplayer.captions/example/casa.dfxp.xml.1 new file mode 100644 index 0000000000000000000000000000000000000000..542d416017774d70a52c3e78fb893d8a8a8bee0e --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/example/casa.dfxp.xml.1 @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> +<tt xmlns="http://www.w3.org/2006/04/ttaf1" + xmlns:tts="http://www.w3.org/2006/04/ttaf1#styling" xml:lang="en"> + <head> + <styling> + + <style id="1" tts:textAlign="left" tts:fontFamily="_sans" tts:color="#ffffff" tts:backgroundColor="#00000050" /> +</styling> + </head> + <body id="text"> + <div id="1" xml:lang="en"> + <p begin="0:00:05.59" end="0:00:10.46" style="1">I've heard of other programs like this but most of them are all geared toward the engineers</p> + <p begin="0:00:10.46" end="0:00:16.48" style="1">or it's the final year of the engineer that you finally get to build a project</p> + <p begin="0:00:16.48" end="0:00:20.07" style="1">some culmination for all your work we've been doing that the whole four years</p> + <p begin="0:00:20.07" end="0:00:25.58" style="1">that we've been here and it really does make for an incredible learning environment</p> + <p begin="0:00:25.58" end="0:00:29.72" style="1">The professors are very one on one with the students and individualize with us</p> + <p begin="0:00:29.72" end="0:00:33.89" style="1">it's more of a friendship with the teachers instead of just a professor</p> + <p begin="0:00:33.89" end="0:00:38.14" style="1">in a regular lecture hall or something it's more one on one</p> + <p begin="0:00:38.14" end="0:00:43.70" style="1"> You got your different majors in CASA I'm in EST and then there's like four areas of study</p> + <p begin="0:00:43.70" end="0:00:49.30" style="1">that go into that your biomedical networking communications and industrial electronics technology</p> + <p begin="0:00:49.30" end="0:00:52.64" style="1">I plan to work in a dental office as a dental hygienist</p> + <p begin="0:00:52.64" end="0:00:57.90" style="1">Southern was the only dental hygiene school in Illinois that has a bachelor's degree</p> + <p begin="0:00:57.90" end="0:01:05.13" style="1">in dental hygiene and we perform cleanings on children at schools, visit nursing homes</p> + <p begin="0:01:05.13" end="0:01:10.46" style="1">and perform cleanings there We just get alot of experience outside of school</p> + <p begin="0:01:10.46" end="0:01:11.80" style="1">to get us ready for the real world</p> + <p begin="0:01:11.80" end="0:01:15.63" style="1">I have a really good time with this especially when we do work in the 737</p> + <p begin="0:01:15.63" end="0:01:21.72" style="1">Our professors and instructors push us to get things going like this plane we pretty much</p> + <p begin="0:01:21.72" end="0:01:27.36" style="1">got it running a couple of years ago and now its pretty much fully operational Its great</p> + <p begin="0:01:27.36" end="0:01:32.35" style="1">and you learn so much you get a lot of hands on experience working on live aircraft like this</p> + <p begin="0:01:32.35" end="0:01:37.30" style="1">The glass cockpit is two 15 inch screens those screens provide you with all the information</p> + <p begin="0:01:37.30" end="0:01:41.10" style="1">that each gauge used to provide and it provides it in one centralized location</p> + <p begin="0:01:41.10" end="0:01:45.00" style="1">besides that it also provides a moving map like GPS type display</p> + <p begin="0:01:45.00" end="0:01:48.90" style="1">I would definitely say it’s a very good option they are providing us now</p> + <p begin="0:01:48.90" end="0:01:53.86" style="1">The club is an organization of students that kind of wanted to go beyond the classroom</p> + <p begin="0:01:53.86" end="0:01:59.28" style="1">The whole point of it was you know this is what we do with what we learn every concept</p> + <p begin="0:01:59.28" end="0:02:04.57" style="1">that they picked up in all their classes digital analog discreet everything they applied in</p> + <p begin="0:02:04.57" end="0:02:08.90" style="1">in the dawgzooka project They started looking around at parts they asked the SIU Police</p> + <p begin="0:02:08.90" end="0:02:13.76" style="1">department they donated several old bomb disposal chassis that they could build on</p> + <p begin="0:02:13.76" end="0:02:19.17" style="1">and these principles they apply is what culminates into that final product</p> + <p begin="0:02:19.17" end="0:02:23.66" style="1">it’s great just build of everything that you learn</p> + <p begin="0:02:23.66" end="0:02:26.90" style="1">SIU is one of the only state schools that offers this program</p> + <p begin="0:02:26.90" end="0:02:29.64" style="1">that’s one of the main reasons is because it is a bachelors degree program</p> + <p begin="0:02:29.64" end="0:02:34.06" style="1">and it’s got the option for three different specializations</p> + <p begin="0:02:34.06" end="0:02:38.37" style="1">you’ve got CTMRI ultrasound and then you’ve got radiation therapy</p> + <p begin="0:02:38.37" end="0:02:43.75" style="1">I see it as the ability to pursue different job opportunities and also job security</p> + <p begin="0:02:43.75" end="0:02:47.50" style="1">mostly we’r e all really excited about clinicals because you don’t have to take any classes</p> + <p begin="0:02:47.50" end="0:02:51.95" style="1">when your doing it and it’s just kind of a real relief to be out working rather than</p> + <p begin="0:02:51.95" end="0:02:53.67" style="1">taking classes all the time</p> + <p begin="0:02:53.67" end="0:02:57.91" style="1">That second semester when you got out to clinics and you actually had a real patient</p> + <p begin="0:02:57.91" end="0:03:05.25" style="1">you had real life scenarios and your working with real people that were trained to do the same</p> + <p begin="0:03:05.25" end="0:03:10.91" style="1">thing and you’re their as a student but your being treated essentially as an equal</p> + <p begin="0:03:10.91" end="0:03:15.92" style="1">and you get that real life experience and it just adds to your education</p> + <p begin="0:03:15.92" end="0:03:24.07" style="1"></p> + </div> + </body> +</tt> diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/engineering.xml b/typo3/contrib/flowplayer/flowplayer.captions/example/engineering.xml new file mode 100644 index 0000000000000000000000000000000000000000..d9b83664a196d45dcc64d8edf0b7bf971df6e044 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/example/engineering.xml @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?> <tt xml:lang="en" xmlns="http://www.w3.org/2006/10/ttaf1" xmlns:tts="http://www.w3.org/2006/10/ttaf1#styling"> <head> <styling> <style id="1" tts:textAlign="left" tts:fontFamily="_sans" tts:color="#ffffff" tts:backgroundColor="#00000050" /> </styling> </head> <body id="text"> <div xml:lang="en" > <p begin="0:00:05.56" end="0:00:08.34" style="1">The size of SIU I really liked</p> <p begin="0:00:08.35" end="0:00:10.00" style="1">like our community is really tight</p> <p begin="0:00:10.00" end="0:00:12.45" style="1">The college of engineering I know pretty much the whole class</p> <p begin="0:00:12.45" end="0:00:16.00" style="1">because we are so small and your teachers are really friendly</p> <p begin="0:00:16.00" end="0:00:19.12" style="1">and there’s lots of stuff to do here outside and inside</p> <p begin="0:00:19.12" end="0:00:21.19" style="1">At some bigger schools they have</p> <p begin="0:00:21.19" end="0:00:26.19" style="1">hundreds of people in their classrooms and there’s no interaction between the faculty and the students</p> <p begin="0:00:26.19" end="0:00:32.03" style="1">students and down here it's a lot more accommodating to people and individuals</p> <p begin="0:00:32.03" end="0:00:34.27" style="1">I haven't had a professor I don't like yet</p> <p begin="0:00:34.27" end="0:00:37.39" style="1">I really like all of them they are all really passionate about what they do</p> <p begin="0:00:37.39" end="0:00:40.75" style="1">and they all really want you to learn they want you to succeed</p> <p begin="0:00:40.75" end="0:00:44.79" style="1">It's a lot of fun especially classes with labs you get a lot of hands on experience</p> <p begin="0:00:44.79" end="0:00:49.45" style="1">which is nice because it's not all theoretical ideas that your learning</p> <p begin="0:00:49.45" end="0:00:52.98" style="1">you get to apply those concepts that you learn in class</p> <p begin="0:00:52.98" end="0:00:55.27" style="1">You have at least four classes with labs</p> <p begin="0:00:55.27" end="0:00:56.26" style="1">you have design electives</p> <p begin="0:00:56.26" end="0:00:59.20" style="1">where you actually pick apart things and fix things</p> <p begin="0:00:59.20" end="0:01:03.09" style="1">and a design class a senior design class where you build something</p> <p begin="0:01:03.09" end="0:01:06.23" style="1">We participate in all kinds of stuff like volunteer activities</p> <p begin="0:01:06.23" end="0:01:08.90" style="1">the moon buggy team the race car team</p> <p begin="0:01:08.90" end="0:01:10.87" style="1">we go to conferences twice a year</p> <p begin="0:01:10.87" end="0:01:17.38" style="1">we have design competitions we have social events and we participate with all other organizations in the college of engineering</p> <p begin="0:01:17.38" end="0:01:22.64" style="1">We design and build a moon buggy for a competition at the NASA space camp</p> <p begin="0:01:22.64" end="0:01:27.74" style="1">it's nice to have seen what I have seen as well as see the club come as far as it has</p> <p begin="0:01:27.74" end="0:01:30.40" style="1">I don't know anyone who didn't have an internship this summer</p> <p begin="0:01:30.40" end="0:01:35.56" style="1">we've got Caterpillar the Environmental Protection Agency Boeing John Deere</p> <p begin="0:01:35.56" end="0:01:41.52" style="1">Caterpillar is a company I've wanted to work for since I was a little kid playing with my toy Tonka trucks</p> <p begin="0:01:41.52" end="0:01:46.01" style="1">all the big yellow construction machinery that’s exciting for a little kid</p> <p begin="0:01:46.01" end="0:01:48.43" style="1">and continued to be something that I wanted to get into</p> <p begin="0:01:48.43" end="0:01:52.54" style="1">You know we're really proud of this school that we have we've got a really good engineering school</p> <p begin="0:01:52.54" end="0:01:56.21" style="1">and we work really hard to keep it up and keep up our reputations</p> <p begin="0:01:56.21" end="0:01:58.48" style="1">I'm really proud of our hard work</p> </div> </body> </tt> \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/flowplayer.captions.js b/typo3/contrib/flowplayer/flowplayer.captions/example/flowplayer.captions.js new file mode 100644 index 0000000000000000000000000000000000000000..788ab3641a0974582379217b9a875dabe94707b0 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/example/flowplayer.captions.js @@ -0,0 +1,186 @@ +/** + * flowplayer.playlist.js 3.0.0. Flowplayer JavaScript plugin. + * + * This file is part of Flowplayer, http://flowplayer.org + * + * Author: Tero Piirainen, <support@flowplayer.org> + * Copyright (c) 2009 Flowplayer Ltd + * + * Dual licensed under MIT and GPL 2+ licenses + * SEE: http://www.opensource.org/licenses + * + * Version: 3.0.0 - Tue Nov 25 2008 16:30:11 GMT-0000 (GMT+00:00) + */ +(function($) { + + $f.addPlugin("captions", function(container, options) { + + // self points to current Player instance + var self = this; + var api = null; + var opts = { + activeClass: 'active', + template: '<img src="images/${time}.jpg"/>', + padTime: true, + fadeTime: 500 + }; + + $.extend(opts, options); + var wrap = container; + var template = null; + + //wrap = $(wrap); + //alert(wrap.html()); + //var template = wrap.is(":empty") ? opts.template : wrap.html(); + var el = ""; + //wrap.empty(); + + + function seek() + { + var status = api.getStatus(); + alert(status.index); + } + + function parseTemplate(values) + { + $.each(values, function(key, val) { + + if (typeof val == 'object') + { + parseTemplate(key); + } else { + if (key == "time") { + val = Math.round(val / 1000); + if (opts.padTime && val < 10) val = "0" + val; + } + + el = el.replace("$\{" +key+ "\}", val).replace("$%7B" +key+ "%7D", val); + + } + }); + } + + // onStart + self.onStart(function(clip) { + + var index = 1; + + wrap = $(wrap); + template = wrap.is(":empty") ? opts.template : wrap.html(); + wrap.fadeOut(opts.fadeTime).empty(); + + // wrap.empty(); + + $.each(clip.cuepoints, function(key, val) { + + el = template; + if (val !== null) { + var time = Math.round(val[0].time / 1000); + parseTemplate(val[0]); + + el = $(el); + el.attr("index",index); + index++; + el.click(function() { + self.seek(time); + api.seekTo($(this).attr("index")); + //api.next(); + }); + + wrap.append(el); + } + }); + + if (wrap.parent().css('display') == "none") { + wrap.show(); + wrap.parent('div').fadeIn(opts.fadeTime); + } else { + wrap.fadeIn(opts.fadeTime); + } + + + $(wrap.parent()).scrollable({items:wrap,size:4, clickable:true, activeClass: opts.activeClass}); + api = $(wrap.parent()).scrollable(); + + + $("a.prevPage").click(function() { + api.prevPage(500); + }); + + $("a.prevPage").mouseover(function() { + api.prevPage(500); + }); + + $("a.nextPage").click(function() { + api.nextPage(500); + }); + + $("a.nextPage").mouseover(function() { + api.nextPage(500); + }); + + els = wrap.children(); + + + }); + + + self.onCuepoint(function(clip, cuepoint) { + + //var cue = els.filter("[@time=" + cuepoint.time + "]"); + //api.move(); + api.next(); + // alert(api.getIndex()); + //alert(wrap.html()); + //self.getPlugin("scrollable").next(); + //console.log(cue.text()); + //alert(cuepoint.time); + //alert("embedded cuepoint entered, time: " + cuepoint.time); + }); + /* + // onPause + self.onPause(function(clip) { + getEl(clip).removeClass(opts.playingClass).addClass(opts.pausedClass); + }); + + // onResume + self.onResume(function(clip) { + getEl(clip).removeClass(opts.pausedClass).addClass(opts.playingClass); + }); + + // what happens when clip ends ? + if (!opts.loop && !manual) { + + // stop the playback exept on the last clip, which is stopped by default + self.onBeforeFinish(function(clip) { + if (clip.index < els.length -1) { + return false; + } + }); + }*/ + + // on manual setups perform looping here + /*if (manual && opts.loop) { + self.onBeforeFinish(function(clip) { + var el = getEl(clip); + if (el.next().length) { + el.next().click(); + } else { + els.eq(0).click(); + } + return false; + }); + }*/ + + // onUnload + self.onUnload(function() { + clearCSS(); + }); + + + return self; + + }); + +})(jQuery); diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/flvtool2-cuepoints.sh b/typo3/contrib/flowplayer/flowplayer.captions/example/flvtool2-cuepoints.sh new file mode 100644 index 0000000000000000000000000000000000000000..a69dc043e3d9011642f653799e34cdb6aea045c0 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/example/flvtool2-cuepoints.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# /usr/local/bin/cuepoints +# +# Generate an XML file used by FLVTool2 to add cuepoints to a flash file +# The XML file adds a cuepoint every ten seconds, to line up with timestamps +# +# Syntax: cuepoints [<seconds>] [<filename>] +# cuepoints 1800 cuepoints-1800.xml +# cuepoints 7200 +# cuepoints +# +# Options for start time and interval could be added +# +# ----------------------------------------------------------------------------- + +# Add a help screen +if [ "$1" = "-h" -o "$1" = "--help" -o "$1" = "help" ] + then echo -e "\ncuepoints [<seconds>] [<filename>]" + echo -e "\tThe cuepoints script creates an XML file used by FLVTool2 to add cuepoints to a flash file" + echo -e "\nSyntax:" + echo -e "\tcuepoints \t\t(defaults to 3600 seconds, or one hour, written to cuepoints.xml)" + echo -e "\tcuepoints 1800 \t\t(create cuepoints for a half-hour file)" + echo -e "\tcuepoints 1800 cuepoints-1800.xml\t(specify a filename)\n" + exit +fi + +echo -e "\nCreating cuepoints.xml, used by FLVTool2 to add cuepoints to a flash file \ +(see \"cuepoints help\" for syntax and options)\n" + +# Check for length +if [ "$1" = "" ] + then LENGTH="3600" + else LENGTH="$1" +fi + +# Check for filename +if [ "$2" = "" ] + then FIL="cuepoints.xml" + else FIL="$2" +fi + +# Write the header +echo "<?xml version=\"1.0\"?>" > $FIL +echo "<tags>" >> $FIL +echo " <!-- navigation cue points -->" >> $FIL + +# Write the body +for N in $(seq 0 10 $LENGTH) +do + NAME="$( echo $(date -d "+$N seconds"\ 00:00:00 +%H:%M:%S) )" + echo " <metatag event=\"onCuePoint\">" >> $FIL + echo " <name>"$NAME"</name>" >> $FIL + echo " <timestamp>"$N"000</timestamp>" >> $FIL + echo " <type>navigation</type>" >> $FIL + echo " </metatag>" >> $FIL +done + +# Write the footer +echo "</tags>" >> $FIL + +echo -e "An XML file specifying $LENGTH timestamps has been written to $FIL\n" + +echo -e "To create a flash file with these cuepoints, use \"flvtool2 -AUPt cuepoints.xml input.flv output.flv\"\n" + diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/left.png b/typo3/contrib/flowplayer/flowplayer.captions/example/images/left.png new file mode 100644 index 0000000000000000000000000000000000000000..bb9c9a71f5b46e1432124b50fff35379473c201a Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/left.png differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/right.png b/typo3/contrib/flowplayer/flowplayer.captions/example/images/right.png new file mode 100644 index 0000000000000000000000000000000000000000..469a229064d16673e1fc125cc273f912acd9a6c4 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/right.png differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame00.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame00.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6181408d3d7bbae0f6241dcf99611bd3bfe42adf Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame00.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame01.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame01.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e71736658ae31506ab12f2339e717910a44915b2 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame01.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame02.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame02.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0731d10ed96c316688ffaba245c2b30175363669 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame02.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame03.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame03.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0d5a9edc384c50cf8579f93b10fde4367ea54c3c Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame03.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame04.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame04.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d92086441dfa6fa6b67ae7757a52d1d944f455c0 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame04.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame05.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame05.jpg new file mode 100644 index 0000000000000000000000000000000000000000..39a7d6a2f4382383bdc853dca81ae3a844076856 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame05.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame06.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame06.jpg new file mode 100644 index 0000000000000000000000000000000000000000..54da9332d7367959ac0eebc6ba90997b7c9fe81f Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame06.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame07.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame07.jpg new file mode 100644 index 0000000000000000000000000000000000000000..fdcff6946e1d0253cfd7cd42aa08a6eb169527e3 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame07.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame08.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame08.jpg new file mode 100644 index 0000000000000000000000000000000000000000..378c5fbf087f16637035f8bf4ccda92663186c8d Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame08.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame09.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame09.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2c0c57a22469445099979cd98c771ac481658fc4 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame09.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame10.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame10.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c6747cbf9d92a6eacf364c324b072b9e70cd7494 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame10.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame11.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame11.jpg new file mode 100644 index 0000000000000000000000000000000000000000..182e0509670994a1d6f532dcdde35c62667b870b Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame11.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame12.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame12.jpg new file mode 100644 index 0000000000000000000000000000000000000000..4bf650f803c303c74a26ff71d0ffaa5926ef5e17 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame12.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame13.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame13.jpg new file mode 100644 index 0000000000000000000000000000000000000000..037e7e6308af476abc68a7e1955ae0c9d192a9af Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame13.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame14.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame14.jpg new file mode 100644 index 0000000000000000000000000000000000000000..fd7f99db615717b451013b95f926a906cc7bfda7 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame14.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame15.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame15.jpg new file mode 100644 index 0000000000000000000000000000000000000000..933278d01609b74eb2242313731cf2d35b46094c Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame15.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame16.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame16.jpg new file mode 100644 index 0000000000000000000000000000000000000000..bbf58f9193a9caa0f4d3b53e79be9e71e410aa7a Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame16.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame17.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame17.jpg new file mode 100644 index 0000000000000000000000000000000000000000..51c353fb02b0bb373abc1d4551fc68ac4f2763c8 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame17.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame18.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame18.jpg new file mode 100644 index 0000000000000000000000000000000000000000..5212f662f664eb9bb29e0eba3c28ed43334a905c Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame18.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame19.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame19.jpg new file mode 100644 index 0000000000000000000000000000000000000000..8b04c5e75e88e73a31a86e7e309fc4b7d2119f77 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame19.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame20.jpg b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame20.jpg new file mode 100644 index 0000000000000000000000000000000000000000..985364137de7e776c2a84aa86adb2e83e5835f08 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/example/images/thumbs/frame20.jpg differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/index.html.tmpl b/typo3/contrib/flowplayer/flowplayer.captions/example/index.html.tmpl new file mode 100644 index 0000000000000000000000000000000000000000..918fdba1c07c3d30c2a30f9178edaf2c382926c3 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/example/index.html.tmpl @@ -0,0 +1,1056 @@ +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<!-- + Flowplayer website, forums & jQuery Tools by Tero Piirainen + + Prefer web standards over Flash. Video is the only exception. +--> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + +<head> + + <title>Flowplayer - Flash Video Player for the Web</title> + <meta name="Description" content="Embed video streams to your website. Superior alternative to YouTube. Open Sourced under the GPL license. No other software makes this smoother." /> + <meta name="Keywords" content="video player for the web, flash video player,web media player,free video player,free flv player,mp4 flash player,mp4 player,open source video player,flash 9 video,flash video,web video,flv player,flv video" /> + + + + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <meta name="Distribution" content="Global" /> + <meta name="Author" content="Tero Piirainen" /> + <meta name="Robots" content="index,follow" /> + + + <link rel="stylesheet" type="text/css" href="http://static.flowplayer.org/css/global-0.25.css" /> + + + <script type="text/javascript" src="http://static.flowplayer.org/js/flowplayer-3.2.2.min.js"></script> + <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script> + <script type="text/javascript" src="http://cdn.jquerytools.org/1.2.3/jquery.tools.min.js"></script> + <link rel="stylesheet" type="text/css" href="http://static.flowplayer.org/tools/css/overlay-apple.css"/> + <script type="text/javascript" src="http://flowplayer.org/tools/download/1.2.3/overlay/overlay.apple.min.js"></script> + + <script type="text/javascript" src="flowplayer.captions.js"></script> + + + + <style type="text/css"> + div.overlay { + width:1024px; + height:432px; + + } + + #cuethumbs { + height:115px; + background:#f5fbfb url(/img/global/gradient/h150.png) repeat-x; + padding:5px; + border:1px solid #ddd; + width: 780px; + } + + #cuethumbs div.items { + height:115px; + width: 700px; + float:left; + } + + #cuethumbs div.items img:hover { + border:3px solid #000000; + } + + active { + border:3px solid #CCCCCC; + } + + #cuethumbs div.items img.active { + border:3px solid #CCCCCC; + } + + #cuethumbs div.items img { + border:1px solid #000000; + float:left; + height:113px; + cursor:pointer; + margin-right:7px; + width:150px; + } + + #cuethumbs div.items a:hover { + background-position:-140px 0; + color:#000; + } + + #cuethumbs div.items a.playing { + background-position:-280px 0; + color:#000; + } + + #cuethumbs div.items a.paused { + background-position:-420px 0; + color:#000; + } + + #cuethumbs div.items a.progress { + opacity:0.8; + } + + #cuethumbs div.items em { + float:right; + margin-top:15px; + color:red; + font-style:normal; + } + + #cuethumbs a.nextPage, #cuethumbs a.prevPage { + display:block; + width:18px; + height:18px; + background:url(images/left.png) no-repeat; + margin:30px 10px; + cursor:pointer; + float:left; + } + + #cuethumbs a.nextPage:hover, #cuethumbs a.prevPage:hover { + background-position:0px -18px; + } + + #cuethumbs a.nextPage { + background-image:url(images/right.png); + } + + </style> + + + <!--[if lt IE 7]> + <style type="text/css"> + @import "http://static.flowplayer.org/css/ie6.css?v=0.2"; + </style> + <![endif]--> + + <!--[if lt IE 8]> + <style> + html { overflow-x:hidden; } + #content ol, #content ul {margin-left: 50px; } + </style> + <![endif]--> + +</head> + +<body id="plugins_captions"> + +<div id="wrap"> + + <div id="content"> + +<h1> + Flash plugin: <strong>Captions</strong> + <em>Subtitles for your videos</em> +</h1> + + +<h2>Introduction</h2> + +<p> + The Captions plugin is used to show Closed Captions (CC) for videos. You can supply the Captions information as an external text file. Closed Captioning is a term describing several systems developed to display text on a video screen to provide additional or interpretive information to viewers who wish to access it. The most common use is to provide subtitles for movies. See <a href="http://en.wikipedia.org/wiki/Closed_captioning" class="external">here for more info</a>. +</p> + + +<h2>Features</h2> + +<ul> + <li>Loading subtitles from the Timed Text or Subrip format files.</li> + <li>Styling text from styles set in the Time Text format files.</li> + <li>Loading of subtitles from embedded FLV cuepoints.</li> + <li>Controls an external Content plugin to show the cuepoints.</li> +</ul> + +<p> + <strong>Timed Text</strong> is a W3C specification for delivering captioning and video description for the web. You can find + the spec <a href="http://www.w3.org/AudioVideo/TT/">here in the W3C site</a>. + <strong>SubRip</strong> is a common format for distributing Captions for DVD rips. It is the + native subtitle format of the <a href="http://zuggy.wz.cz/">SubRip program</a>. +</p> + + +<h2>SubRip example</h2> + +<p> + The following shows Captions from a SubRib file. You will need a recent version of Flash installed to view the video that is a H.264 encoded mp4 file. The first subtitle comes after 13 seconds. +</p> + +<!-- player container--> +<a + href="http://vod01.netdna.com/vod/demo.flowplayer/flowplayer-700.flv" + style="display:block;width:500px;height:330px;" + id="player"> + + <!-- splash image inside the container --> + <img src="http://www.flowplayer.org/img/home/flow_eye.jpg" alt="Search engine friendly content" /> + +</a> + +<!-- Flowplayer installation and configuration --> +<script language="JavaScript"> + +$f("player", "@PLAYER_SWF@", { + clip: { + + // here is our high quality movie + //url: 'mp4:buffalo_soldiers.mp4', + url: 'http://video.flowplayer.org/flowplayer.flv', + // this is the SubRib file with captions info + captionUrl: 'http://releases.flowplayer.org/data/buffalo.srt', + + // we want to use RTMP since this is a 1,5 hour long movie. + //provider: 'rtmp' + }, + log: { + level: 'error', + filter: 'org.flowplayer.captions.*' + }, + plugins: { + + // the captions plugin + captions: { + url: '@MAIN_PLAYER_SWF@', + + // pointer to a content plugin (see below) + captionTarget: 'content' + }, + + /* + configure a content plugin so that it + looks good for showing subtitles + */ + content: { + url:'../flowplayer.content.swf', + bottom: 25, + height:40, + backgroundColor: 'transparent', + backgroundGradient: 'none', + border: 0, + textDecoration: 'outline', + style: { + body: { + fontSize: 14, + fontFamily: 'Arial', + textAlign: 'center', + color: '#ffffff' + } + } + }, + + // streaming plugin configuration + rtmp: { + url: '../flowplayer.rtmp.swf', + netConnectionUrl: 'rtmp://flashy.flowplayer.org:1935/fastplay' + }, + + // change default skin to "tube" + controls: { + url: '../flowplayer.controls.swf' + } + + } +}); +</script> + + + + +<div class="box code"> +<pre><code class="javascript">$f("player", "@PLAYER_SWF@", { + clip: { + + // here is our high quality movie + url: 'mp4:buffalo_soldiers.mp4', + + // this is the SubRib file with captions info + captionUrl: 'http://releases.flowplayer.org/data/buffalo.srt', + + // we want to use RTMP since this is a 1,5 hour long movie. + provider: 'rtmp' + }, + plugins: { + + // the captions plugin + captions: { + url: '@MAIN_PLAYER_SWF@', + + // pointer to a content plugin (see below) + captionTarget: 'content' + }, + + /* + configure a content plugin so that it + looks good for showing subtitles + */ + content: { + url:'../flowplayer.content.swf', + bottom: 25, + height:40, + backgroundColor: 'transparent', + backgroundGradient: 'none', + border: 0, + textDecoration: 'outline', + style: { + body: { + fontSize: 14, + fontFamily: 'Arial', + textAlign: 'center', + color: '#ffffff' + } + } + }, + + // streaming plugin configuration + rtmp: { + url: '../flowplayer.rtmp.swf', + netConnectionUrl: 'rtmp://flashy.flowplayer.org:1935/fastplay' + }, + + // change default skin to "tube" + controls: { + url: '../flowplayer.controls.swf' + } + + } +});</code></pre> +</div> + + +<h2>Configuration</h2> + +<p> + Here is a list of all Captions specific clip properties. These go under the <samp>clip</samp> node in the player configuration: +</p> + +<table class="listing"> + <tr> + <th>property</th> + <th>datatype</th> + + <th>default</th> + <th>description</th> + </tr> + <tr> + <td><code>captionUrl</code></td> + <td>String</td> + <td></td> + + <td> + Path to a Timed Text or SubRip Captions file. + </td> + </tr> + <tr> + <td><code>captions</code></td> + <td>array</td> + <td></td> + + <td> + A json array of cuepoint objects ie + { + time: 0, + name: 'cue1', + parameters: { + begin: 0, + end: 4000, + text: 'First caption with default style coming from the Content plugin config' + } + } + </td> + </tr> + <tr> + <td><code>showCaptions</code></td> + <td>boolean</td> + + <td>true</td> + <td> + Show Captions for this clip. You can set this to false if you have embedded Captions in the video and you don't want to show them. + </td> + </tr> +</table> + +<p> + Here is a list of configuration options for the Captions plugin. These go under the Captions <samp>plugin</samp> node in the player configuration: +</p> + +<table class="listing"> + <tr> + <th>property</th> + + <th>description</th> + </tr> + <tr> + <td><code>captionTarget</code></td> + <td> + The name of a Content plugin configured to show the Captions. The plugin needs to be specified in the player's initial configuration. + </td> + + </tr> + + <tr> + <td><code>template</code></td> + <td> + Used with embedded cuepoints. A template string that specifies tokens for names of cuepoint parameters. The tokens are replaced by values that are looked up from the cuepoint parameters. If you embed cuepoints where the subtitles are in the cuepoint parameter called <samp>subtitle</samp>, you should set the use of a template with the value '${subtitle}'. + </td> + </tr> + + <tr> + <td><code>button</code></td> + <td> + <a href="/documentation/configuration/plugins.html#display-properties">Display properties</a> for the CC-button. The default + properties are: <samp>{ width: 20, height: 15, right: 5, bottom: 30, label: 'CC' }</samp>. Specify <samp>null</samp> and the button + is not shown at all. The <samp>label</samp> property in this object specifies the label text for the button. If you want to make the captions initially hidden, specify <samp>display: 'none'</samp> in the Content plugin that is used to show the captions. Once the CC button is clicked, the captions become visible. + </td> + </tr> + +</table> + +<a name="scripting"></a> +<h2>Scripting</h2> + +<p> + The captions plugin has the following custom methods that can be used at runtime: +</p> + +<table class="listing"> + <thead> + <tr> + <th>method</th> + <th>example</th> + <th>description</th> + </tr> + </thead> + + <tr> + <td class="code">loadCaptionsFromFile(clipIndex, captionURL, fileExtension)</td> + <td class="code" nowrap>loadCaptions(0, 'captions.xml')</td> + <td> + Loads captions for the specified clip. The <samp>fileExtension</samp> is an optional parameter + and you should specify it if the <samp>captionURL</samp> does not contain a file extension that + can be used to recognize the caption file format. The supported <samp>fileExtension</samp> values + are 'txt' and 'srt'. + </td> + </tr> + <tr> + <td class="code">loadCaptions(clipIndex, captions)</td> + <td class="code" nowrap>loadCaptions(0, captions)</td> + <td> + Loads a json array of captions for the specified clip. + </td> + </tr> +</table> + + +<h2>Timed text example</h2> + +<a class="player" id="timedtext"> + <img src="http://static.flowplayer.org/img/player/btn/showme.png" /> +</a><div class="box code"> +<pre><code class="html"><a class="player" id="timedtext"> + <img src="http://static.flowplayer.org/img/player/btn/showme.png" /> +</a></code></pre> +</div> + + +<script language='javascript'> +$f("timedtext", "@PLAYER_SWF@", { + log: { level: 'debug', filter: 'org.flowplayer.captions.*'}, + clip: { + url: 'http://video.flowplayer.org/flowplayer.flv', + + // this is the Timed Text file with captions info + captionUrl: 'http://releases.flowplayer.org/data/timedtext.xml' + }, + plugins: { + + captions: { + url: '@MAIN_PLAYER_SWF@', + + // pointer to a content plugin (see below) + captionTarget: 'content' + }, + + // configure a content plugin to look good for our purpose + content: { + url:'../flowplayer.content.swf', + bottom: 25, + width: '80%', + height:40, + backgroundColor: 'transparent', + backgroundGradient: 'low', + borderRadius: 4, + border: 0, + + style: { + 'body': { + fontSize: '14', + fontFamily: 'Arial', + textAlign: 'center', + color: '#000000' + } + } + } + } +}); +</script><div class="box code"> +<pre><code class="javascript">$f("timedtext", "@PLAYER_SWF@", { + log: { level: 'debug', filter: 'org.flowplayer.captions.*'}, + clip: { + url: 'http://video.flowplayer.org/flowplayer.flv', + + // this is the Timed Text file with captions info + captionUrl: 'http://releases.flowplayer.org/data/timedtext.xml' + }, + plugins: { + + captions: { + url: '@MAIN_PLAYER_SWF@', + + // pointer to a content plugin (see below) + captionTarget: 'content' + }, + + // configure a content plugin to look good for our purpose + content: { + url:'../flowplayer.content.swf', + bottom: 25, + width: '80%', + height:40, + backgroundColor: 'transparent', + backgroundGradient: 'low', + borderRadius: 4, + border: 0, + + style: { + 'body': { + fontSize: '14', + fontFamily: 'Arial', + textAlign: 'center', + color: '#000000' + } + } + } + } +});</code></pre> +</div> + + +<p> + The timed text XML file used in this example is shown below. The style definitions are in the first part of the file inside the <samp>head</samp> element and below that we have the Captions inside the <samp>body</samp> element. +</p> + +<p> + The first caption does not include the <samp>style</samp> attribute and therefore the style used to render it comes from the styling settings used to configure our Content plugin. The second caption uses the style with id 1 that defines a white font and left text alignment. The third caption has a small font coming from the 2nd style referenced by its id 2. +</p> + +<div class="box code"> +<pre><code class="xml"><?xml version="1.0" encoding="UTF-8"?> +<tt xml:lang="en" xmlns="http://www.w3.org/2006/10/ttaf1" + xmlns:tts="http://www.w3.org/2006/10/ttaf1#styling"> + <head> + <styling> + <style id="1" tts:fontFamily="Arial" tts:fontSize="14" tts:color="#FFFFFF" + tts:textAlign="left" tts:fontStyle="Bold" /> + <style id="2" tts:fontSize="10" tts:color="#000000" /> + </styling> + </head> + <body> + <div xml:lang="en" > + <p begin = "00:00:00.01" dur="04.00"> + First caption with default style coming from the Content plugin config + </p> + + <p begin = "00:00:04.19" dur="04.00" style="1"> + 2nd caption with timed text styling to make the text white + </p> + + <p begin = "8s" dur="04.00" style="2"> + 3rd caption using a small black font + </p> + </div> + </body> +</tt></code></pre> +</div> + + + + +<h2>Embedded Captions example</h2> + +<p> + This example show Captions based on data included in cuepoints that are embedded in the video file. The cuepoints were embedded into the video using <a href="http://www.richapps.de/?p=169" class="external">RichFLV</a>. The first caption is at 6 seconds. +</p> + +<a class="player" id="embedded"> + <img src="http://static.flowplayer.org/img/player/btn/showme.png" /> +</a> + +<div class="box code"> +<pre><code class="html"><a class="player" id="embedded"> + <img src="http://static.flowplayer.org/img/player/btn/showme.png" /> +</a></code></pre> +</div> + + +<script language='javascript'> +$f("embedded", "@PLAYER_SWF@", { + clip: { + url: 'http://video.flowplayer.org/flowplayer_cues.flv', + // cuepoint timing is in milliseconds in the file, so override + // the default multiplier value of 1000 that converts seconds + // to milliseconds + cuepointMultiplier: 1 + }, + log: { + level: 'debug', + filter: 'org.flowplayer.captions.*' + }, + plugins: { + + captions: { + url: '@MAIN_PLAYER_SWF@', + + // the content plugin we use to show the captions + captionTarget: 'content' + }, + + // configure a content plugin to look good for our purpose + content: { + url:'../flowplayer.content.swf', + top: 10, + width: '80%', + height:40, + backgroundColor: 'transparent', + backgroundGradient: 'none', + border: 0, + + // an outline is useful so that the subtitles are more visible + textDecoration: 'outline', + style: { + 'body': { + fontSize: '14', + fontFamily: 'Arial', + textAlign: 'center', + color: '#ffffff' + } + } + } + } +}); +</script> + +<p> + The file used in the example above has cuepoints at the following points of the timeline: 6000, 13500, 16000, and at 20000 milliseconds. Using the RichFLV application it's easy to add them. Each of these cuepoints has one parameter called <samp>text</samp> that contins the text displayed as the caption text. +</p> + +<div class="box code"> +<pre><code class="javascript">$f("embedded", "@PLAYER_SWF@", { + clip: { + url: 'http://video.flowplayer.org/flowplayer_cues.flv', + // cuepoint timing is in milliseconds in the file, so override + // the default multiplier value of 1000 that converts seconds + // to milliseconds + cuepointMultiplier: 1 + }, + plugins: { + + captions: { + url: '@MAIN_PLAYER_SWF@', + + // the content plugin we use to show the captions + captionTarget: 'content' + }, + + // configure a content plugin to look good for our purpose + content: { + url:'../flowplayer.content.swf', + top: 10, + width: '80%', + height:40, + backgroundColor: 'transparent', + backgroundGradient: 'none', + border: 0, + + // an outline is useful so that the subtitles are more visible + textDecoration: 'outline', + style: { + 'body': { + fontSize: '14', + fontFamily: 'Arial', + textAlign: 'center', + color: '#ffffff' + } + } + } + } +});</code></pre> +</div> + + + +<h2>Json Config Captions Example</h2> + +<p> + This example is Captions based on a Json config. +</p> + +<a class="player" id="json"> + <img src="http://static.flowplayer.org/img/player/btn/showme.png" /> +</a> + + +<script language='javascript'> +$f("json", "@PLAYER_SWF@", { + clip: { + url: 'http://video.flowplayer.org/flowplayer.flv', + cuepointMultiplier: 1, + captions: [ + { + time: 0, + name: 'cue1', + parameters: { + begin: 0, + end: 4000, + text: 'First caption with default style coming from the Content plugin config' + } + }, + { + time: 4000, + name: 'cue2', + parameters: { + begin: 4000, + end: 8000, + text: '2nd caption with timed text styling to make the text white' + } + }, + { + time: 8000, + name: 'cue3', + parameters: { + begin: 8000, + end: 12000, + text: '3rd caption using a small black font' + } + }, + + ] + }, + log: { + level: 'debug', + filter: 'org.flowplayer.captions.*' + }, + plugins: { + + captions: { + url: '@MAIN_PLAYER_SWF@', + + // the content plugin we use to show the captions + captionTarget: 'content', + }, + + content: { + url:'../flowplayer.content.swf', + bottom: 25, + height:40, + backgroundColor: 'transparent', + backgroundGradient: 'none', + border: 0, + textDecoration: 'outline', + style: { + body: { + fontSize: 14, + fontFamily: 'Arial', + textAlign: 'center', + color: '#ffffff' + } + } + }, + } +}); +</script> + +<div class="box code"> +<pre><code class="javascript"> +$f("json", "@PLAYER_SWF@", { + clip: { + url: 'http://video.flowplayer.org/flowplayer.flv', + captions: [ + { + time: 0, + name: 'cue1', + parameters: { + begin: 0, + end: 4000, + text: 'First caption with default style coming from the Content plugin config' + } + }, + { + time: 4000, + name: 'cue2', + parameters: { + begin: 4000, + end: 8000, + text: '2nd caption with timed text styling to make the text white' + } + }, + { + time: 8000, + name: 'cue3', + parameters: { + begin: 8000, + end: 12000, + text: '3rd caption using a small black font' + } + }, + + ] + }, + plugins: { + + captions: { + url: '@MAIN_PLAYER_SWF@', + + // the content plugin we use to show the captions + captionTarget: 'content' + }, + + // configure a content plugin to look good for our purpose + content: { + url:'../flowplayer.content.swf', + top: 10, + width: '80%', + height:40, + backgroundColor: 'transparent', + backgroundGradient: 'none', + border: 0, + + // an outline is useful so that the subtitles are more visible + textDecoration: 'outline', + style: { + 'body': { + fontSize: '14', + fontFamily: 'Arial', + textAlign: 'center', + color: '#ffffff' + } + } + } + } +}); +</code></pre> +</div> + +<a name="javascript_plugin"></a> +<h2>Javascript Plugin</h2> + +<p> + Available is the captions javascript plugin which provides a means to dynamically produce a scrollable playlist of the cuepoints. +</p> + +<p> + The captions setup is similar to the javascript playlist plugin, where the template can be provided by the html or config. +</p> + +<a class="player" id="javascript-plugin"> + <img src="http://static.flowplayer.org/img/player/btn/showme.png" /> +</a> + + +<script language='javascript'> +$f("javascript-plugin", "@PLAYER_SWF@", { + clip: { + url: 'http://video.flowplayer.org/flowplayer.flv', + cuepointMultiplier: 1, + captions: [ + { + time: 0, + name: 'cue1', + parameters: { + begin: 0, + end: 4000, + thumb: 'images/frame01.jpg', + text: 'First caption with default style coming from the Content plugin config' + } + }, + { + time: 4000, + name: 'cue2', + parameters: { + begin: 4000, + end: 8000, + thumb: 'images/frame06.jpg', + text: '2nd caption with timed text styling to make the text white' + } + }, + { + time: 8000, + name: 'cue3', + parameters: { + begin: 8000, + end: 12000, + thumb: 'images/frame08.jpg', + text: '3rd caption using a small black font' + } + }, + + ] + }, + log: { + level: 'debug', + filter: 'org.flowplayer.captions.*' + }, + plugins: { + + captions: { + url: '@MAIN_PLAYER_SWF@', + + // the content plugin we use to show the captions + captionTarget: 'content', + }, + + content: { + url:'../flowplayer.content.swf', + bottom: 25, + height:40, + backgroundColor: 'transparent', + backgroundGradient: 'none', + border: 0, + textDecoration: 'outline', + style: { + body: { + fontSize: 14, + fontFamily: 'Arial', + textAlign: 'center', + color: '#ffffff' + } + } + }, + } +}).captions("div.items", {}); +</script> + +<div id="cuethumbs" style="display:none;"> + <a class="prevPage"></a> + <div class="items" style="display:none;"> + <img src="images/thumbs/frame${time}.jpg"/> + </div> + <a class="nextPage"></a> +</div> + +<div class="box code"> +<pre><code class="javascript"> +$f("javascript-plugin", "@PLAYER_SWF@", { + clip: { + url: 'http://video.flowplayer.org/flowplayer.flv', + captions: [ + { + time: 0, + name: 'cue1', + parameters: { + begin: 0, + end: 4000, + text: 'First caption with default style coming from the Content plugin config' + } + }, + { + time: 4000, + name: 'cue2', + parameters: { + begin: 4000, + end: 8000, + text: '2nd caption with timed text styling to make the text white' + } + }, + { + time: 8000, + name: 'cue3', + parameters: { + begin: 8000, + end: 12000, + text: '3rd caption using a small black font' + } + }, + + ] + }, + plugins: { + + captions: { + url: '@MAIN_PLAYER_SWF@', + + // the content plugin we use to show the captions + captionTarget: 'content' + }, + + // configure a content plugin to look good for our purpose + content: { + url:'../flowplayer.content.swf', + top: 10, + width: '80%', + height:40, + backgroundColor: 'transparent', + backgroundGradient: 'none', + border: 0, + + // an outline is useful so that the subtitles are more visible + textDecoration: 'outline', + style: { + 'body': { + fontSize: '14', + fontFamily: 'Arial', + textAlign: 'center', + color: '#ffffff' + } + } + } + } +}).captions("div.items", {}); +</code></pre> +</div> + + +<br/><br/><b>Configuration:</b> +<table class="listing"> + <thead> + <tr> + <th nowrap="nowrap">property / datatype</th> + <th>default</th> + <th>description</th> + </tr> + </thead> + + <tr> + <td class="code">activeClass <div class="type">string</div></td> + <td class="code default"></td> + <td class="description"> + The active selected item class. + </td> + </tr> + <tr> + <td class="code">template <div class="type">string</div></td> + <td class="code default"><img src="images/${time}.jpg"/></td> + <td class="description"> + The template config to be used for generating the thumbnails. The fields of the cuepoints are used for the template like ${time}. + If the wrapper has the template set, it will be used instead of the template config. + </td> + </tr> + <tr> + <td class="code">fadeTime <div class="type">int</div></td> + <td class="code default">100</td> + <td class="description"> + The interval time for fading the wrapper in and out. Useful for hiding the wrapper if a template is set in it. + </td> + </tr> +</table> + + </div> + </div> +</body> +</html> \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.captions/example/tools.scrollable-1.1.2.js b/typo3/contrib/flowplayer/flowplayer.captions/example/tools.scrollable-1.1.2.js new file mode 100644 index 0000000000000000000000000000000000000000..319357ceb8988809eba4411d1249b65d002a3cd5 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/example/tools.scrollable-1.1.2.js @@ -0,0 +1,445 @@ +/** + * tools.scrollable 1.1.2 - Scroll your HTML with eye candy. + * + * Copyright (c) 2009 Tero Piirainen + * http://flowplayer.org/tools/scrollable.html + * + * Dual licensed under MIT and GPL 2+ licenses + * http://www.opensource.org/licenses + * + * Launch : March 2008 + * Date: ${date} + * Revision: ${revision} + */ +(function($) { + + // static constructs + $.tools = $.tools || {}; + + $.tools.scrollable = { + version: '1.1.2', + + conf: { + + // basics + size: 5, + vertical: false, + speed: 400, + keyboard: true, + + // by default this is the same as size + keyboardSteps: null, + + // other + disabledClass: 'disabled', + hoverClass: null, + clickable: true, + activeClass: 'active', + easing: 'swing', + loop: false, + + items: '.items', + item: null, + + // navigational elements + prev: '.prev', + next: '.next', + prevPage: '.prevPage', + nextPage: '.nextPage', + api: false + + // CALLBACKS: onBeforeSeek, onSeek, onReload + } + }; + + var current; + + // constructor + function Scrollable(root, conf) { + + // current instance + var self = this, $self = $(this), + horizontal = !conf.vertical, + wrap = root.children(), + index = 0, + forward; + + + if (!current) { current = self; } + + // bind all callbacks from configuration + $.each(conf, function(name, fn) { + if ($.isFunction(fn)) { $self.bind(name, fn); } + }); + + + if (wrap.length > 1) { wrap = $(conf.items, root); } + + // navigational items can be anywhere when globalNav = true + function find(query) { + var els = $(query); + return conf.globalNav ? els : root.parent().find(query); + } + + // to be used by plugins + root.data("finder", find); + + // get handle to navigational elements + var prev = find(conf.prev), + next = find(conf.next), + prevPage = find(conf.prevPage), + nextPage = find(conf.nextPage); + + + // methods + $.extend(self, { + + getIndex: function() { + return index; + }, + + getClickIndex: function() { + var items = self.getItems(); + return items.index(items.filter("." + conf.activeClass)); + }, + + getConf: function() { + return conf; + }, + + getSize: function() { + return self.getItems().size(); + }, + + getPageAmount: function() { + return Math.ceil(this.getSize() / conf.size); + }, + + getPageIndex: function() { + return Math.ceil(index / conf.size); + }, + + getNaviButtons: function() { + return prev.add(next).add(prevPage).add(nextPage); + }, + + getRoot: function() { + return root; + }, + + getItemWrap: function() { + return wrap; + }, + + getItems: function() { + return wrap.children(conf.item); + }, + + getVisibleItems: function() { + return self.getItems().slice(index, index + conf.size); + }, + + /* all seeking functions depend on this */ + seekTo: function(i, time, fn) { + + if (i < 0) { i = 0; } + + + // nothing happens + if (index === i) { return self; } + + // function given as second argument + if ($.isFunction(time)) { + fn = time; + } + + // seeking exceeds the end + + if (i > self.getSize() - conf.size) { + return conf.loop ? self.begin() : this.end(); + } + + + var item = self.getItems().eq(i); + if (!item.length) { return self; } + + // onBeforeSeek + var e = $.Event("onBeforeSeek"); + + $self.trigger(e, [i]); + + if (e.isDefaultPrevented()) { return self; } + + // get the (possibly altered) speed + if (time === undefined || $.isFunction(time)) { time = conf.speed; } + + function callback() { + if (fn) { fn.call(self, i); } + $self.trigger("onSeek", [i]); + } + + + if (horizontal) { + wrap.animate({left: -item.position().left}, time, conf.easing, callback); + } else { + wrap.animate({top: -item.position().top}, time, conf.easing, callback); + } + + + current = self; + index = i; + + // onStart + e = $.Event("onStart"); + $self.trigger(e, [i]); + if (e.isDefaultPrevented()) { return self; } + + + /* default behaviour */ + + // prev/next buttons disabled flags + prev.add(prevPage).toggleClass(conf.disabledClass, i === 0); + next.add(nextPage).toggleClass(conf.disabledClass, i >= self.getSize() - conf.size); + + return self; + }, + + + move: function(offset, time, fn) { + forward = offset > 0; + return this.seekTo(index + offset, time, fn); + }, + + next: function(time, fn) { + return this.move(1, time, fn); + }, + + prev: function(time, fn) { + return this.move(-1, time, fn); + }, + + movePage: function(offset, time, fn) { + forward = offset > 0; + var steps = conf.size * offset; + + var i = index % conf.size; + if (i > 0) { + steps += (offset > 0 ? -i : conf.size - i); + } + + return this.move(steps, time, fn); + }, + + prevPage: function(time, fn) { + return this.movePage(-1, time, fn); + }, + + nextPage: function(time, fn) { + return this.movePage(1, time, fn); + }, + + setPage: function(page, time, fn) { + return this.seekTo(page * conf.size, time, fn); + }, + + begin: function(time, fn) { + forward = false; + return this.seekTo(0, time, fn); + }, + + end: function(time, fn) { + forward = true; + var to = this.getSize() - conf.size; + return to > 0 ? this.seekTo(to, time, fn) : self; + }, + + reload: function() { + $self.trigger("onReload"); + return self; + }, + + focus: function() { + current = self; + return self; + }, + + click: function(i) { + + var item = self.getItems().eq(i), + klass = conf.activeClass, + size = conf.size; + + // check that i is sane + if (i < 0 || i >= self.getSize()) { return self; } + + // size == 1 + if (size == 1) { + if (conf.loop) { return self.next(); } + + if (i === 0 || i == self.getSize() -1) { + forward = (forward === undefined) ? true : !forward; + } + return forward === false ? self.prev() : self.next(); + } + + // size == 2 + if (size == 2) { + if (i == index) { i--; } + self.getItems().removeClass(klass); + item.addClass(klass); + return self.seekTo(i, time, fn); + } + + if (!item.hasClass(klass)) { + self.getItems().removeClass(klass); + item.addClass(klass); + var delta = Math.floor(size / 2); + var to = i - delta; + + // next to last item must work + if (to > self.getSize() - size) { + to = self.getSize() - size; + } + + if (to !== i) { + return self.seekTo(to); + } + } + + return self; + }, + + // bind / unbind + bind: function(name, fn) { + $self.bind(name, fn); + return self; + }, + + unbind: function(name) { + $self.unbind(name); + return self; + } + + }); + + // callbacks + $.each("onBeforeSeek,onStart,onSeek,onReload".split(","), function(i, ev) { + self[ev] = function(fn) { + return self.bind(ev, fn); + }; + }); + + + // prev button + prev.addClass(conf.disabledClass).click(function() { + self.prev(); + }); + + + // next button + next.click(function() { + self.next(); + }); + + // prev page button + nextPage.click(function() { + self.nextPage(); + }); + + if (self.getSize() < conf.size) { + next.add(nextPage).addClass(conf.disabledClass); + } + + + // next page button + prevPage.addClass(conf.disabledClass).click(function() { + self.prevPage(); + }); + + + // hover + var hc = conf.hoverClass, keyId = "keydown." + Math.random().toString().substring(10); + + self.onReload(function() { + + // hovering + if (hc) { + self.getItems().hover(function() { + $(this).addClass(hc); + }, function() { + $(this).removeClass(hc); + }); + } + + // clickable + if (conf.clickable) { + self.getItems().each(function(i) { + $(this).unbind("click.scrollable").bind("click.scrollable", function(e) { + if ($(e.target).is("a")) { return; } + return self.click(i); + }); + }); + } + + // keyboard + if (conf.keyboard) { + + // keyboard works on one instance at the time. thus we need to unbind first + $(document).unbind(keyId).bind(keyId, function(evt) { + + // do nothing with CTRL / ALT buttons + if (evt.altKey || evt.ctrlKey) { return; } + + // do nothing for unstatic and unfocused instances + if (conf.keyboard != 'static' && current != self) { return; } + + var s = conf.keyboardSteps; + + if (horizontal && (evt.keyCode == 37 || evt.keyCode == 39)) { + self.move(evt.keyCode == 37 ? -s : s); + return evt.preventDefault(); + } + + if (!horizontal && (evt.keyCode == 38 || evt.keyCode == 40)) { + self.move(evt.keyCode == 38 ? -s : s); + return evt.preventDefault(); + } + + return true; + + }); + + } else { + $(document).unbind(keyId); + } + + }); + + self.reload(); + + } + + + // jQuery plugin implementation + $.fn.scrollable = function(conf) { + + // already constructed --> return API + var el = this.eq(typeof conf == 'number' ? conf : 0).data("scrollable"); + if (el) { return el; } + + var globals = $.extend({}, $.tools.scrollable.conf); + conf = $.extend(globals, conf); + + conf.keyboardSteps = conf.keyboardSteps || conf.size; + + this.each(function() { + el = new Scrollable($(this), conf); + $(this).data("scrollable", el); + }); + + return conf.api ? el: this; + + }; + + +})(jQuery); diff --git a/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/CCButton.as b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/CCButton.as new file mode 100644 index 0000000000000000000000000000000000000000..f077dd57c1f4a44afa7b4929d8eb0acae6545350 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/CCButton.as @@ -0,0 +1,68 @@ +/* + * This file is part of Flowplayer, http://flowplayer.org + * + * By: Anssi Piirainen, <support@flowplayer.org> + *Copyright (c) 2008-2011 Flowplayer Oy * + * Released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + */ + +package org.flowplayer.captions { + import flash.display.Sprite; + import flash.events.MouseEvent; + import flash.text.TextField; + + import org.flowplayer.view.AbstractSprite; + import org.flowplayer.view.Flowplayer; + + public class CCButton extends AbstractSprite { + private var _text:TextField; + private var _background:Sprite; + private var _textColor:Number; + private var _label:String; + + public function CCButton(player:Flowplayer, label:String) { + _label = label; + _background = new Sprite(); + _background.buttonMode = true; + addChild(_background); + createText(player); + + isDown = true; + } + + protected override function onResize():void { + drawBackground(); + _text.x = 2; + _text.y = 0; + } + + public function get clickArea():Sprite + { + return _background; + } + + private function drawBackground():void { + _background.graphics.clear(), + _background.graphics.lineStyle(2, 0x555555); + _background.graphics.beginFill(0xaaaaaa, 1); + _background.graphics.drawRoundRect(0, 0, width, height, 6, 6); + _background.graphics.endFill(); + } + + private function createText(player:Flowplayer):void { + _text = player.createTextField(8, true); + _text.text = _label; + _text.textColor = _textColor; + addChild(_text); + _text.selectable = false; + _text.mouseEnabled = false; + } + + public function set isDown(isDown:Boolean):void { + _textColor = isDown ? 0 : 0xff2222; + _text.textColor = _textColor; + } + + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/Caption.as b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/Caption.as new file mode 100644 index 0000000000000000000000000000000000000000..2205d8d4c9cd931cd42cc528aadd957cf7c61d80 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/Caption.as @@ -0,0 +1,537 @@ +/* + * This file is part of Flowplayer, http://flowplayer.org + * + * By: Daniel Rossi, <electroteque@gmail.com> + * Copyright (c) 2009 Electroteque Multimedia + * + * Copyright 2009 Joel Hulen, loading of captions files from URLs without a file extension + * + * Released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + */ +package org.flowplayer.captions { + import flash.events.MouseEvent; + import flash.utils.*; + + import org.flowplayer.captions.parsers.CaptionParser; + import org.flowplayer.captions.parsers.JSONParser; + import org.flowplayer.captions.parsers.SRTParser; + import org.flowplayer.captions.parsers.TTXTParser; + import org.flowplayer.controller.ResourceLoader; + import org.flowplayer.layout.LayoutEvent; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipEvent; + import org.flowplayer.model.ClipEventType; + import org.flowplayer.model.DisplayPluginModel; + import org.flowplayer.model.PlayerEvent; + import org.flowplayer.model.Plugin; + import org.flowplayer.model.PluginModel; + import org.flowplayer.util.PropertyBinder; + import org.flowplayer.view.AbstractSprite; + import org.flowplayer.view.FlowStyleSheet; + import org.flowplayer.view.Flowplayer; + import org.flowplayer.view.Styleable; + import org.flowplayer.model.PlayerEventType; + + + + /** + * A Subtitling and Captioning Plugin. Supports the following: + * <ul> + * <li>Loading subtitles from the Timed Text or Subrip format files.</li> + * <li>Styling text from styles set in the Time Text format files.</li> + * <li>Loading subtitles or cuepoints from a JSON config.</li> + * <li>Loading subtitles or cuepoints from embedded FLV cuepoints.</li> + * <li>Controls an external content plugin.</li> + * <li>Working with the Javascript captions plugin, it enables a scrolling cuepoint thumbnail menu.</li> + * </ul> + * <p> + * To setup an external subtitle caption file the config would look like so: + * + * captionType: 'external' + * + * For Timed Text + * + * captionUrl: 'timedtext.xml' + * + * For Subrip + * + * captionUrl: 'subrip.srt' + * + * <p> + * To enable the captioning to work properly a caption target must link to a content plugin like so: + * + * captionTarget: 'content' + * + * Where content is the config for a loaded content plugin. + * + * <p> + * + * To be able to customised the subtitle text a template string is able to tell the captioning plugin + * which text property is to be used for the subtitle text which is important for embedded cuepoints. It also + * enables to add extra properties to the text like so: + * + * template: '{text} {time} {custom}' + * + * <p> + * To enable simple formatting of text if Timed Text has style settings, + * only "fontStyle", "fontWeight" and "textAlign" properties are able to be set like so: + * + * simpleFormatting: true + * + * @author danielr, Anssi Piirainen (api@iki.fi) + */ + public class Caption extends AbstractSprite implements Plugin, Styleable { + private var _player:Flowplayer; + private var _model:PluginModel; + private var _captionView:*; + private var _config:Config; + private var _styles:FlowStyleSheet; + private var _viewModel:DisplayPluginModel; + private var _template:String; + private var _button:CCButton; + private var _totalCaptions:int; + private var _numCaptionsLoaded:int; + private var _initialized:Boolean; + + private var _currentCaption:Object; + private var _captionHeightRatio:Number; + private var _captionWidthRatio:Number; + private var _captionFontSizes:Object; + + private var _captionViewWidth:int = 0; + + /** + * Sets the plugin model. This gets called before the plugin + * has been added to the display list and before the player is set. + * @param plugin + */ + public function onConfig(plugin:PluginModel):void { + + _model = plugin; + _config = new PropertyBinder(new Config(), null).copyProperties(plugin.config) as Config; + + } + + + public function hasCaptions():Boolean { + var clips:Array = _player.playlist.clips; + for (var i:Number = 0; i < clips.length; i++) { + var clip:Clip = clips[i] as Clip; + if (clip.customProperties && (clip.getCustomProperty("captions") || clip.getCustomProperty("captionUrl"))) { + return true; + } + } + return false; + + } + + /** + * Sets the Flowplayer interface. The interface is immediately ready to use, all + * other plugins have been loaded an initialized also. + * @param player + */ + public function onLoad(player:Flowplayer):void { + log.debug("onLoad"); + _initialized = false; + _player = player; + _player.playlist.onCuepoint(onCuepoint); + + _player.playlist.commonClip.onNetStreamEvent(onNetStreamCaption); + + if (! _config.captionTarget) { + throw Error("No captionTarget defined in the configuration"); + } + _viewModel = _player.pluginRegistry.getPlugin(_config.captionTarget) as DisplayPluginModel; + _captionView = _viewModel.getDisplayObject(); + + _player.onLoad(onPlayerInitialized); + + if (hasCaptions()) { + loadClipCaptions(); + } else { + _model.dispatchOnLoad(); + } + } + + private function initializeRatios():void { + _captionHeightRatio = _captionView.height / _player.screen.getDisplayObject().height; + _captionWidthRatio = _captionView.width / _player.screen.getDisplayObject().width; + } + + private function onPlayerInitialized(event:PlayerEvent):void { + initCaptionView(); + + log.debug("button", _config.button); + if (_config.button) { + _button = new CCButton(_player, _config.button["label"]); + _player.addToPanel(_button, _config.button); + + _button.isDown = _viewModel.visible; + _button.clickArea.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void { + _button.isDown = _player.togglePlugin(_config.captionTarget); + }); + } + + if (_viewModel.visible) + initializeRatios(); + else + { + _captionView.alpha = 0; + _player.togglePlugin(_config.captionTarget); + initializeRatios(); + _player.togglePlugin(_config.captionTarget); + _captionView.alpha = 1; + } + + _player.playlist.onPause(function(event:ClipEvent):void { + if (_currentCaption != null) + clearInterval(_currentCaption.captionInterval); + }); + + _player.playlist.onResume(function(event:ClipEvent):void { + if (_currentCaption != null) + { + var newDuration:Number = _currentCaption.endTime - _player.status.time; + if (newDuration > 0) + _currentCaption.captionInterval = setInterval(clearCaption, newDuration); + } + }); + + _player.playlist.onStop(function(event:ClipEvent):void { + clearCaption(); + }); + _player.playlist.onSeek(function(event:ClipEvent):void { + clearCaption(); + }); + + _player.onBeforeFullscreen(function(event:PlayerEvent):void { + _captionViewWidth = _captionView.width; + }); + _player.onFullscreen(resizeCaptionView); + _player.onFullscreenExit(resizeCaptionView); + + + } + + private function resizeCaptionView(event:PlayerEvent):void + { + var newWidth:Number = _player.screen.getDisplayObject().width * _captionWidthRatio; + var newHeight:Number = _player.screen.getDisplayObject().height * _captionHeightRatio; + + // log.info("resizing, width:" +_player.screen.getDisplayObject().width + " * "+_captionWidthRatio+" = "+ newWidth); + // log.info("resizing, width:" +_player.screen.getDisplayObject().height + " * "+_captionHeightRatio+" = "+ newHeight); + + if (event.type == (PlayerEventType.FULLSCREEN).name) + { + _captionFontSizes = {}; + var styleNames:Array = _captionView.style.styleSheet.styleNames; + for (var i:int = 0; i < styleNames.length; i++) + { + if (_captionView.style.getStyle(styleNames[i]).fontSize) + { + var style:Object = _captionView.style.getStyle(styleNames[i]); + + _captionFontSizes[styleNames[i]] = style.fontSize; + + // log.info ("current font size "+style.fontSize+", ratio "+ newWidth+"/"+_captionView.width+" = "+(newWidth / _captionViewWidth)); + style.fontSize = style.fontSize * newWidth / _captionViewWidth; + _captionView.style.setStyle(styleNames[i], style); + } + } + } + else + { // setting back fontsizes .. + for (var styleName:String in _captionFontSizes) + { + style = _captionView.style.getStyle(styleName); + style.fontSize = _captionFontSizes[styleName]; + _captionView.style.setStyle(styleName, style); + } + } + + var newY:Number = _captionView.y; + if (newY > _player.screen.getDisplayObject().height / 2) + newY = _captionView.y - (newHeight - _captionView.height); + + var newX:Number = _captionView.x - (newWidth - _captionView.width); + + _player.css(_config.captionTarget, {y: newY, x: newX, height: newHeight, width: newWidth}); + } + + private function onPlayerResized(event:LayoutEvent):void { + log.debug("onPlayerResized"); + _button.x = _captionView.x + _captionView.width + 3; + _button.y = _captionView.y; + } + + + private function loadClipCaptions():void { + // count files + iterateCaptions(function (clip:Clip):void { + _totalCaptions++; + }); + // load files + iterateCaptions(function(clip:Clip):void { + if (clip.getCustomProperty("captions")) { + loadCaption(clip, clip.getCustomProperty("captions") as Array); + } else { + loadCaptionFile(clip, clip.getCustomProperty("captionUrl") as String); + } + }); + } + + + private function iterateCaptions(callback:Function):void { + var clips:Array = _player.playlist.clips; + for (var i:Number = 0; i < clips.length; i++) { + var clip:Clip = _player.playlist.clips[i] as Clip; + var captions:Array = clip.customProperties ? clip.getCustomProperty("captions") as Array : null; + if (clip.getCustomProperty("captions") || clip.getCustomProperty("captionUrl")) { + callback(clip); + } + } + } + + /** + * Loads a new stylesheet and changes the style from the loaded sheet. + * @param clipIndex + * @param captionURL the URL to load the caption file from + * @param fileExtension optional file extension to be used if captionURL does not use an extension, one of + * 'xml', 'srt', 'tx3g', 'qtxt' + */ + [External] + public function loadCaptions(clipIndex:int, captionsUrl:String = null):void { + if (! captionsUrl) return; + log.info("loading captions from " + captionsUrl); + loadCaptionFile(_player.playlist.clips[clipIndex], captionsUrl); + } + + [External] + public function addCaptions(clipIndex:int, captions:Array):void { + if (! captions) return; + log.info("loading captions from " + captions); + loadCaption(_player.playlist.clips[clipIndex], captions); + } + + /** + * Sets style properties. + */ + public function css(styleProps:Object = null):Object { + var result:Object = _captionView.css(styleProps); + return result; + } + + protected function loadCaption(clip:Clip, captions:Array):void { + parseCuePoints(clip, captions); + _numCaptionsLoaded++; + log.debug(_numCaptionsLoaded + " clip captions out of " + _totalCaptions + " loaded"); + if (_numCaptionsLoaded == _totalCaptions && ! _initialized) { + log.debug("all caption files loaded, dispatching onLoad()"); + _initialized = true; + _model.dispatchOnLoad(); + } + } + + /** + * Joel Hulen - April 20, 2009 + * Modified loadCaptionFile to add the fileExtension parameter. + */ + protected function loadCaptionFile(clip:Clip, captionFile:String = null):void { + var loader:ResourceLoader = _player.createLoader(); + + if (captionFile) { + log.info("loading captions from file " + captionFile); + loader.addTextResourceUrl(captionFile); + } + + loader.load(null, function(loader:ResourceLoader):void { + parseCuePoints(clip, loader.getContent(captionFile)); + + _numCaptionsLoaded++; + log.debug(_numCaptionsLoaded + " captions files out of " + _totalCaptions + " loaded"); + if (_numCaptionsLoaded == _totalCaptions && ! _initialized) { + log.debug("all captions loaded, dispatching onLoad()"); + _initialized = true; + _model.dispatchOnLoad(); + } + }); + } + + protected function parseCuePoints(clip:Clip, captionData:*):void + { + log.debug("captions file loaded, parsing cuepoints"); + var parser:CaptionParser = createParser(captionData); + + // remove all existing cuepoints + clip.removeCuepoints(function(cue:Object):Boolean { + return cue.hasOwnProperty("__caption"); + }); + + try { + clip.addCuepoints(parser.parse(captionData)); + //clip.addCuepoints(parser.parse(_captions.length > 0 ? _captions : captionData)); + } catch (e:Error) { + log.error("parseCuePoints():" + e.message); + } + _captionView.style = parser.styles; + } + + private function createParser(captionData:Object):CaptionParser { + var parser:CaptionParser; + + if (new XML(captionData).localName() == "tt") { + log.debug("parsing Timed Text captions"); + parser = new TTXTParser(); + TTXTParser(parser).simpleFormatting = _config.simpleFormatting; + } else if (String(captionData).charAt(0) == "1") { + log.debug("parsing SubRip captions"); + parser = new SRTParser(); + } else if (captionData is Array || captionData.toString().indexOf('[')) { + parser = new JSONParser(); + } else { + throw new Error("Unrecognized captions file extension"); + } + parser.styles = _captionView.style; + return parser; + } + + + protected function parseTemplate(values:Object):String + { + for (var key:String in values) { + + if (typeof values[key] == 'object') + { + parseTemplate(values[key]); + } else { + _template = _template.replace("{" + key + "}", values[key]); + } + } + + if (values.time >= 0) { + _template = _template.replace("{time}", values.time); + } + + return _template; + } + + protected function clearCaption(clearHTML:Boolean = true):void + { + if (_currentCaption == null) return; + + clearInterval(_currentCaption.captionInterval); + _currentCaption = null; + + if (clearHTML) + _captionView.html = ""; + } + + protected function captionsDisabledForClip(clip:Clip):Boolean { + return clip.customProperties && clip.customProperties.hasOwnProperty("showCaptions") && ! clip.customProperties["showCaptions"]; + } + + protected function onNetStreamCaption(event:ClipEvent):void { + if ( event.info != "onTextData" ) + return; + + var clip:Clip = event.target as Clip; + var data:Object = event.info2; + var text:String = data['text']; + + if ( captionsDisabledForClip(clip) ) + return; + + if ( ! data.hasOwnProperty('text') ) + return; + + if (clip.customProperties && clip.customProperties.hasOwnProperty("captionsTrackFilter")) { + var captionsTrackFilter:String = clip.customProperties['captionsTrackFilter']; + var filterKey:String = captionsTrackFilter.substr(0, captionsTrackFilter.indexOf('=')); + var filterValue:String = captionsTrackFilter.substr(captionsTrackFilter.indexOf('=')+1); + + if ( data.hasOwnProperty(filterKey) && (data[filterKey]+"") != filterValue ) { + log.debug("Skipping "+ text + ", "+filterKey+" filtered out : "+(data[filterKey]+"")+" != "+filterValue); + return; + } + } + + text = text.replace(/\n/, '<br>'); + + _captionView.html = "<p>" + text + "</p>"; + + } + + protected function onCuepoint(event:ClipEvent):void { + log.debug("onCuepoint", event.info.parameters); + + var clip:Clip = event.target as Clip; + if ( captionsDisabledForClip(clip) ) + return; + + if (clip.customProperties && clip.customProperties.hasOwnProperty("captionUrl")) { + var cue:Object = event.info; + if (! cue.hasOwnProperty("captionType") || cue["captionType"] != "external") { + // we are using a captions file and this cuepoint is not from the file + return; + } + } + + clearCaption(false); + + _template = _config.template; + var bgColor:String = (_captionView.style.getStyle("." + event.info.parameters.style).backgroundColor ? _captionView.style.getStyle("." + event.info.parameters.style).backgroundColor + : _captionView.style.rootStyle.backgroundColor); + + _captionView.css({backgroundColor: bgColor}); + var text:String = (_template ? parseTemplate(event.info) : event.info.parameters.text); + text = text.replace(/\n/, '<br>'); + + _captionView.html = "<p class='" + event.info.parameters.style + "'>" + text + "</p>"; + if (Number(event.info.parameters.end) > 0) + { + _currentCaption = { + captionInterval: setInterval(clearCaption, Number(event.info.parameters.end)), + beginTime: _player.status.time, + endTime: _player.status.time + Number(event.info.parameters.end) + }; + } + } + + protected function initCaptionView():void { + log.debug("creating content view"); + if (_config.captionTarget) + { + log.info("Loading caption target plugin: " + _config.captionTarget); + + if (_config.autoLayout) + { + _captionView.css(getDefaultConfig()); + } + } else { + throw new Error("No caption target specified, please configure a Content plugin instance to be used as target"); + } + } + + + public override function set alpha(value:Number):void { + super.alpha = value; + if (!_captionView) return; + _captionView.alpha = value; + } + + public function getDefaultConfig():Object { + return { bottom: 25, width: '80%'}; + } + + public function animate(styleProps:Object):Object { + return _captionView.animate(styleProps); + } + + public function onBeforeCss(styleProps:Object = null):void { + } + + public function onBeforeAnimate(styleProps:Object):void { + } + } +} diff --git a/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/CaptionFileTypes.as b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/CaptionFileTypes.as new file mode 100644 index 0000000000000000000000000000000000000000..9dcd736da208d5eff09e0910da90872e1e286489 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/CaptionFileTypes.as @@ -0,0 +1,26 @@ +/* + * This file is part of Flowplayer, http://flowplayer.org + * + * By: Daniel Rossi, <electroteque@gmail.com> + * Copyright (c) 2009 Electroteque Multimedia + * + * Released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + */ + +package org.flowplayer.captions +{ + public class CaptionFileTypes + { + public static var TTXT:String = "xml"; + public static var SRT:String = "srt"; + public static var TX3G:String = "tx3g"; + public static var QTXT:String = "qtxt"; + + + public function CaptionFileTypes() + { + } + + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/CaptionSourceTypes.as b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/CaptionSourceTypes.as new file mode 100644 index 0000000000000000000000000000000000000000..4be688c360f4a42b8e02999d9f050e4ac30afd3a --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/CaptionSourceTypes.as @@ -0,0 +1,22 @@ +/* + * This file is part of Flowplayer, http://flowplayer.org + * + * By: Daniel Rossi, <electroteque@gmail.com> + * Copyright (c) 2009 Electroteque Multimedia + * + * Released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + */ +package org.flowplayer.captions +{ + public class CaptionSourceTypes + { + public static var EMBEDDED:String = "embedded"; + public static var EXTERNAL:String = "external"; + + public function CaptionSourceTypes() + { + } + + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/Config.as b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/Config.as new file mode 100644 index 0000000000000000000000000000000000000000..0d8cd00830d94856804d59a8af6c8891a92d9d77 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/Config.as @@ -0,0 +1,91 @@ +/* + * This file is part of Flowplayer, http://flowplayer.org + * + * By: Daniel Rossi, <electroteque@gmail.com> + * Copyright (c) 2009 Electroteque Multimedia + * + * Released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + */ + +package org.flowplayer.captions +{ + import org.flowplayer.model.DisplayProperties; + import org.flowplayer.model.DisplayPropertiesImpl; + import org.flowplayer.util.Arrange; + + public class Config { + private var _autoLayout:Boolean = true; + private var _simpleFormatting:Boolean = false; + private var _captionTarget:String; + private var _template:String; + private static const BUTTON_DEFAULTS:Object = { width: 20, height: 15, right: 5, bottom: 35, name: "cc_button", label: 'CC' }; + private var _button:Object = BUTTON_DEFAULTS; + + + public function get captionTarget():String { + return _captionTarget; + } + + public function set captionTarget(captionTarget:String):void { + _captionTarget = captionTarget; + } + + public function get template():String { + return _template; + } + + public function set template(template:String):void { + _template = template; + } + + public function get autoLayout():Boolean { + return _autoLayout; + } + + public function set autoLayout(autoLayout:Boolean):void { + _autoLayout = autoLayout; + } + + public function get simpleFormatting():Boolean { + return _simpleFormatting; + } + + public function set simpleFormatting(simpleFormatting:Boolean):void { + _simpleFormatting = simpleFormatting; + } + + public function get button():Object { + return _button; + } + + public function set button(val:Object):void { + if (! val) { + _button = null; + return; + } + fixPositionSettings(val, BUTTON_DEFAULTS); + _button = BUTTON_DEFAULTS; + for (var prop:String in val) { + _button[prop] = val[prop]; + } + } + + private function fixPositionSettings(props:Object, defaults:Object):void { + clearOpposite("bottom", "top", props, defaults); + clearOpposite("left", "right", props, defaults); + } + + private function clearOpposite(prop1:String, prop2:String, props:Object, defaults:Object):void { + if (props.hasOwnProperty(prop1) && defaults.hasOwnProperty(prop2)) { + delete defaults[prop2]; + } else if (props.hasOwnProperty(prop2) && defaults.hasOwnProperty(prop1)) { + delete defaults[prop1]; + } + } + + } +} + + + diff --git a/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/NumberFormatter.as b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/NumberFormatter.as new file mode 100644 index 0000000000000000000000000000000000000000..27308b14c8c038413dbf7f73d61b356d44290f77 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/NumberFormatter.as @@ -0,0 +1,45 @@ +/* + * This file is part of Flowplayer, http://flowplayer.org + * + * Time formatter thanks to the JW Player Project + * + * By: Daniel Rossi, <electroteque@gmail.com> + * Copyright (c) 2009 Electroteque Multimedia + * + * Released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + */ + +package org.flowplayer.captions { + + public class NumberFormatter { + + public static function seconds(str:String, timeMultiplier:Number = 1000):Number { + return Math.round(toSeconds(str) * timeMultiplier / 100) * 100; + } + + private static function toSeconds(str:String):Number { + str = str.replace(",", "."); + var arr:Array = str.split(':'); + var sec:Number = 0; + if (str.substr(-1) == 's') { + return Number(str.substr(0, str.length - 1)); + } + if (str.substr(-1) == 'm') { + return Number(str.substr(0, str.length - 1)) * 60; + } + if (str.substr(-1) == 'h') { + return Number(str.substr(0, str.length - 1)) * 3600; + } + if (arr.length > 1) { + sec = Number(arr[arr.length - 1]); + sec += Number(arr[arr.length - 2]) * 60; + if (arr.length == 3) { + sec += Number(arr[arr.length - 3]) * 3600; + } + return sec; + } + return Number(str); + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/parsers/AbstractCaptionParser.as b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/parsers/AbstractCaptionParser.as new file mode 100644 index 0000000000000000000000000000000000000000..ae9376407373ff19a4e03e8c6f18eaf1fa691b1a --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/parsers/AbstractCaptionParser.as @@ -0,0 +1,38 @@ +/* + * This file is part of Flowplayer, http://flowplayer.org + * + * By: Anssi Piirainen, Flowplayer Oy + * Copyright (c) 2009-2011 Flowplayer Oy + * + * Released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + */ +package org.flowplayer.captions.parsers { + import org.flowplayer.view.FlowStyleSheet; + import org.flowplayer.view.FlowStyleSheet; + + public class AbstractCaptionParser implements CaptionParser { + private var _styles:FlowStyleSheet; + + public final function parse(data:Object):Array { + var captions:Array = parseCaptions(data); + for (var i:int = 0; i < captions.length; i++) { + captions[i]["__caption"] = true; + } + return captions; + } + + protected function parseCaptions(data:Object):Array { + return null; + } + + public function get styles():FlowStyleSheet { + return _styles; + } + + public function set styles(value:FlowStyleSheet):void { + _styles = value; + } + } + +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/parsers/CaptionParser.as b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/parsers/CaptionParser.as new file mode 100644 index 0000000000000000000000000000000000000000..d243a318e435d255637d11d0d67c8b24bada4617 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/parsers/CaptionParser.as @@ -0,0 +1,22 @@ +/* + * This file is part of Flowplayer, http://flowplayer.org + * + * By: Anssi Piirainen, Flowplayer Oy + * Copyright (c) 2009-2011 Flowplayer Oy + * + * Released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + */ +package org.flowplayer.captions.parsers { + import org.flowplayer.view.FlowStyleSheet; + + public interface CaptionParser { + + function parse(data:Object):Array; + + function set styles(style:FlowStyleSheet):void; + + function get styles():FlowStyleSheet; + + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/parsers/JSONParser.as b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/parsers/JSONParser.as new file mode 100644 index 0000000000000000000000000000000000000000..044d41b97a32c6925bc2d2cd82a919b290e3d65e --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/parsers/JSONParser.as @@ -0,0 +1,62 @@ +/* + * This file is part of Flowplayer, http://flowplayer.org + * + * By: Daniel Rossi, <electroteque@gmail.com> + * Copyright (c) 2009 Electroteque Multimedia + * + * Released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + */ +package org.flowplayer.captions.parsers +{ + import org.flowplayer.model.Cuepoint; + import org.flowplayer.util.Log; + import org.flowplayer.config.ConfigParser; + import org.flowplayer.flow_internal; + import org.flowplayer.view.FlowStyleSheet; + + use namespace flow_internal; + + public class JSONParser extends AbstractCaptionParser + { + + protected var log:Log = new Log(this); + private var _arr:Array = new Array(); + private var cueRow:int = 0; + + private function parseRows(item:*, index:int, array:Array):void + { + + var time:int = Number(item.time); + var cue:Object = Cuepoint.createDynamic(time, "embedded"); // creates a dynamic + var parameters:Object = new Object(); + var name:String = (item.name ? item.name : "cue" + cueRow); + cue.time = time; + cue.name = name; + cue.type = "event"; + + if (item.parameters) + { + + for (var param:String in item.parameters) + { + parameters[param] = item.parameters[param]; + } + } + + parameters.style = styles.rootStyleName; + parameters.begin = item.parameters.begin; + parameters.end = item.parameters.end - item.parameters.begin; + cue.parameters = parameters; + _arr.push(cue); + cueRow++; + } + + override protected function parseCaptions(data:Object):Array { + + if (!data is Array) data = ConfigParser.parse(String(data)); + (data as Array).forEach(parseRows); + return _arr; + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/parsers/SRTParser.as b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/parsers/SRTParser.as new file mode 100644 index 0000000000000000000000000000000000000000..4868303eba36e7ae694d403d2b024253697f5a1c --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/parsers/SRTParser.as @@ -0,0 +1,71 @@ +/* + * This file is part of Flowplayer, http://flowplayer.org + * + * Subrip Parsing thanks to the as3subtitle Project http://code.google.com/p/as3subtitle/ + * + * By: Daniel Rossi, <electroteque@gmail.com> + * Copyright (c) 2009 Electroteque Multimedia + * + * Released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + */ + +package org.flowplayer.captions.parsers +{ + import org.flowplayer.captions.NumberFormatter; + import org.flowplayer.model.Cuepoint; + import org.flowplayer.util.Log; + import org.flowplayer.view.FlowStyleSheet; + import org.flowplayer.view.FlowStyleSheet; + + public class SRTParser extends AbstractCaptionParser + { + + protected var log:Log = new Log(this); + private var _arr:Array = new Array(); + private var cueRow:int = 0; + + private function parseRows(item:*, index:int, array:Array):void + { + if (!item) return; + log.debug("parsing " + item); + var rows:Array = item.split(/\r?\n/); + var time_pattern:RegExp = /(\d{2}:\d{2}:\d{2}(?:,\d*)?) --> (\d{2}:\d{2}:\d{2}(?:,\d*)?)/; + var hasValidTime:Boolean = time_pattern.test(rows[1]); + + if (!hasValidTime) { + log.error("Invalid time format for #" + (rows[0]) + item); + return; + } + + var time:Array = time_pattern.exec(rows[1]); + var text:String = rows.slice(2, rows.length).join("\n"); + var begin:Number = NumberFormatter.seconds(time[1]); + var end:Number = (NumberFormatter.seconds(time[2]) - begin); + log.debug("" + end); + var name:String = (rows[0] ? rows[0] : "cue" + cueRow); + var parameters:Object = new Object(); + + var cue:Object = Cuepoint.createDynamic(begin, "embedded"); // creates a dynamic + cue.captionType = "external"; + cue.time = begin; + cue.name = name; + cue.type = "event"; + parameters.begin = begin; + parameters.end = end; + parameters.style = styles.rootStyleName; + parameters.text = text; + cue.parameters = parameters; + _arr.push(cue); + cueRow++; + } + + override protected function parseCaptions(data:Object):Array { + log.debug("parseCaptions"); + var line_break:RegExp = /\n\r?\n/; + var subtitles:Array = String(data).split(line_break); + subtitles.forEach(parseRows); + return _arr; + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/parsers/TTXTParser.as b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/parsers/TTXTParser.as new file mode 100644 index 0000000000000000000000000000000000000000..7b798483a92004da2cf6d063c361b3141f9c2967 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.captions/src/actionscript/org/flowplayer/captions/parsers/TTXTParser.as @@ -0,0 +1,145 @@ +/* + * This file is part of Flowplayer, http://flowplayer.org + * + * By: Daniel Rossi, <electroteque@gmail.com> + * Copyright (c) 2009 Electroteque Multimedia + * + * Released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + */ + +package org.flowplayer.captions.parsers +{ + import org.flowplayer.captions.NumberFormatter; + import org.flowplayer.model.Cuepoint; + import org.flowplayer.util.Log; + import org.flowplayer.view.FlowStyleSheet; + + public class TTXTParser extends AbstractCaptionParser + { + private var tt:Namespace = new Namespace("http://www.w3.org/2006/10/ttaf1"); + private var tts:Namespace = new Namespace("http://www.w3.org/2006/04/ttaf1#styling"); + private var ttm:Namespace = new Namespace("http://www.w3.org/2006/10/ttaf1#metadata"); + + private var bodyStyle:String; + private var _simpleFormatting:Boolean = false; + private var cueRow:int = 0; + internal static const SIMPLE_FORMATTING_PROPS:Array = ["fontStyle", "fontWeight", "textAlign"]; + + protected var log:Log = new Log(this); + + public function TTXTParser() + { + default xml namespace = tt + ; + } + + public function get simpleFormatting():Boolean { + return _simpleFormatting; + } + + public function set simpleFormatting(simpleFormatting:Boolean):void { + _simpleFormatting = simpleFormatting; + } + + private function getStyleObj(style:String):Object + { + return styles.getStyle("." + style); + } + + + override protected function parseCaptions(data:Object):Array { + var xml:XML = new XML(data); + log.debug("got data " + xml); + log.debug("body " + xml.body); + log.debug("div " + xml.body.div); + parseStyles(xml.head.styling.style); + bodyStyle = xml.body.hasOwnProperty("@style") ? xml.body.@style : styles.rootStyleName; + + var arr:Array = new Array(); + var i:int = 0; + + var div:XMLList = xml.body.div; + for each (var property:XML in div) + { + log.debug("found div"); + var divStyle:String = property.hasOwnProperty("@style") ? property.@style : bodyStyle; + var parent:XML = div.parent().parent(); + var lang:String = property.hasOwnProperty("@lang") ? property.@*::lang : parent.@*::lang; + var begin:Number; + var end:Number; + + if (property.hasOwnProperty("@begin")) + { + begin = NumberFormatter.seconds(property.@begin); + end = property.hasOwnProperty("@dur") ? NumberFormatter.seconds(property.@dur) : NumberFormatter.seconds(property.@end) - begin; + } + + for each (var p:XML in property.p) + { + log.debug("found paragraph (p tag)"); + var time:int = begin ? begin : NumberFormatter.seconds(p.@begin); + var cue:Object = Cuepoint.createDynamic(time, "embedded"); + var parameters:Object = new Object(); + var pStyle:String = getStyleObj(p.@style).hasOwnProperty("color") ? p.@style : divStyle; + var endTime:int = end ? end : (p.hasOwnProperty("@dur") ? NumberFormatter.seconds(p.@dur) : NumberFormatter.seconds(p.@end) - time); + var name:String = p.hasOwnProperty("@id") ? p.@*::id : (property.hasOwnProperty("@id") ? property.@*::id : "cue" + cueRow); + + cue.captionType = "external"; + cue.time = time; + + cue.name = name; + cue.type = "event"; + parameters.begin = time; + parameters.end = endTime; + parameters.lang = lang; + parameters.style = pStyle; + + var content:String = ""; + for each (var child:XML in p.children()) { + if (child.localName() == "br") { + content += "<br/>"; + } else { + content += child.toString(); + } + } + + parameters.text = content; + cue.parameters = parameters; + arr.push(cue); + log.debug("added cuepoint " + cue + " with text " + parameters.text); + cueRow++; + } + + } + + return arr; + } + + + public function parseStyles(style:XMLList):FlowStyleSheet + { + + for each (var styleProperty:XML in style) + { + var styleObj:Object = styleProperty.hasOwnProperty("@style") + ? styles.getStyle("." + styleProperty.@style) + : {}; + + for each (var attr:XML in styleProperty.@*) + { + var name:String = attr.name().localName; + log.debug("style name " + name + ": " + SIMPLE_FORMATTING_PROPS.indexOf(name)); + if (! _simpleFormatting || SIMPLE_FORMATTING_PROPS.indexOf(name) >= 0) { + log.debug("applied style " + name + " to value " + attr); + styleObj[name] = attr; + } + } + + styles.setStyle("." + styleProperty.@id, styleObj); + } + return styles; + } + + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.captions/src/flash/closebutton.fla b/typo3/contrib/flowplayer/flowplayer.captions/src/flash/closebutton.fla new file mode 100644 index 0000000000000000000000000000000000000000..6f9d75529e560b0f05d5fb3c06214fede003df37 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/src/flash/closebutton.fla differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/src/flash/closebutton.swc b/typo3/contrib/flowplayer/flowplayer.captions/src/flash/closebutton.swc new file mode 100644 index 0000000000000000000000000000000000000000..ad0c441983c7c94a0e77c78880e920d41c559197 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/src/flash/closebutton.swc differ diff --git a/typo3/contrib/flowplayer/flowplayer.captions/src/flash/closebutton.swf b/typo3/contrib/flowplayer/flowplayer.captions/src/flash/closebutton.swf new file mode 100644 index 0000000000000000000000000000000000000000..4ee488f76370caa139a06777ab6bc24f981a417f Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.captions/src/flash/closebutton.swf differ diff --git a/typo3/contrib/flowplayer/flowplayer.content-3.2.0.swf b/typo3/contrib/flowplayer/flowplayer.content-3.2.0.swf new file mode 100644 index 0000000000000000000000000000000000000000..33498f439a672f1af5db513941f5799eef42e398 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.content-3.2.0.swf differ diff --git a/typo3/contrib/flowplayer/flowplayer.content/LICENSE.txt b/typo3/contrib/flowplayer/flowplayer.content/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..bab38cb72d259c5e3fb965912a138a62c0dc2c1a --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.content/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2008, 2009 Flowplayer Oy + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/typo3/contrib/flowplayer/flowplayer.content/README.txt b/typo3/contrib/flowplayer/flowplayer.content/README.txt new file mode 100644 index 0000000000000000000000000000000000000000..54fe9ef08413ed9b6ac6ba8087dd6d48125677de --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.content/README.txt @@ -0,0 +1,32 @@ +Version history: + +3.2.0 +----- +- Added new added onBeforeCss() and onBeforeAnimate() callback functions, that are now part of the Styleable interface. + +3.1.0 +----- +Changes: +- added public get and set functions for accessing the content view style property +- supports outlining the text with a black outline (using the flash glow filter), this is enabled using + textDecoration: 'outline' + +3.0.1 +----- +- dispatches the LOAD event when initialized (needed for flowplayer 3.0.2 compatibility) + +3.0.0 +----- +- 3.0.0-final release + +beta3 +----- +- does not change the text format initialized by the player + +beta2 +----- +- no changes, just practicing plugin versioning + +beta1 +----- +- First public beta release diff --git a/typo3/contrib/flowplayer/flowplayer.content/build.properties b/typo3/contrib/flowplayer/flowplayer.content/build.properties new file mode 100644 index 0000000000000000000000000000000000000000..e37cd70883b1fae34c72db752be24ccf3d61c880 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.content/build.properties @@ -0,0 +1,2 @@ +devkit-dir=../flowplayer.devkit +version=3.2.0 diff --git a/typo3/contrib/flowplayer/flowplayer.content/build.xml b/typo3/contrib/flowplayer/flowplayer.content/build.xml new file mode 100644 index 0000000000000000000000000000000000000000..9c4e709a62710d1280bb036474997bfef76c922d --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.content/build.xml @@ -0,0 +1,29 @@ +<project name="Flowplayer content" default="deploy"> + <property file="build.generated.properties"/> + + <property file="${user.home}/plugin.properties" /> + <property file="build.properties" /> + + <property file="${devkit-dir}/plugin-build.properties" /> + <import file="${devkit-dir}/plugin-build.xml"/> + <property name="flowplayer_lib" value="${devkit-dir}/flowplayer.swc" /> + + + <property name="basename" value="flowplayer.content" /> + <property name="releasedir" value="${basename}" /> + <property name="plugin-binary" value="${basename}.swf" /> + <property name="plugin-binary-versioned" value="${basename}-${version}.swf" /> + <property name="plugin-main-class" value="org/flowplayer/content/Content.as" /> + <property name="library-path" value="src/flash" /> + + <target name="release" description="makes a release" depends="build"> + <copyrelease targetdir="flowplayer.content"> + <releasefiles> + <fileset dir="${build-dir}"> + <include name="${plugin-binary-versioned}"/> + </fileset> + </releasefiles> + </copyrelease> + </target> + +</project> \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.content/src/actionscript/org/flowplayer/content/CloseButton.as b/typo3/contrib/flowplayer/flowplayer.content/src/actionscript/org/flowplayer/content/CloseButton.as new file mode 100644 index 0000000000000000000000000000000000000000..866883528e96de8d4a4af2551bda4d6d730da971 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.content/src/actionscript/org/flowplayer/content/CloseButton.as @@ -0,0 +1 @@ +/* * This file is part of Flowplayer, http://flowplayer.org * * By: Anssi Piirainen, <support@flowplayer.org> * Copyright (c) 2008, 2009 Flowplayer Oy * * Released under the MIT License: * http://www.opensource.org/licenses/mit-license.php */ package org.flowplayer.content { import flash.display.DisplayObject; import flash.display.Sprite; import flash.events.MouseEvent; /** * @author api */ internal class CloseButton extends Sprite { private var _icon:DisplayObject; public function CloseButton(icon:DisplayObject = null) { _icon = icon || new CloseIcon(); _icon.width = 10; _icon.height = 10; addChild(_icon); addEventListener(MouseEvent.MOUSE_OVER, onMouseOver); addEventListener(MouseEvent.MOUSE_OUT, onMouseOut); onMouseOut(); buttonMode = true; } private function onMouseOut(event:MouseEvent = null):void { _icon.alpha = 0.7; } private function onMouseOver(event:MouseEvent):void { _icon.alpha = 1; } } } \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.content/src/actionscript/org/flowplayer/content/Content.as b/typo3/contrib/flowplayer/flowplayer.content/src/actionscript/org/flowplayer/content/Content.as new file mode 100644 index 0000000000000000000000000000000000000000..5b63446db5f2f2280b15b6b31a2392c4e7a6f615 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.content/src/actionscript/org/flowplayer/content/Content.as @@ -0,0 +1 @@ +/* * This file is part of Flowplayer, http://flowplayer.org * * By: Anssi Piirainen, <support@flowplayer.org> * Copyright (c) 2008, 2009 Flowplayer Oy * * Released under the MIT License: * http://www.opensource.org/licenses/mit-license.php */ package org.flowplayer.content { import org.flowplayer.util.Assert; import org.flowplayer.model.DisplayPluginModel; import flash.display.DisplayObject; import flash.display.DisplayObjectContainer; import flash.events.Event; import flash.events.MouseEvent; import org.flowplayer.content.ContentView; import org.flowplayer.controller.ResourceLoader; import org.flowplayer.model.Plugin; import org.flowplayer.model.PluginEventType; import org.flowplayer.model.PluginModel; import org.flowplayer.util.Log; import org.flowplayer.view.AbstractSprite; import org.flowplayer.view.FlowStyleSheet; import org.flowplayer.view.Flowplayer; import org.flowplayer.view.Styleable; import org.flowplayer.view.StyleableSprite; /** * Content plugin. * * @author api */ public class Content extends AbstractSprite implements Plugin, Styleable { private var _styleSheetFile:String; private var _player:Flowplayer; private var _model:PluginModel; private var _contentView:ContentView; private var _html:String; private var _closeButton:Boolean = false; private var _closeImage:String; public function Content() { addListeners(); } internal function addListeners():void { addEventListener(MouseEvent.ROLL_OVER, onMouseOver); addEventListener(MouseEvent.ROLL_OUT, onMouseOut); addEventListener(MouseEvent.CLICK, onClick); } internal function removeListeners():void { removeEventListener(MouseEvent.ROLL_OVER, onMouseOver); removeEventListener(MouseEvent.ROLL_OUT, onMouseOut); removeEventListener(MouseEvent.CLICK, onClick); } override protected function onResize():void { if (!_contentView) return; _contentView.setSize(width, height); _contentView.x = 0; _contentView.y = 0; } /** * Sets the plugin model. This gets called before the plugin * has been added to the display list and before the player is set. * @param plugin */ public function onConfig(plugin:PluginModel):void { _model = plugin; if (plugin.config) { log.debug("config object received with html " + plugin.config.html + ", stylesheet " + plugin.config.stylesheet); _styleSheetFile = plugin.config.stylesheet; _html = plugin.config.html; _closeButton = plugin.config.closeButton; _closeImage = plugin.config.closeImage; } } /** * Sets the Flowplayer interface. The interface is immediately ready to use, all * other plugins have been loaded an initialized also. * @param player */ public function onLoad(player:Flowplayer):void { log.info("set player"); _player = player; if (_styleSheetFile || _closeImage) { loadResources(_styleSheetFile, _closeImage); } else { createContentView(null, null); _model.dispatchOnLoad(); } } /** * Sets the HTML content. * @param htmlText */ [External] public function set html(htmlText:String):void { log.debug("set hetml()"); _contentView.html = htmlText; } public function get html():String { log.debug("get hetml()"); return _contentView.html; } /** * Appends HTML text to the content. * @param htmlText * @return the new text after append */ [External] public function append(htmlText:String):String { log.debug("apped()"); return _contentView.append(htmlText); } /** * Loads a new stylesheet and changes the style from the loaded sheet. */ [External] public function loadStylesheet(styleSheetFile:String):void { if (! styleSheetFile) return; log.info("loading stylesheet from " + styleSheetFile); loadResources(styleSheetFile); } /** * Sets style properties. */ public function css(styleProps:Object = null):Object { var result:Object = _contentView.css(styleProps); return result; } public function get style():FlowStyleSheet { return _contentView ? _contentView.style : null; } public function set style(value:FlowStyleSheet):void { Assert.notNull(_contentView, "content view not created yet"); _contentView.style = value; } private function loadResources(styleSheetFile:String = null, imageFile:String = null):void { var loader:ResourceLoader = _player.createLoader(); if (styleSheetFile) { log.debug("loading stylesheet from file " + _styleSheetFile); } if (imageFile) { log.debug("loading closeImage from file " + _closeImage); } if (styleSheetFile) { loader.addTextResourceUrl(styleSheetFile); } if (imageFile) { loader.addBinaryResourceUrl(imageFile); } loader.load(null, onResourcesLoaded); } private function onResourcesLoaded(loader:ResourceLoader):void { if (_contentView) { if (_styleSheetFile) { _contentView.style = createStyleSheet(loader.getContent(_styleSheetFile) as String); } if (_closeImage) { _contentView.closeImage = loader.getContent(_closeImage) as DisplayObject; } } else { createContentView(_styleSheetFile ? loader.getContent(_styleSheetFile) as String : null, _closeImage ? loader.getContent(_closeImage) as DisplayObject : null); } _model.dispatchOnLoad(); } private function createStyleSheet(cssText:String = null):FlowStyleSheet { var styleSheet:FlowStyleSheet = new FlowStyleSheet("#content", cssText); // all root style properties come in config root (backgroundImage, backgroundGradient, borderRadius etc) addRules(styleSheet, _model.config); // style rules for the textField come inside a style node addRules(styleSheet, _model.config.style); return styleSheet; } private function addRules(styleSheet:FlowStyleSheet, rules:Object):void { var rootStyleProps:Object; for (var styleName:String in rules) { log.debug("adding additional style rule for " + styleName); if (FlowStyleSheet.isRootStyleProperty(styleName)) { if (! rootStyleProps) { rootStyleProps = new Object(); } log.debug("setting root style property " + styleName + " to value " + rules[styleName]); rootStyleProps[styleName] = rules[styleName]; } else { styleSheet.setStyle(styleName, rules[styleName]); } } styleSheet.addToRootStyle(rootStyleProps); } private function createContentView(cssText:String = null, closeImage:DisplayObject = null):void { log.debug("creating content view"); _contentView = new ContentView(_model as DisplayPluginModel, _player, _closeButton); if (closeImage) { _contentView.closeImage = closeImage; } log.debug("callign onResize"); onResize(); // make it correct size before adding to display list (avoids unnecessary re-arrangement) log.debug("setting stylesheet " + cssText); _contentView.style = createStyleSheet(cssText); log.debug("setting html"); _contentView.html = _html; log.debug("adding to display list"); addChild(_contentView); } public override function set alpha(value:Number):void { super.alpha = value; if (!_contentView) return; _contentView.alpha = value; } private function onMouseOver(event:MouseEvent):void { if (!_model) return; if (_contentView.redrawing) return; _model.dispatch(PluginEventType.PLUGIN_EVENT, "onMouseOver"); } private function onMouseOut(event:MouseEvent):void { if (!_model) return; _model.dispatch(PluginEventType.PLUGIN_EVENT, "onMouseOut"); } private function onClick(event:MouseEvent):void { if (!_model) return; _model.dispatch(PluginEventType.PLUGIN_EVENT, "onClick"); } public function getDefaultConfig():Object { return { top: 10, left: '50%', width: '95%', height: 50, opacity: 0.9, borderRadius: 10, backgroundGradient: 'low' }; } public function animate(styleProps:Object):Object { return _contentView.animate(styleProps); } public function onBeforeCss(styleProps:Object = null):void { } public function onBeforeAnimate(styleProps:Object):void { } } } \ No newline at end of file diff --git a/typo3/contrib/flowplayer/flowplayer.content/src/actionscript/org/flowplayer/content/ContentView.as b/typo3/contrib/flowplayer/flowplayer.content/src/actionscript/org/flowplayer/content/ContentView.as new file mode 100644 index 0000000000000000000000000000000000000000..0a776b50cc2dba2f2708fecae35ee42f83815661 --- /dev/null +++ b/typo3/contrib/flowplayer/flowplayer.content/src/actionscript/org/flowplayer/content/ContentView.as @@ -0,0 +1,190 @@ +/* + * This file is part of Flowplayer, http://flowplayer.org + * + * By: Anssi Piirainen, <support@flowplayer.org> + * Copyright (c) 2008, 2009 Flowplayer Oy + * + * Released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + */ +package org.flowplayer.content { + import flash.filters.GlowFilter; + + import org.flowplayer.model.DisplayPluginModel; + import org.flowplayer.view.FlowStyleSheet; + import org.flowplayer.view.Flowplayer; + import org.flowplayer.view.StyleableSprite; + + import flash.display.BlendMode; + import flash.display.DisplayObject; + import flash.display.Sprite; + import flash.events.MouseEvent; + import flash.text.AntiAliasType; + import flash.text.TextField; + import flash.text.TextFieldAutoSize; + + /** + * @author api + */ + internal class ContentView extends StyleableSprite { + + private var _text:TextField; + private var _textMask:Sprite; + private var _closeButton:CloseButton; + private var _htmlText:String; + private var _player:Flowplayer; + private var _plugin:DisplayPluginModel; + private var _originalAlpha:Number; + + public function ContentView(plugin:DisplayPluginModel, player:Flowplayer, closeButton:Boolean) { + super(null, player, player.createLoader()); + _plugin = plugin; + _player = player; + if (closeButton) { + createCloseButton(); + } + } + + override protected function onSetStyle(style:FlowStyleSheet):void { + log.debug("onSetStyle"); + createTextField(_text ? _text.htmlText : null); + } + + override protected function onSetStyleObject(styleName:String, style:Object):void { + log.debug("onSetStyleObject"); + createTextField(_text ? _text.htmlText : null); + } + + public function set html(htmlText:String):void { + _htmlText = htmlText; + if (! _htmlText) { + _htmlText = ""; + } + _text.htmlText = "<body>" + _htmlText + "</body>"; + log.debug("set html to " + _text.htmlText); + } + + public function get html():String { + return _htmlText; + } + + public function append(htmlText:String):String { + html = _htmlText + htmlText; + log.debug("appended html to " + _text.htmlText); + return _htmlText; + } + + public function set closeImage(image:DisplayObject):void { + if (_closeButton) { + removeChild(_closeButton); + } + createCloseButton(image); + } + + private function createTextField(htmlText:String = null):void { + log.debug("creating text field for text " + htmlText); + if (_text) { + removeChild(_text); + } + _text = _player.createTextField(); + _text.blendMode = BlendMode.LAYER; + _text.autoSize = TextFieldAutoSize.CENTER; + _text.wordWrap = true; + _text.multiline = true; + _text.antiAliasType = AntiAliasType.ADVANCED; + _text.condenseWhite = true; + + log.info("style.textDecoration " + style.textDecoration); + if (style.textDecoration == "outline") { + log.debug("setting textDecoration") + var glow:GlowFilter = new GlowFilter(0, .80, 2, 4, 6); + var filters:Array = [glow]; + _text.filters = filters; + } + + addChild(_text); + if (style) { + _text.styleSheet = style.styleSheet; + } + if (htmlText) { + log.debug("setting html to " + htmlText); + html = htmlText; + } + _textMask = createMask(); + addChild(_textMask); + _text.mask = _textMask; + arrangeText(); + } + + private function arrangeText():void { + if (! (_text && style)) return; + var padding:Array = style.padding; + log.debug("arranging text with padding " + padding + " height is " + height); + // only reset values if they change, otherwise there will be visual "blinking" of text/images + setTextProperty("y", padding[0]); + setTextProperty("x", padding[3]); + setTextProperty("height", height - padding[0] - padding[2]); + setTextProperty("width", width - padding[1] - padding[3]); + } + + private function setTextProperty(prop:String, value:Number):void { + if (_text[prop] != value) { + log.debug("setting text property " + prop + " to value " + value); + _text[prop] = value; + } + } + + override protected function onResize():void { + arrangeCloseButton(); + if (_textMask) { + _textMask.width = width; + _textMask.height = height; + } + this.x = 0; + this.y = 0; + } + + override protected function onRedraw():void { + arrangeText(); + arrangeCloseButton(); + } + + private function arrangeCloseButton():void { + if (_closeButton && style) { + _closeButton.x = width - _closeButton.width - 1 - style.borderRadius / 5; + _closeButton.y = 1 + style.borderRadius / 5; + setChildIndex(_closeButton, numChildren - 1); + } + } + + private function createCloseButton(icon:DisplayObject = null):void { + _closeButton = new CloseButton(icon); + addChild(_closeButton); + _closeButton.addEventListener(MouseEvent.CLICK, onCloseClicked); + } + + private function onCloseClicked(event:MouseEvent):void { + Content(_plugin.getDisplayObject()).removeListeners(); + _originalAlpha = _plugin.getDisplayObject().alpha; + _player.animationEngine.fadeOut(_plugin.getDisplayObject(), 500, onFadeOut); + } + + private function onFadeOut():void { + log.debug("faded out"); + // + // restore original alpha value + _plugin.alpha = _originalAlpha; + _plugin.getDisplayObject().alpha = _originalAlpha; + // we need to update the properties to the registry, so that animations happen correctly after this + _player.pluginRegistry.updateDisplayProperties(_plugin); + + Content(_plugin.getDisplayObject()).addListeners(); + } + + override public function set alpha(value:Number):void { + super.alpha = value; + if (! _text) return; + _text.alpha = value; + } + } +} diff --git a/typo3/contrib/flowplayer/flowplayer.content/src/flash/closebutton.fla b/typo3/contrib/flowplayer/flowplayer.content/src/flash/closebutton.fla new file mode 100644 index 0000000000000000000000000000000000000000..6f9d75529e560b0f05d5fb3c06214fede003df37 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.content/src/flash/closebutton.fla differ diff --git a/typo3/contrib/flowplayer/flowplayer.content/src/flash/closebutton.swc b/typo3/contrib/flowplayer/flowplayer.content/src/flash/closebutton.swc new file mode 100644 index 0000000000000000000000000000000000000000..ad0c441983c7c94a0e77c78880e920d41c559197 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.content/src/flash/closebutton.swc differ diff --git a/typo3/contrib/flowplayer/flowplayer.content/src/flash/closebutton.swf b/typo3/contrib/flowplayer/flowplayer.content/src/flash/closebutton.swf new file mode 100644 index 0000000000000000000000000000000000000000..4ee488f76370caa139a06777ab6bc24f981a417f Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.content/src/flash/closebutton.swf differ diff --git a/typo3/contrib/flowplayer/flowplayer.controls-3.2.5.swf b/typo3/contrib/flowplayer/flowplayer.controls-3.2.5.swf new file mode 100644 index 0000000000000000000000000000000000000000..5507a531ddcc0baccaf1339c852ee1623dfd5b05 Binary files /dev/null and b/typo3/contrib/flowplayer/flowplayer.controls-3.2.5.swf differ diff --git a/typo3/contrib/flowplayer/lib/corelib/license.txt b/typo3/contrib/flowplayer/lib/corelib/license.txt new file mode 100644 index 0000000000000000000000000000000000000000..d95fea60d9cd868fa05e51201427bc59af5f0f57 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/license.txt @@ -0,0 +1,33 @@ +Adobe Systems Incorporated(r) Source Code License Agreement +Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + +Please read this Source Code License Agreement carefully before using +the source code. + +Adobe Systems Incorporated grants to you a perpetual, worldwide, +non-exclusive, no-charge, royalty-free, irrevocable copyright license, +to reproduce, prepare derivative works of, publicly display, publicly +perform, and distribute this source code and such derivative works in +source or object code form without any attribution requirements. + +The name "Adobe Systems Incorporated" must not be used to endorse or +promote products derived from the source code without prior written +permission. + +You agree to indemnify, hold harmless and defend Adobe Systems +Incorporated from and against any loss, damage, claims or lawsuits, +including attorney's fees that arise or result from your use or +distribution of the source code. + +THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT ANY +TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO +WARRANTY OF NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT +SHALL MACROMEDIA OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOURCE CODE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/typo3/contrib/flowplayer/lib/corelib/readme.txt b/typo3/contrib/flowplayer/lib/corelib/readme.txt new file mode 100644 index 0000000000000000000000000000000000000000..51c60f786d6c9de0434baf98b97e7c2ff228079e --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/readme.txt @@ -0,0 +1,5 @@ +corelib ActionScript 3 Library +Release version .90 + +Project Homepage: +http://code.google.com/p/as3corelib/ \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/crypto/MD5.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/crypto/MD5.as new file mode 100644 index 0000000000000000000000000000000000000000..f5c0e02f1add9aa7c7edc54c7a0b1841f8f36708 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/crypto/MD5.as @@ -0,0 +1,256 @@ +/* +Adobe Systems Incorporated(r) Source Code License Agreement +Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + +Please read this Source Code License Agreement carefully before using +the source code. + +Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable copyright license, to reproduce, +prepare derivative works of, publicly display, publicly perform, and +distribute this source code and such derivative works in source or +object code form without any attribution requirements. + +The name "Adobe Systems Incorporated" must not be used to endorse or promote products +derived from the source code without prior written permission. + +You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and +against any loss, damage, claims or lawsuits, including attorney's +fees that arise or result from your use or distribution of the source +code. + +THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT +ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF +NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA +OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.crypto { + + import com.adobe.utils.IntUtil; + + /** + * The MD5 Message-Digest Algorithm + * + * Implementation based on algorithm description at + * http://www.faqs.org/rfcs/rfc1321.html + */ + public class MD5 { + + /** + * Performs the MD5 hash algorithm on a string. + * + * @param s The string to hash + * @return A string containing the hash value of s + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function hash( s:String ):String { + // initialize the md buffers + var a:int = 1732584193; + var b:int = -271733879; + var c:int = -1732584194; + var d:int = 271733878; + + // variables to store previous values + var aa:int; + var bb:int; + var cc:int; + var dd:int; + + // create the blocks from the string and + // save the length as a local var to reduce + // lookup in the loop below + var x:Array = createBlocks( s ); + var len:int = x.length; + + // loop over all of the blocks + for ( var i:int = 0; i < len; i += 16) { + // save previous values + aa = a; + bb = b; + cc = c; + dd = d; + + // Round 1 + a = ff( a, b, c, d, x[i+ 0], 7, -680876936 ); // 1 + d = ff( d, a, b, c, x[i+ 1], 12, -389564586 ); // 2 + c = ff( c, d, a, b, x[i+ 2], 17, 606105819 ); // 3 + b = ff( b, c, d, a, x[i+ 3], 22, -1044525330 ); // 4 + a = ff( a, b, c, d, x[i+ 4], 7, -176418897 ); // 5 + d = ff( d, a, b, c, x[i+ 5], 12, 1200080426 ); // 6 + c = ff( c, d, a, b, x[i+ 6], 17, -1473231341 ); // 7 + b = ff( b, c, d, a, x[i+ 7], 22, -45705983 ); // 8 + a = ff( a, b, c, d, x[i+ 8], 7, 1770035416 ); // 9 + d = ff( d, a, b, c, x[i+ 9], 12, -1958414417 ); // 10 + c = ff( c, d, a, b, x[i+10], 17, -42063 ); // 11 + b = ff( b, c, d, a, x[i+11], 22, -1990404162 ); // 12 + a = ff( a, b, c, d, x[i+12], 7, 1804603682 ); // 13 + d = ff( d, a, b, c, x[i+13], 12, -40341101 ); // 14 + c = ff( c, d, a, b, x[i+14], 17, -1502002290 ); // 15 + b = ff( b, c, d, a, x[i+15], 22, 1236535329 ); // 16 + + // Round 2 + a = gg( a, b, c, d, x[i+ 1], 5, -165796510 ); // 17 + d = gg( d, a, b, c, x[i+ 6], 9, -1069501632 ); // 18 + c = gg( c, d, a, b, x[i+11], 14, 643717713 ); // 19 + b = gg( b, c, d, a, x[i+ 0], 20, -373897302 ); // 20 + a = gg( a, b, c, d, x[i+ 5], 5, -701558691 ); // 21 + d = gg( d, a, b, c, x[i+10], 9, 38016083 ); // 22 + c = gg( c, d, a, b, x[i+15], 14, -660478335 ); // 23 + b = gg( b, c, d, a, x[i+ 4], 20, -405537848 ); // 24 + a = gg( a, b, c, d, x[i+ 9], 5, 568446438 ); // 25 + d = gg( d, a, b, c, x[i+14], 9, -1019803690 ); // 26 + c = gg( c, d, a, b, x[i+ 3], 14, -187363961 ); // 27 + b = gg( b, c, d, a, x[i+ 8], 20, 1163531501 ); // 28 + a = gg( a, b, c, d, x[i+13], 5, -1444681467 ); // 29 + d = gg( d, a, b, c, x[i+ 2], 9, -51403784 ); // 30 + c = gg( c, d, a, b, x[i+ 7], 14, 1735328473 ); // 31 + b = gg( b, c, d, a, x[i+12], 20, -1926607734 ); // 32 + + // Round 3 + a = hh( a, b, c, d, x[i+ 5], 4, -378558 ); // 33 + d = hh( d, a, b, c, x[i+ 8], 11, -2022574463 ); // 34 + c = hh( c, d, a, b, x[i+11], 16, 1839030562 ); // 35 + b = hh( b, c, d, a, x[i+14], 23, -35309556 ); // 36 + a = hh( a, b, c, d, x[i+ 1], 4, -1530992060 ); // 37 + d = hh( d, a, b, c, x[i+ 4], 11, 1272893353 ); // 38 + c = hh( c, d, a, b, x[i+ 7], 16, -155497632 ); // 39 + b = hh( b, c, d, a, x[i+10], 23, -1094730640 ); // 40 + a = hh( a, b, c, d, x[i+13], 4, 681279174 ); // 41 + d = hh( d, a, b, c, x[i+ 0], 11, -358537222 ); // 42 + c = hh( c, d, a, b, x[i+ 3], 16, -722521979 ); // 43 + b = hh( b, c, d, a, x[i+ 6], 23, 76029189 ); // 44 + a = hh( a, b, c, d, x[i+ 9], 4, -640364487 ); // 45 + d = hh( d, a, b, c, x[i+12], 11, -421815835 ); // 46 + c = hh( c, d, a, b, x[i+15], 16, 530742520 ); // 47 + b = hh( b, c, d, a, x[i+ 2], 23, -995338651 ); // 48 + + // Round 4 + a = ii( a, b, c, d, x[i+ 0], 6, -198630844 ); // 49 + d = ii( d, a, b, c, x[i+ 7], 10, 1126891415 ); // 50 + c = ii( c, d, a, b, x[i+14], 15, -1416354905 ); // 51 + b = ii( b, c, d, a, x[i+ 5], 21, -57434055 ); // 52 + a = ii( a, b, c, d, x[i+12], 6, 1700485571 ); // 53 + d = ii( d, a, b, c, x[i+ 3], 10, -1894986606 ); // 54 + c = ii( c, d, a, b, x[i+10], 15, -1051523 ); // 55 + b = ii( b, c, d, a, x[i+ 1], 21, -2054922799 ); // 56 + a = ii( a, b, c, d, x[i+ 8], 6, 1873313359 ); // 57 + d = ii( d, a, b, c, x[i+15], 10, -30611744 ); // 58 + c = ii( c, d, a, b, x[i+ 6], 15, -1560198380 ); // 59 + b = ii( b, c, d, a, x[i+13], 21, 1309151649 ); // 60 + a = ii( a, b, c, d, x[i+ 4], 6, -145523070 ); // 61 + d = ii( d, a, b, c, x[i+11], 10, -1120210379 ); // 62 + c = ii( c, d, a, b, x[i+ 2], 15, 718787259 ); // 63 + b = ii( b, c, d, a, x[i+ 9], 21, -343485551 ); // 64 + + a += aa; + b += bb; + c += cc; + d += dd; + } + + // Finish up by concatening the buffers with their hex output + return IntUtil.toHex( a ) + IntUtil.toHex( b ) + IntUtil.toHex( c ) + IntUtil.toHex( d ); + } + + /** + * Auxiliary function f as defined in RFC + */ + private static function f( x:int, y:int, z:int ):int { + return ( x & y ) | ( (~x) & z ); + } + + /** + * Auxiliary function g as defined in RFC + */ + private static function g( x:int, y:int, z:int ):int { + return ( x & z ) | ( y & (~z) ); + } + + /** + * Auxiliary function h as defined in RFC + */ + private static function h( x:int, y:int, z:int ):int { + return x ^ y ^ z; + } + + /** + * Auxiliary function i as defined in RFC + */ + private static function i( x:int, y:int, z:int ):int { + return y ^ ( x | (~z) ); + } + + /** + * A generic transformation function. The logic of ff, gg, hh, and + * ii are all the same, minus the function used, so pull that logic + * out and simplify the method bodies for the transoformation functions. + */ + private static function transform( func:Function, a:int, b:int, c:int, d:int, x:int, s:int, t:int):int { + var tmp:int = a + int( func( b, c, d ) ) + x + t; + return IntUtil.rol( tmp, s ) + b; + } + + /** + * ff transformation function + */ + private static function ff ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int { + return transform( f, a, b, c, d, x, s, t ); + } + + /** + * gg transformation function + */ + private static function gg ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int { + return transform( g, a, b, c, d, x, s, t ); + } + + /** + * hh transformation function + */ + private static function hh ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int { + return transform( h, a, b, c, d, x, s, t ); + } + + /** + * ii transformation function + */ + private static function ii ( a:int, b:int, c:int, d:int, x:int, s:int, t:int ):int { + return transform( i, a, b, c, d, x, s, t ); + } + + /** + * Converts a string to a sequence of 16-word blocks + * that we'll do the processing on. Appends padding + * and length in the process. + * + * @param s The string to split into blocks + * @return An array containing the blocks that s was + * split into. + */ + private static function createBlocks( s:String ):Array { + var blocks:Array = new Array(); + var len:int = s.length * 8; + var mask:int = 0xFF; // ignore hi byte of characters > 0xFF + for( var i:int = 0; i < len; i += 8 ) { + blocks[ i >> 5 ] |= ( s.charCodeAt( i / 8 ) & mask ) << ( i % 32 ); + } + + // append padding and length + blocks[ len >> 5 ] |= 0x80 << ( len % 32 ); + blocks[ ( ( ( len + 64 ) >>> 9 ) << 4 ) + 14 ] = len; + return blocks; + } + + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/crypto/SHA1.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/crypto/SHA1.as new file mode 100644 index 0000000000000000000000000000000000000000..793157d4a917480908ed8fc151e5092864c69f83 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/crypto/SHA1.as @@ -0,0 +1,268 @@ +/* +Adobe Systems Incorporated(r) Source Code License Agreement +Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + +Please read this Source Code License Agreement carefully before using +the source code. + +Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable copyright license, to reproduce, +prepare derivative works of, publicly display, publicly perform, and +distribute this source code and such derivative works in source or +object code form without any attribution requirements. + +The name "Adobe Systems Incorporated" must not be used to endorse or promote products +derived from the source code without prior written permission. + +You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and +against any loss, damage, claims or lawsuits, including attorney's +fees that arise or result from your use or distribution of the source +code. + +THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT +ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF +NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA +OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.crypto +{ + import com.adobe.utils.IntUtil; + import flash.utils.ByteArray; + import mx.utils.Base64Encoder; + + /** + * US Secure Hash Algorithm 1 (SHA1) + * + * Implementation based on algorithm description at + * http://www.faqs.org/rfcs/rfc3174.html + */ + public class SHA1 + { + /** + * Performs the SHA1 hash algorithm on a string. + * + * @param s The string to hash + * @return A string containing the hash value of s + * @langversion ActionScript 3.0 + * @playerversion 9.0 + * @tiptext + */ + public static function hash( s:String ):String + { + var blocks:Array = createBlocksFromString( s ); + var byteArray:ByteArray = hashBlocks( blocks ); + + return IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ); + } + + /** + * Performs the SHA1 hash algorithm on a ByteArray. + * + * @param data The ByteArray data to hash + * @return A string containing the hash value of data + * @langversion ActionScript 3.0 + * @playerversion 9.0 + */ + public static function hashBytes( data:ByteArray ):String + { + var blocks:Array = SHA1.createBlocksFromByteArray( data ); + var byteArray:ByteArray = hashBlocks(blocks); + + return IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ); + } + + /** + * Performs the SHA1 hash algorithm on a string, then does + * Base64 encoding on the result. + * + * @param s The string to hash + * @return The base64 encoded hash value of s + * @langversion ActionScript 3.0 + * @playerversion 9.0 + * @tiptext + */ + public static function hashToBase64( s:String ):String + { + var blocks:Array = SHA1.createBlocksFromString( s ); + var byteArray:ByteArray = hashBlocks(blocks); + + // ByteArray.toString() returns the contents as a UTF-8 string, + // which we can't use because certain byte sequences might trigger + // a UTF-8 conversion. Instead, we convert the bytes to characters + // one by one. + var charsInByteArray:String = ""; + byteArray.position = 0; + for (var j:int = 0; j < byteArray.length; j++) + { + var byte:uint = byteArray.readUnsignedByte(); + charsInByteArray += String.fromCharCode(byte); + } + + var encoder:Base64Encoder = new Base64Encoder(); + encoder.encode(charsInByteArray); + return encoder.flush(); + } + + private static function hashBlocks( blocks:Array ):ByteArray + { + // initialize the h's + var h0:int = 0x67452301; + var h1:int = 0xefcdab89; + var h2:int = 0x98badcfe; + var h3:int = 0x10325476; + var h4:int = 0xc3d2e1f0; + + var len:int = blocks.length; + var w:Array = new Array( 80 ); + + // loop over all of the blocks + for ( var i:int = 0; i < len; i += 16 ) { + + // 6.1.c + var a:int = h0; + var b:int = h1; + var c:int = h2; + var d:int = h3; + var e:int = h4; + + // 80 steps to process each block + // TODO: unroll for faster execution, or 4 loops of + // 20 each to avoid the k and f function calls + for ( var t:int = 0; t < 80; t++ ) { + + if ( t < 16 ) { + // 6.1.a + w[ t ] = blocks[ i + t ]; + } else { + // 6.1.b + w[ t ] = IntUtil.rol( w[ t - 3 ] ^ w[ t - 8 ] ^ w[ t - 14 ] ^ w[ t - 16 ], 1 ); + } + + // 6.1.d + var temp:int = IntUtil.rol( a, 5 ) + f( t, b, c, d ) + e + int( w[ t ] ) + k( t ); + + e = d; + d = c; + c = IntUtil.rol( b, 30 ); + b = a; + a = temp; + } + + // 6.1.e + h0 += a; + h1 += b; + h2 += c; + h3 += d; + h4 += e; + } + + var byteArray:ByteArray = new ByteArray(); + byteArray.writeInt(h0); + byteArray.writeInt(h1); + byteArray.writeInt(h2); + byteArray.writeInt(h3); + byteArray.writeInt(h4); + byteArray.position = 0; + return byteArray; + } + + /** + * Performs the logical function based on t + */ + private static function f( t:int, b:int, c:int, d:int ):int { + if ( t < 20 ) { + return ( b & c ) | ( ~b & d ); + } else if ( t < 40 ) { + return b ^ c ^ d; + } else if ( t < 60 ) { + return ( b & c ) | ( b & d ) | ( c & d ); + } + return b ^ c ^ d; + } + + /** + * Determines the constant value based on t + */ + private static function k( t:int ):int { + if ( t < 20 ) { + return 0x5a827999; + } else if ( t < 40 ) { + return 0x6ed9eba1; + } else if ( t < 60 ) { + return 0x8f1bbcdc; + } + return 0xca62c1d6; + } + + /** + * Converts a ByteArray to a sequence of 16-word blocks + * that we'll do the processing on. Appends padding + * and length in the process. + * + * @param data The data to split into blocks + * @return An array containing the blocks into which data was split + */ + private static function createBlocksFromByteArray( data:ByteArray ):Array + { + var oldPosition:int = data.position; + data.position = 0; + + var blocks:Array = new Array(); + var len:int = data.length * 8; + var mask:int = 0xFF; // ignore hi byte of characters > 0xFF + for( var i:int = 0; i < len; i += 8 ) + { + blocks[ i >> 5 ] |= ( data.readByte() & mask ) << ( 24 - i % 32 ); + } + + // append padding and length + blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 ); + blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len; + + data.position = oldPosition; + + return blocks; + } + + /** + * Converts a string to a sequence of 16-word blocks + * that we'll do the processing on. Appends padding + * and length in the process. + * + * @param s The string to split into blocks + * @return An array containing the blocks that s was split into. + */ + private static function createBlocksFromString( s:String ):Array + { + var blocks:Array = new Array(); + var len:int = s.length * 8; + var mask:int = 0xFF; // ignore hi byte of characters > 0xFF + for( var i:int = 0; i < len; i += 8 ) { + blocks[ i >> 5 ] |= ( s.charCodeAt( i / 8 ) & mask ) << ( 24 - i % 32 ); + } + + // append padding and length + blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 ); + blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len; + return blocks; + } + + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/crypto/SHA224.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/crypto/SHA224.as new file mode 100644 index 0000000000000000000000000000000000000000..d1c46d0c9084c3b5e2421c35daecd7d06dd04582 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/crypto/SHA224.as @@ -0,0 +1,255 @@ +/* +Adobe Systems Incorporated(r) Source Code License Agreement +Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + +Please read this Source Code License Agreement carefully before using +the source code. + +Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable copyright license, to reproduce, +prepare derivative works of, publicly display, publicly perform, and +distribute this source code and such derivative works in source or +object code form without any attribution requirements. + +The name "Adobe Systems Incorporated" must not be used to endorse or promote products +derived from the source code without prior written permission. + +You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and +against any loss, damage, claims or lawsuits, including attorney's +fees that arise or result from your use or distribution of the source +code. + +THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT +ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF +NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA +OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.crypto +{ + import com.adobe.utils.IntUtil; + import flash.utils.ByteArray; + import mx.utils.Base64Encoder; + + /** + * The SHA-224 algorithm + * + * @see http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf + */ + public class SHA224 + { + + /** + * Performs the SHA224 hash algorithm on a string. + * + * @param s The string to hash + * @return A string containing the hash value of s + * @langversion ActionScript 3.0 + * @playerversion 9.0 + * @tiptext + */ + public static function hash( s:String ):String { + var blocks:Array = createBlocksFromString( s ); + var byteArray:ByteArray = hashBlocks( blocks ); + return IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ); + } + + /** + * Performs the SHA224 hash algorithm on a ByteArray. + * + * @param data The ByteArray data to hash + * @return A string containing the hash value of data + * @langversion ActionScript 3.0 + * @playerversion 9.0 + */ + public static function hashBytes( data:ByteArray ):String + { + var blocks:Array = createBlocksFromByteArray( data ); + var byteArray:ByteArray = hashBlocks(blocks); + return IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ); + } + + /** + * Performs the SHA224 hash algorithm on a string, then does + * Base64 encoding on the result. + * + * @param s The string to hash + * @return The base64 encoded hash value of s + * @langversion ActionScript 3.0 + * @playerversion 9.0 + * @tiptext + */ + public static function hashToBase64( s:String ):String + { + var blocks:Array = createBlocksFromString( s ); + var byteArray:ByteArray = hashBlocks(blocks); + + // ByteArray.toString() returns the contents as a UTF-8 string, + // which we can't use because certain byte sequences might trigger + // a UTF-8 conversion. Instead, we convert the bytes to characters + // one by one. + var charsInByteArray:String = ""; + byteArray.position = 0; + for (var j:int = 0; j < byteArray.length; j++) + { + var byte:uint = byteArray.readUnsignedByte(); + charsInByteArray += String.fromCharCode(byte); + } + + var encoder:Base64Encoder = new Base64Encoder(); + encoder.encode(charsInByteArray); + return encoder.flush(); + } + + private static function hashBlocks( blocks:Array ):ByteArray { + var h0:int = 0xc1059ed8; + var h1:int = 0x367cd507; + var h2:int = 0x3070dd17; + var h3:int = 0xf70e5939; + var h4:int = 0xffc00b31; + var h5:int = 0x68581511; + var h6:int = 0x64f98fa7; + var h7:int = 0xbefa4fa4; + + var k:Array = new Array(0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2); + + var len:int = blocks.length; + var w:Array = new Array(); + + // loop over all of the blocks + for ( var i:int = 0; i < len; i += 16 ) { + + var a:int = h0; + var b:int = h1; + var c:int = h2; + var d:int = h3; + var e:int = h4; + var f:int = h5; + var g:int = h6; + var h:int = h7; + + for(var t:int = 0; t < 64; t++) { + + if ( t < 16 ) { + w[t] = blocks[ i + t ]; + if(isNaN(w[t])) { w[t] = 0; } + } else { + var ws0:int = IntUtil.ror(w[t-15], 7) ^ IntUtil.ror(w[t-15], 18) ^ (w[t-15] >>> 3); + var ws1:int = IntUtil.ror(w[t-2], 17) ^ IntUtil.ror(w[t-2], 19) ^ (w[t-2] >>> 10); + w[t] = w[t-16] + ws0 + w[t-7] + ws1; + } + + var s0:int = IntUtil.ror(a, 2) ^ IntUtil.ror(a, 13) ^ IntUtil.ror(a, 22); + var maj:int = (a & b) ^ (a & c) ^ (b & c); + var t2:int = s0 + maj; + var s1:int = IntUtil.ror(e, 6) ^ IntUtil.ror(e, 11) ^ IntUtil.ror(e, 25); + var ch:int = (e & f) ^ ((~e) & g); + var t1:int = h + s1 + ch + k[t] + w[t]; + + h = g; + g = f; + f = e; + e = d + t1; + d = c; + c = b; + b = a; + a = t1 + t2; + } + + //Add this chunk's hash to result so far: + h0 += a; + h1 += b; + h2 += c; + h3 += d; + h4 += e; + h5 += f; + h6 += g; + h7 += h; + } + + var byteArray:ByteArray = new ByteArray(); + byteArray.writeInt(h0); + byteArray.writeInt(h1); + byteArray.writeInt(h2); + byteArray.writeInt(h3); + byteArray.writeInt(h4); + byteArray.writeInt(h5); + byteArray.writeInt(h6); + byteArray.position = 0; + return byteArray; + } + + /** + * Converts a ByteArray to a sequence of 16-word blocks + * that we'll do the processing on. Appends padding + * and length in the process. + * + * @param data The data to split into blocks + * @return An array containing the blocks into which data was split + */ + private static function createBlocksFromByteArray( data:ByteArray ):Array + { + var oldPosition:int = data.position; + data.position = 0; + + var blocks:Array = new Array(); + var len:int = data.length * 8; + var mask:int = 0xFF; // ignore hi byte of characters > 0xFF + for( var i:int = 0; i < len; i += 8 ) + { + blocks[ i >> 5 ] |= ( data.readByte() & mask ) << ( 24 - i % 32 ); + } + + // append padding and length + blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 ); + blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len; + + data.position = oldPosition; + + return blocks; + } + + /** + * Converts a string to a sequence of 16-word blocks + * that we'll do the processing on. Appends padding + * and length in the process. + * + * @param s The string to split into blocks + * @return An array containing the blocks that s was split into. + */ + private static function createBlocksFromString( s:String ):Array + { + var blocks:Array = new Array(); + var len:int = s.length * 8; + var mask:int = 0xFF; // ignore hi byte of characters > 0xFF + for( var i:int = 0; i < len; i += 8 ) { + blocks[ i >> 5 ] |= ( s.charCodeAt( i / 8 ) & mask ) << ( 24 - i % 32 ); + } + + // append padding and length + blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 ); + blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len; + return blocks; + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/crypto/SHA256.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/crypto/SHA256.as new file mode 100644 index 0000000000000000000000000000000000000000..00108b648537fb9503ebe3a4c000457a88889874 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/crypto/SHA256.as @@ -0,0 +1,260 @@ +/* +Adobe Systems Incorporated(r) Source Code License Agreement +Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + +Please read this Source Code License Agreement carefully before using +the source code. + +Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable copyright license, to reproduce, +prepare derivative works of, publicly display, publicly perform, and +distribute this source code and such derivative works in source or +object code form without any attribution requirements. + +The name "Adobe Systems Incorporated" must not be used to endorse or promote products +derived from the source code without prior written permission. + +You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and +against any loss, damage, claims or lawsuits, including attorney's +fees that arise or result from your use or distribution of the source +code. + +THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT +ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF +NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA +OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.crypto +{ + import com.adobe.utils.IntUtil; + import flash.utils.ByteArray; + import mx.utils.Base64Encoder; + + /** + * The SHA-256 algorithm + * + * @see http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf + */ + public class SHA256 + { + + /** + * Performs the SHA256 hash algorithm on a string. + * + * @param s The string to hash + * @return A string containing the hash value of s + * @langversion ActionScript 3.0 + * @playerversion 9.0 + * @tiptext + */ + public static function hash( s:String ):String { + var blocks:Array = createBlocksFromString( s ); + var byteArray:ByteArray = hashBlocks( blocks ); + + return IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ); + } + + /** + * Performs the SHA256 hash algorithm on a ByteArray. + * + * @param data The ByteArray data to hash + * @return A string containing the hash value of data + * @langversion ActionScript 3.0 + * @playerversion 9.0 + */ + public static function hashBytes( data:ByteArray ):String + { + var blocks:Array = createBlocksFromByteArray( data ); + var byteArray:ByteArray = hashBlocks(blocks); + + return IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ) + + IntUtil.toHex( byteArray.readInt(), true ); + } + + /** + * Performs the SHA256 hash algorithm on a string, then does + * Base64 encoding on the result. + * + * @param s The string to hash + * @return The base64 encoded hash value of s + * @langversion ActionScript 3.0 + * @playerversion 9.0 + * @tiptext + */ + public static function hashToBase64( s:String ):String + { + var blocks:Array = createBlocksFromString( s ); + var byteArray:ByteArray = hashBlocks(blocks); + + // ByteArray.toString() returns the contents as a UTF-8 string, + // which we can't use because certain byte sequences might trigger + // a UTF-8 conversion. Instead, we convert the bytes to characters + // one by one. + var charsInByteArray:String = ""; + byteArray.position = 0; + for (var j:int = 0; j < byteArray.length; j++) + { + var byte:uint = byteArray.readUnsignedByte(); + charsInByteArray += String.fromCharCode(byte); + } + + var encoder:Base64Encoder = new Base64Encoder(); + encoder.encode(charsInByteArray); + return encoder.flush(); + } + + private static function hashBlocks( blocks:Array ):ByteArray { + var h0:int = 0x6a09e667; + var h1:int = 0xbb67ae85; + var h2:int = 0x3c6ef372; + var h3:int = 0xa54ff53a; + var h4:int = 0x510e527f; + var h5:int = 0x9b05688c; + var h6:int = 0x1f83d9ab; + var h7:int = 0x5be0cd19; + + var k:Array = new Array(0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2); + + var len:int = blocks.length; + var w:Array = new Array( 64 ); + + // loop over all of the blocks + for ( var i:int = 0; i < len; i += 16 ) { + + var a:int = h0; + var b:int = h1; + var c:int = h2; + var d:int = h3; + var e:int = h4; + var f:int = h5; + var g:int = h6; + var h:int = h7; + + for(var t:int = 0; t < 64; t++) { + + if ( t < 16 ) { + w[t] = blocks[ i + t ]; + if(isNaN(w[t])) { w[t] = 0; } + } else { + var ws0:int = IntUtil.ror(w[t-15], 7) ^ IntUtil.ror(w[t-15], 18) ^ (w[t-15] >>> 3); + var ws1:int = IntUtil.ror(w[t-2], 17) ^ IntUtil.ror(w[t-2], 19) ^ (w[t-2] >>> 10); + w[t] = w[t-16] + ws0 + w[t-7] + ws1; + } + + var s0:int = IntUtil.ror(a, 2) ^ IntUtil.ror(a, 13) ^ IntUtil.ror(a, 22); + var maj:int = (a & b) ^ (a & c) ^ (b & c); + var t2:int = s0 + maj; + var s1:int = IntUtil.ror(e, 6) ^ IntUtil.ror(e, 11) ^ IntUtil.ror(e, 25); + var ch:int = (e & f) ^ ((~e) & g); + var t1:int = h + s1 + ch + k[t] + w[t]; + + h = g; + g = f; + f = e; + e = d + t1; + d = c; + c = b; + b = a; + a = t1 + t2; + } + + //Add this chunk's hash to result so far: + h0 += a; + h1 += b; + h2 += c; + h3 += d; + h4 += e; + h5 += f; + h6 += g; + h7 += h; + } + + var byteArray:ByteArray = new ByteArray(); + byteArray.writeInt(h0); + byteArray.writeInt(h1); + byteArray.writeInt(h2); + byteArray.writeInt(h3); + byteArray.writeInt(h4); + byteArray.writeInt(h5); + byteArray.writeInt(h6); + byteArray.writeInt(h7); + byteArray.position = 0; + return byteArray; + } + + /** + * Converts a ByteArray to a sequence of 16-word blocks + * that we'll do the processing on. Appends padding + * and length in the process. + * + * @param data The data to split into blocks + * @return An array containing the blocks into which data was split + */ + private static function createBlocksFromByteArray( data:ByteArray ):Array + { + var oldPosition:int = data.position; + data.position = 0; + + var blocks:Array = new Array(); + var len:int = data.length * 8; + var mask:int = 0xFF; // ignore hi byte of characters > 0xFF + for( var i:int = 0; i < len; i += 8 ) + { + blocks[ i >> 5 ] |= ( data.readByte() & mask ) << ( 24 - i % 32 ); + } + + // append padding and length + blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 ); + blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len; + + data.position = oldPosition; + + return blocks; + } + + /** + * Converts a string to a sequence of 16-word blocks + * that we'll do the processing on. Appends padding + * and length in the process. + * + * @param s The string to split into blocks + * @return An array containing the blocks that s was split into. + */ + private static function createBlocksFromString( s:String ):Array + { + var blocks:Array = new Array(); + var len:int = s.length * 8; + var mask:int = 0xFF; // ignore hi byte of characters > 0xFF + for( var i:int = 0; i < len; i += 8 ) { + blocks[ i >> 5 ] |= ( s.charCodeAt( i / 8 ) & mask ) << ( 24 - i % 32 ); + } + + // append padding and length + blocks[ len >> 5 ] |= 0x80 << ( 24 - len % 32 ); + blocks[ ( ( ( len + 64 ) >> 9 ) << 4 ) + 15 ] = len; + return blocks; + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/crypto/WSSEUsernameToken.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/crypto/WSSEUsernameToken.as new file mode 100644 index 0000000000000000000000000000000000000000..58a33604c2fa9c4074586dbedb2c0d9d91acc5a4 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/crypto/WSSEUsernameToken.as @@ -0,0 +1,117 @@ +/* +Adobe Systems Incorporated(r) Source Code License Agreement +Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + +Please read this Source Code License Agreement carefully before using +the source code. + +Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable copyright license, to reproduce, +prepare derivative works of, publicly display, publicly perform, and +distribute this source code and such derivative works in source or +object code form without any attribution requirements. + +The name "Adobe Systems Incorporated" must not be used to endorse or promote products +derived from the source code without prior written permission. + +You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and +against any loss, damage, claims or lawsuits, including attorney's +fees that arise or result from your use or distribution of the source +code. + +THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT +ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF +NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA +OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.crypto +{ + import mx.formatters.DateFormatter; + import mx.utils.Base64Encoder; + + /** + * Web Services Security Username Token + * + * Implementation based on algorithm description at + * http://www.oasis-open.org/committees/wss/documents/WSS-Username-02-0223-merged.pdf + */ + public class WSSEUsernameToken + { + /** + * Generates a WSSE Username Token. + * + * @param username The username + * @param password The password + * @param nonce A cryptographically random nonce (if null, the nonce + * will be generated) + * @param timestamp The time at which the token is generated (if null, + * the time will be set to the moment of execution) + * @return The generated token + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function getUsernameToken(username:String, password:String, nonce:String=null, timestamp:Date=null):String + { + if (nonce == null) + { + nonce = generateNonce(); + } + nonce = base64Encode(nonce); + + var created:String = generateTimestamp(timestamp); + + var password64:String = getBase64Digest(nonce, + created, + password); + + var token:String = new String("UsernameToken Username=\""); + token += username + "\", " + + "PasswordDigest=\"" + password64 + "\", " + + "Nonce=\"" + nonce + "\", " + + "Created=\"" + created + "\""; + return token; + } + + private static function generateNonce():String + { + // Math.random returns a Number between 0 and 1. We don't want our + // nonce to contain invalid characters (e.g. the period) so we + // strip them out before returning the result. + var s:String = Math.random().toString(); + return s.replace(".", ""); + } + + internal static function base64Encode(s:String):String + { + var encoder:Base64Encoder = new Base64Encoder(); + encoder.encode(s); + return encoder.flush(); + } + + internal static function generateTimestamp(timestamp:Date):String + { + if (timestamp == null) + { + timestamp = new Date(); + } + var dateFormatter:DateFormatter = new DateFormatter(); + dateFormatter.formatString = "YYYY-MM-DDTJJ:NN:SS" + return dateFormatter.format(timestamp) + "Z"; + } + + internal static function getBase64Digest(nonce:String, created:String, password:String):String + { + return SHA1.hashToBase64(nonce + created + password); + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/errors/IllegalStateError.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/errors/IllegalStateError.as new file mode 100644 index 0000000000000000000000000000000000000000..2c83e363d7682524f51f5fadb17778b5a159fe64 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/errors/IllegalStateError.as @@ -0,0 +1,66 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.errors +{ + /** + * This class represents an Error that is thrown when a method is called when + * the receiving instance is in an invalid state. + * + * For example, this may occur if a method has been called, and other properties + * in the instance have not been initialized properly. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + */ + public class IllegalStateError extends Error + { + /** + * Constructor + * + * @param message A message describing the error in detail. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public function IllegalStateError(message:String) + { + super(message); + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/fileformats/vcard/Address.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/fileformats/vcard/Address.as new file mode 100644 index 0000000000000000000000000000000000000000..25852049f80391269ad2b2e206474df4a6975b63 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/fileformats/vcard/Address.as @@ -0,0 +1,50 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +package com.adobe.fileformats.vcard +{ + public class Address + { + public var type:String; + public var street:String; + public var city:String; + public var state:String; + public var postalCode:String; + + public function toString():String + { + return (street + " " + city + ", " + state + " " + postalCode); + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/fileformats/vcard/Email.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/fileformats/vcard/Email.as new file mode 100644 index 0000000000000000000000000000000000000000..c0b16ffc29ed1cc50fc2a359afd1dd75abd650c9 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/fileformats/vcard/Email.as @@ -0,0 +1,42 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +package com.adobe.fileformats.vcard +{ + public class Email + { + public var type:String; + public var address:String; + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/fileformats/vcard/Phone.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/fileformats/vcard/Phone.as new file mode 100644 index 0000000000000000000000000000000000000000..8159cc9375597de3b21fae20d2d3787568e74045 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/fileformats/vcard/Phone.as @@ -0,0 +1,42 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +package com.adobe.fileformats.vcard +{ + public class Phone + { + public var type:String; + public var number:String; + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/fileformats/vcard/VCard.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/fileformats/vcard/VCard.as new file mode 100644 index 0000000000000000000000000000000000000000..e8c873011b51740f56a47e48d20a22698a8b3a86 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/fileformats/vcard/VCard.as @@ -0,0 +1,57 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +package com.adobe.fileformats.vcard +{ + import flash.utils.ByteArray; + + public class VCard + { + public var fullName:String; + public var orgs:Array; + public var title:String; + public var image:ByteArray; + public var phones:Array; + public var emails:Array; + public var addresses:Array; + + public function VCard() + { + orgs = new Array(); + phones = new Array(); + emails = new Array(); + addresses = new Array(); + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/fileformats/vcard/VCardParser.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/fileformats/vcard/VCardParser.as new file mode 100644 index 0000000000000000000000000000000000000000..51f9ebcd7ce2084d893762b65b6ed531862227db --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/fileformats/vcard/VCardParser.as @@ -0,0 +1,249 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +package com.adobe.fileformats.vcard +{ + import mx.utils.Base64Decoder; + import mx.utils.StringUtil; + + public class VCardParser + { + public static function parse(vcardStr:String):Array + { + var vcards:Array = new Array(); + var lines:Array = vcardStr.split(/\r\n/); + var vcard:VCard; + var type:String; + var typeTmp:String; + var line:String; + + for (var i:uint = 0; i < lines.length; ++i) + { + line = lines[i]; + if (line == "BEGIN:VCARD") + { + vcard = new VCard(); + } + else if (line == "END:VCARD") + { + if (vcard != null) + { + vcards.push(vcard); + } + } + else if(line.search(/^ORG/i) != -1) + { + var org:String = line.substring(4, line.length); + var orgArray:Array = org.split(";"); + for each (var orgToken:String in orgArray) + { + if (StringUtil.trim(orgToken).length > 0) + { + vcard.orgs.push(orgToken); + } + } + } + else if(line.search(/^TITLE/i) != -1) + { + var title:String = line.substring(6, line.length); + vcard.title = title; + } + else if (line.search(/^FN:/i) != -1) + { + var fullName:String = line.substring(3, line.length); + vcard.fullName = fullName; + } + else if (line.search(/^TEL/i) != -1) + { + type = new String(); + typeTmp = new String(); + var phone:Phone = new Phone(); + var number:String; + var phoneTokens:Array = line.split(";"); + for each (var phoneToken:String in phoneTokens) + { + if (phoneToken.search(/^TYPE=/i) != -1) + { + if (phoneToken.indexOf(":") != -1) + { + typeTmp = phoneToken.substring(5, phoneToken.indexOf(":")); + number = phoneToken.substring(phoneToken.indexOf(":")+1, phoneToken.length); + } + else + { + typeTmp = phoneToken.substring(5, phoneToken.length); + } + + typeTmp = typeTmp.toLocaleLowerCase(); + + if (typeTmp == "pref") + { + continue; + } + if (type.length != 0) + { + type += (" "); + } + type += typeTmp; + } + } + if (type.length > 0 && number != null) + { + phone.type = type; + phone.number = number; + } + vcard.phones.push(phone); + } + else if (line.search(/^EMAIL/i) != -1) + { + type = new String(); + typeTmp = new String(); + var email:Email = new Email(); + var emailAddress:String; + var emailTokens:Array = line.split(";"); + for each (var emailToken:String in emailTokens) + { + if (emailToken.search(/^TYPE=/i) != -1) + { + if (emailToken.indexOf(":") != -1) + { + typeTmp = emailToken.substring(5, emailToken.indexOf(":")); + emailAddress = emailToken.substring(emailToken.indexOf(":")+1, emailToken.length); + } + else + { + typeTmp = emailToken.substring(5, emailToken.length); + } + + typeTmp = typeTmp.toLocaleLowerCase(); + + if (typeTmp == "pref" || typeTmp == "internet") + { + continue; + } + if (type.length != 0) + { + type += (" "); + } + type += typeTmp; + } + } + if (type.length > 0 && emailAddress != null) + { + email.type = type; + email.address = emailAddress; + } + vcard.emails.push(email); + } + else if (line.indexOf("ADR;") != -1) + { + var addressTokens:Array = line.split(";"); + var address:Address = new Address(); + for (var j:uint = 0; j < addressTokens.length; ++j) + { + var addressToken:String = addressTokens[j]; + if (addressToken.search(/^home:+$/i) != -1) // For Outlook, which uses non-standard vCards. + { + address.type = "home"; + } + else if (addressToken.search(/^work:+$/i) != -1) // For Outlook, which uses non-standard vCards. + { + address.type = "work"; + } + if (addressToken.search(/^type=/i) != -1) // The "type" parameter is the standard way (which Address Book uses) + { + // First, remove the optional ":" character. + addressToken = addressToken.replace(/:/,""); + var addressType:String = addressToken.substring(5, addressToken.length).toLowerCase(); + if (addressType == "pref") // Not interested in which one is preferred. + { + continue; + } + else if (addressType.indexOf("home") != -1) // home + { + addressType = "home"; + } + else if (addressType.indexOf("work") != -1) // work + { + addressType = "work"; + } + else if (addressType.indexOf(",") != -1) // if the comma technique is used, just use the first one + { + var typeTokens:Array = addressType.split(","); + for each (var typeToken:String in typeTokens) + { + if (typeToken != "pref") + { + addressType = typeToken; + break; + } + } + } + address.type = addressType; + } + else if (addressToken.search(/^\d/) != -1 && address.street == null) + { + address.street = addressToken.replace(/\\n/, ""); + address.city = addressTokens[j+1]; + address.state = addressTokens[j+2]; + address.postalCode = addressTokens[j+3]; + } + } + if (address.type != null && address.street != null) + { + vcard.addresses.push(address); + } + + } + else if (line.search(/^PHOTO;BASE64/i) != -1) + { + var imageStr:String = new String(); + for (var k:uint = i+1; k < lines.length; ++k) + { + imageStr += lines[k]; + //if (lines[k].search(/.+\=$/) != -1) // Very slow in Mac due to RegEx bug + if (lines[k].indexOf('=') != -1) + { + var decoder:Base64Decoder = new Base64Decoder(); + decoder.decode(imageStr); + vcard.image = decoder.flush(); + break; + } + } + } + } + return vcards; + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/images/BitString.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/images/BitString.as new file mode 100644 index 0000000000000000000000000000000000000000..5d89c93bb146439253f9a86b4a5f422c5dd7b799 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/images/BitString.as @@ -0,0 +1,42 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +package com.adobe.images +{ + public class BitString + { + public var len:int = 0; + public var val:int = 0; + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/images/JPGEncoder.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/images/JPGEncoder.as new file mode 100644 index 0000000000000000000000000000000000000000..16799766371ac9b161cf7d34169aa5377003385e --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/images/JPGEncoder.as @@ -0,0 +1,651 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +package com.adobe.images +{ + import flash.geom.*; + import flash.display.*; + import flash.utils.*; + + /** + * Class that converts BitmapData into a valid JPEG + */ + public class JPGEncoder + { + + // Static table initialization + + private var ZigZag:Array = [ + 0, 1, 5, 6,14,15,27,28, + 2, 4, 7,13,16,26,29,42, + 3, 8,12,17,25,30,41,43, + 9,11,18,24,31,40,44,53, + 10,19,23,32,39,45,52,54, + 20,22,33,38,46,51,55,60, + 21,34,37,47,50,56,59,61, + 35,36,48,49,57,58,62,63 + ]; + + private var YTable:Array = new Array(64); + private var UVTable:Array = new Array(64); + private var fdtbl_Y:Array = new Array(64); + private var fdtbl_UV:Array = new Array(64); + + private function initQuantTables(sf:int):void + { + var i:int; + var t:Number; + var YQT:Array = [ + 16, 11, 10, 16, 24, 40, 51, 61, + 12, 12, 14, 19, 26, 58, 60, 55, + 14, 13, 16, 24, 40, 57, 69, 56, + 14, 17, 22, 29, 51, 87, 80, 62, + 18, 22, 37, 56, 68,109,103, 77, + 24, 35, 55, 64, 81,104,113, 92, + 49, 64, 78, 87,103,121,120,101, + 72, 92, 95, 98,112,100,103, 99 + ]; + for (i = 0; i < 64; i++) { + t = Math.floor((YQT[i]*sf+50)/100); + if (t < 1) { + t = 1; + } else if (t > 255) { + t = 255; + } + YTable[ZigZag[i]] = t; + } + var UVQT:Array = [ + 17, 18, 24, 47, 99, 99, 99, 99, + 18, 21, 26, 66, 99, 99, 99, 99, + 24, 26, 56, 99, 99, 99, 99, 99, + 47, 66, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99 + ]; + for (i = 0; i < 64; i++) { + t = Math.floor((UVQT[i]*sf+50)/100); + if (t < 1) { + t = 1; + } else if (t > 255) { + t = 255; + } + UVTable[ZigZag[i]] = t; + } + var aasf:Array = [ + 1.0, 1.387039845, 1.306562965, 1.175875602, + 1.0, 0.785694958, 0.541196100, 0.275899379 + ]; + i = 0; + for (var row:int = 0; row < 8; row++) + { + for (var col:int = 0; col < 8; col++) + { + fdtbl_Y[i] = (1.0 / (YTable [ZigZag[i]] * aasf[row] * aasf[col] * 8.0)); + fdtbl_UV[i] = (1.0 / (UVTable[ZigZag[i]] * aasf[row] * aasf[col] * 8.0)); + i++; + } + } + } + + private var YDC_HT:Array; + private var UVDC_HT:Array; + private var YAC_HT:Array; + private var UVAC_HT:Array; + + private function computeHuffmanTbl(nrcodes:Array, std_table:Array):Array + { + var codevalue:int = 0; + var pos_in_table:int = 0; + var HT:Array = new Array(); + for (var k:int=1; k<=16; k++) { + for (var j:int=1; j<=nrcodes[k]; j++) { + HT[std_table[pos_in_table]] = new BitString(); + HT[std_table[pos_in_table]].val = codevalue; + HT[std_table[pos_in_table]].len = k; + pos_in_table++; + codevalue++; + } + codevalue*=2; + } + return HT; + } + + private var std_dc_luminance_nrcodes:Array = [0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0]; + private var std_dc_luminance_values:Array = [0,1,2,3,4,5,6,7,8,9,10,11]; + private var std_ac_luminance_nrcodes:Array = [0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d]; + private var std_ac_luminance_values:Array = [ + 0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12, + 0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07, + 0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08, + 0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0, + 0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16, + 0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28, + 0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39, + 0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49, + 0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59, + 0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69, + 0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79, + 0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89, + 0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98, + 0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7, + 0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6, + 0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5, + 0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4, + 0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2, + 0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea, + 0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8, + 0xf9,0xfa + ]; + + private var std_dc_chrominance_nrcodes:Array = [0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0]; + private var std_dc_chrominance_values:Array = [0,1,2,3,4,5,6,7,8,9,10,11]; + private var std_ac_chrominance_nrcodes:Array = [0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77]; + private var std_ac_chrominance_values:Array = [ + 0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21, + 0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71, + 0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91, + 0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0, + 0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34, + 0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26, + 0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38, + 0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48, + 0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58, + 0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68, + 0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78, + 0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87, + 0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96, + 0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5, + 0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4, + 0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3, + 0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2, + 0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda, + 0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9, + 0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8, + 0xf9,0xfa + ]; + + private function initHuffmanTbl():void + { + YDC_HT = computeHuffmanTbl(std_dc_luminance_nrcodes,std_dc_luminance_values); + UVDC_HT = computeHuffmanTbl(std_dc_chrominance_nrcodes,std_dc_chrominance_values); + YAC_HT = computeHuffmanTbl(std_ac_luminance_nrcodes,std_ac_luminance_values); + UVAC_HT = computeHuffmanTbl(std_ac_chrominance_nrcodes,std_ac_chrominance_values); + } + + private var bitcode:Array = new Array(65535); + private var category:Array = new Array(65535); + + private function initCategoryNumber():void + { + var nrlower:int = 1; + var nrupper:int = 2; + var nr:int; + for (var cat:int=1; cat<=15; cat++) { + //Positive numbers + for (nr=nrlower; nr<nrupper; nr++) { + category[32767+nr] = cat; + bitcode[32767+nr] = new BitString(); + bitcode[32767+nr].len = cat; + bitcode[32767+nr].val = nr; + } + //Negative numbers + for (nr=-(nrupper-1); nr<=-nrlower; nr++) { + category[32767+nr] = cat; + bitcode[32767+nr] = new BitString(); + bitcode[32767+nr].len = cat; + bitcode[32767+nr].val = nrupper-1+nr; + } + nrlower <<= 1; + nrupper <<= 1; + } + } + + // IO functions + + private var byteout:ByteArray; + private var bytenew:int = 0; + private var bytepos:int = 7; + + private function writeBits(bs:BitString):void + { + var value:int = bs.val; + var posval:int = bs.len-1; + while ( posval >= 0 ) { + if (value & uint(1 << posval) ) { + bytenew |= uint(1 << bytepos); + } + posval--; + bytepos--; + if (bytepos < 0) { + if (bytenew == 0xFF) { + writeByte(0xFF); + writeByte(0); + } + else { + writeByte(bytenew); + } + bytepos=7; + bytenew=0; + } + } + } + + private function writeByte(value:int):void + { + byteout.writeByte(value); + } + + private function writeWord(value:int):void + { + writeByte((value>>8)&0xFF); + writeByte((value )&0xFF); + } + + // DCT & quantization core + + private function fDCTQuant(data:Array, fdtbl:Array):Array + { + var tmp0:Number, tmp1:Number, tmp2:Number, tmp3:Number, tmp4:Number, tmp5:Number, tmp6:Number, tmp7:Number; + var tmp10:Number, tmp11:Number, tmp12:Number, tmp13:Number; + var z1:Number, z2:Number, z3:Number, z4:Number, z5:Number, z11:Number, z13:Number; + var i:int; + /* Pass 1: process rows. */ + var dataOff:int=0; + for (i=0; i<8; i++) { + tmp0 = data[dataOff+0] + data[dataOff+7]; + tmp7 = data[dataOff+0] - data[dataOff+7]; + tmp1 = data[dataOff+1] + data[dataOff+6]; + tmp6 = data[dataOff+1] - data[dataOff+6]; + tmp2 = data[dataOff+2] + data[dataOff+5]; + tmp5 = data[dataOff+2] - data[dataOff+5]; + tmp3 = data[dataOff+3] + data[dataOff+4]; + tmp4 = data[dataOff+3] - data[dataOff+4]; + + /* Even part */ + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + data[dataOff+0] = tmp10 + tmp11; /* phase 3 */ + data[dataOff+4] = tmp10 - tmp11; + + z1 = (tmp12 + tmp13) * 0.707106781; /* c4 */ + data[dataOff+2] = tmp13 + z1; /* phase 5 */ + data[dataOff+6] = tmp13 - z1; + + /* Odd part */ + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = (tmp10 - tmp12) * 0.382683433; /* c6 */ + z2 = 0.541196100 * tmp10 + z5; /* c2-c6 */ + z4 = 1.306562965 * tmp12 + z5; /* c2+c6 */ + z3 = tmp11 * 0.707106781; /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + data[dataOff+5] = z13 + z2; /* phase 6 */ + data[dataOff+3] = z13 - z2; + data[dataOff+1] = z11 + z4; + data[dataOff+7] = z11 - z4; + + dataOff += 8; /* advance pointer to next row */ + } + + /* Pass 2: process columns. */ + dataOff = 0; + for (i=0; i<8; i++) { + tmp0 = data[dataOff+ 0] + data[dataOff+56]; + tmp7 = data[dataOff+ 0] - data[dataOff+56]; + tmp1 = data[dataOff+ 8] + data[dataOff+48]; + tmp6 = data[dataOff+ 8] - data[dataOff+48]; + tmp2 = data[dataOff+16] + data[dataOff+40]; + tmp5 = data[dataOff+16] - data[dataOff+40]; + tmp3 = data[dataOff+24] + data[dataOff+32]; + tmp4 = data[dataOff+24] - data[dataOff+32]; + + /* Even part */ + tmp10 = tmp0 + tmp3; /* phase 2 */ + tmp13 = tmp0 - tmp3; + tmp11 = tmp1 + tmp2; + tmp12 = tmp1 - tmp2; + + data[dataOff+ 0] = tmp10 + tmp11; /* phase 3 */ + data[dataOff+32] = tmp10 - tmp11; + + z1 = (tmp12 + tmp13) * 0.707106781; /* c4 */ + data[dataOff+16] = tmp13 + z1; /* phase 5 */ + data[dataOff+48] = tmp13 - z1; + + /* Odd part */ + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + z5 = (tmp10 - tmp12) * 0.382683433; /* c6 */ + z2 = 0.541196100 * tmp10 + z5; /* c2-c6 */ + z4 = 1.306562965 * tmp12 + z5; /* c2+c6 */ + z3 = tmp11 * 0.707106781; /* c4 */ + + z11 = tmp7 + z3; /* phase 5 */ + z13 = tmp7 - z3; + + data[dataOff+40] = z13 + z2; /* phase 6 */ + data[dataOff+24] = z13 - z2; + data[dataOff+ 8] = z11 + z4; + data[dataOff+56] = z11 - z4; + + dataOff++; /* advance pointer to next column */ + } + + // Quantize/descale the coefficients + for (i=0; i<64; i++) { + // Apply the quantization and scaling factor & Round to nearest integer + data[i] = Math.round((data[i]*fdtbl[i])); + } + return data; + } + + // Chunk writing + + private function writeAPP0():void + { + writeWord(0xFFE0); // marker + writeWord(16); // length + writeByte(0x4A); // J + writeByte(0x46); // F + writeByte(0x49); // I + writeByte(0x46); // F + writeByte(0); // = "JFIF",'\0' + writeByte(1); // versionhi + writeByte(1); // versionlo + writeByte(0); // xyunits + writeWord(1); // xdensity + writeWord(1); // ydensity + writeByte(0); // thumbnwidth + writeByte(0); // thumbnheight + } + + private function writeSOF0(width:int, height:int):void + { + writeWord(0xFFC0); // marker + writeWord(17); // length, truecolor YUV JPG + writeByte(8); // precision + writeWord(height); + writeWord(width); + writeByte(3); // nrofcomponents + writeByte(1); // IdY + writeByte(0x11); // HVY + writeByte(0); // QTY + writeByte(2); // IdU + writeByte(0x11); // HVU + writeByte(1); // QTU + writeByte(3); // IdV + writeByte(0x11); // HVV + writeByte(1); // QTV + } + + private function writeDQT():void + { + writeWord(0xFFDB); // marker + writeWord(132); // length + writeByte(0); + var i:int; + for (i=0; i<64; i++) { + writeByte(YTable[i]); + } + writeByte(1); + for (i=0; i<64; i++) { + writeByte(UVTable[i]); + } + } + + private function writeDHT():void + { + writeWord(0xFFC4); // marker + writeWord(0x01A2); // length + var i:int; + + writeByte(0); // HTYDCinfo + for (i=0; i<16; i++) { + writeByte(std_dc_luminance_nrcodes[i+1]); + } + for (i=0; i<=11; i++) { + writeByte(std_dc_luminance_values[i]); + } + + writeByte(0x10); // HTYACinfo + for (i=0; i<16; i++) { + writeByte(std_ac_luminance_nrcodes[i+1]); + } + for (i=0; i<=161; i++) { + writeByte(std_ac_luminance_values[i]); + } + + writeByte(1); // HTUDCinfo + for (i=0; i<16; i++) { + writeByte(std_dc_chrominance_nrcodes[i+1]); + } + for (i=0; i<=11; i++) { + writeByte(std_dc_chrominance_values[i]); + } + + writeByte(0x11); // HTUACinfo + for (i=0; i<16; i++) { + writeByte(std_ac_chrominance_nrcodes[i+1]); + } + for (i=0; i<=161; i++) { + writeByte(std_ac_chrominance_values[i]); + } + } + + private function writeSOS():void + { + writeWord(0xFFDA); // marker + writeWord(12); // length + writeByte(3); // nrofcomponents + writeByte(1); // IdY + writeByte(0); // HTY + writeByte(2); // IdU + writeByte(0x11); // HTU + writeByte(3); // IdV + writeByte(0x11); // HTV + writeByte(0); // Ss + writeByte(0x3f); // Se + writeByte(0); // Bf + } + + // Core processing + private var DU:Array = new Array(64); + + private function processDU(CDU:Array, fdtbl:Array, DC:Number, HTDC:Array, HTAC:Array):Number + { + var EOB:BitString = HTAC[0x00]; + var M16zeroes:BitString = HTAC[0xF0]; + var i:int; + + var DU_DCT:Array = fDCTQuant(CDU, fdtbl); + //ZigZag reorder + for (i=0;i<64;i++) { + DU[ZigZag[i]]=DU_DCT[i]; + } + var Diff:int = DU[0] - DC; DC = DU[0]; + //Encode DC + if (Diff==0) { + writeBits(HTDC[0]); // Diff might be 0 + } else { + writeBits(HTDC[category[32767+Diff]]); + writeBits(bitcode[32767+Diff]); + } + //Encode ACs + var end0pos:int = 63; + for (; (end0pos>0)&&(DU[end0pos]==0); end0pos--) { + }; + //end0pos = first element in reverse order !=0 + if ( end0pos == 0) { + writeBits(EOB); + return DC; + } + i = 1; + while ( i <= end0pos ) { + var startpos:int = i; + for (; (DU[i]==0) && (i<=end0pos); i++) { + } + var nrzeroes:int = i-startpos; + if ( nrzeroes >= 16 ) { + for (var nrmarker:int=1; nrmarker <= nrzeroes/16; nrmarker++) { + writeBits(M16zeroes); + } + nrzeroes = int(nrzeroes&0xF); + } + writeBits(HTAC[nrzeroes*16+category[32767+DU[i]]]); + writeBits(bitcode[32767+DU[i]]); + i++; + } + if ( end0pos != 63 ) { + writeBits(EOB); + } + return DC; + } + + private var YDU:Array = new Array(64); + private var UDU:Array = new Array(64); + private var VDU:Array = new Array(64); + + private function RGB2YUV(img:BitmapData, xpos:int, ypos:int):void + { + var pos:int=0; + for (var y:int=0; y<8; y++) { + for (var x:int=0; x<8; x++) { + var P:uint = img.getPixel32(xpos+x,ypos+y); + var R:Number = Number((P>>16)&0xFF); + var G:Number = Number((P>> 8)&0xFF); + var B:Number = Number((P )&0xFF); + YDU[pos]=((( 0.29900)*R+( 0.58700)*G+( 0.11400)*B))-128; + UDU[pos]=(((-0.16874)*R+(-0.33126)*G+( 0.50000)*B)); + VDU[pos]=((( 0.50000)*R+(-0.41869)*G+(-0.08131)*B)); + pos++; + } + } + } + + /** + * Constructor for JPEGEncoder class + * + * @param quality The quality level between 1 and 100 that detrmines the + * level of compression used in the generated JPEG + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public function JPGEncoder(quality:Number = 50) + { + if (quality <= 0) { + quality = 1; + } + if (quality > 100) { + quality = 100; + } + var sf:int = 0; + if (quality < 50) { + sf = int(5000 / quality); + } else { + sf = int(200 - quality*2); + } + // Create tables + initHuffmanTbl(); + initCategoryNumber(); + initQuantTables(sf); + } + + /** + * Created a JPEG image from the specified BitmapData + * + * @param image The BitmapData that will be converted into the JPEG format. + * @return a ByteArray representing the JPEG encoded image data. + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public function encode(image:BitmapData):ByteArray + { + // Initialize bit writer + byteout = new ByteArray(); + bytenew=0; + bytepos=7; + + // Add JPEG headers + writeWord(0xFFD8); // SOI + writeAPP0(); + writeDQT(); + writeSOF0(image.width,image.height); + writeDHT(); + writeSOS(); + + + // Encode 8x8 macroblocks + var DCY:Number=0; + var DCU:Number=0; + var DCV:Number=0; + bytenew=0; + bytepos=7; + for (var ypos:int=0; ypos<image.height; ypos+=8) { + for (var xpos:int=0; xpos<image.width; xpos+=8) { + RGB2YUV(image, xpos, ypos); + DCY = processDU(YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT); + DCU = processDU(UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); + DCV = processDU(VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); + } + } + + // Do the bit alignment of the EOI marker + if ( bytepos >= 0 ) { + var fillbits:BitString = new BitString(); + fillbits.len = bytepos+1; + fillbits.val = (1<<(bytepos+1))-1; + writeBits(fillbits); + } + + writeWord(0xFFD9); //EOI + return byteout; + } + } +} diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/images/PNGEncoder.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/images/PNGEncoder.as new file mode 100644 index 0000000000000000000000000000000000000000..bb864446b007c81c99402af3ac22935eaa47c11b --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/images/PNGEncoder.as @@ -0,0 +1,144 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +package com.adobe.images +{ + import flash.geom.*; + import flash.display.Bitmap; + import flash.display.BitmapData; + import flash.utils.ByteArray; + + /** + * Class that converts BitmapData into a valid PNG + */ + public class PNGEncoder + { + /** + * Created a PNG image from the specified BitmapData + * + * @param image The BitmapData that will be converted into the PNG format. + * @return a ByteArray representing the PNG encoded image data. + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function encode(img:BitmapData):ByteArray { + // Create output byte array + var png:ByteArray = new ByteArray(); + // Write PNG signature + png.writeUnsignedInt(0x89504e47); + png.writeUnsignedInt(0x0D0A1A0A); + // Build IHDR chunk + var IHDR:ByteArray = new ByteArray(); + IHDR.writeInt(img.width); + IHDR.writeInt(img.height); + IHDR.writeUnsignedInt(0x08060000); // 32bit RGBA + IHDR.writeByte(0); + writeChunk(png,0x49484452,IHDR); + // Build IDAT chunk + var IDAT:ByteArray= new ByteArray(); + for(var i:int=0;i < img.height;i++) { + // no filter + IDAT.writeByte(0); + var p:uint; + var j:int; + if ( !img.transparent ) { + for(j=0;j < img.width;j++) { + p = img.getPixel(j,i); + IDAT.writeUnsignedInt( + uint(((p&0xFFFFFF) << 8)|0xFF)); + } + } else { + for(j=0;j < img.width;j++) { + p = img.getPixel32(j,i); + IDAT.writeUnsignedInt( + uint(((p&0xFFFFFF) << 8)| + (p>>>24))); + } + } + } + IDAT.compress(); + writeChunk(png,0x49444154,IDAT); + // Build IEND chunk + writeChunk(png,0x49454E44,null); + // return PNG + return png; + } + + private static var crcTable:Array; + private static var crcTableComputed:Boolean = false; + + private static function writeChunk(png:ByteArray, + type:uint, data:ByteArray):void { + if (!crcTableComputed) { + crcTableComputed = true; + crcTable = []; + var c:uint; + for (var n:uint = 0; n < 256; n++) { + c = n; + for (var k:uint = 0; k < 8; k++) { + if (c & 1) { + c = uint(uint(0xedb88320) ^ + uint(c >>> 1)); + } else { + c = uint(c >>> 1); + } + } + crcTable[n] = c; + } + } + var len:uint = 0; + if (data != null) { + len = data.length; + } + png.writeUnsignedInt(len); + var p:uint = png.position; + png.writeUnsignedInt(type); + if ( data != null ) { + png.writeBytes(data); + } + var e:uint = png.position; + png.position = p; + c = 0xffffffff; + for (var i:int = 0; i < (e-p); i++) { + c = uint(crcTable[ + (c ^ png.readUnsignedByte()) & + uint(0xff)] ^ uint(c >>> 8)); + } + c = uint(c^uint(0xffffffff)); + png.position = e; + png.writeUnsignedInt(c); + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/DynamicURLLoader.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/DynamicURLLoader.as new file mode 100644 index 0000000000000000000000000000000000000000..9b16a610699cc7a4e5f5c7785a0b24f03e0c02e0 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/DynamicURLLoader.as @@ -0,0 +1,58 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.net +{ + import flash.net.URLLoader; + + /** + * Class that provides a dynamic implimentation of the URLLoader class. + * + * This class provides no API implimentations. However, since the class is + * declared as dynamic, it can be used in place of URLLoader, and allow + * you to dynamically attach properties to it (which URLLoader does not allow). + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public dynamic class DynamicURLLoader extends URLLoader + { + public function DynamicURLLoader() + { + super(); + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/IURIResolver.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/IURIResolver.as new file mode 100644 index 0000000000000000000000000000000000000000..658a95abfa0048b8d3d57cab71a4e390e77c8e7c --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/IURIResolver.as @@ -0,0 +1,79 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.net +{ + /** + * The URI class cannot know about DNS aliases, virtual hosts, or + * symbolic links that may be involved. The application can provide + * an implementation of this interface to resolve the URI before the + * URI class makes any comparisons. For example, a web host has + * two aliases: + * + * <p><code> + * http://www.site.com/ + * http://www.site.net/ + * </code></p> + * + * <p>The application can provide an implementation that automatically + * resolves site.net to site.com before URI compares two URI objects. + * Only the application can know and understand the context in which + * the URI's are being used.</p> + * + * <p>Use the URI.resolver accessor to assign a custom resolver to + * the URI class. Any resolver specified is global to all instances + * of URI.</p> + * + * <p>URI will call this before performing URI comparisons in the + * URI.getRelation() and URI.getCommonParent() functions. + * + * @see URI.getRelation + * @see URI.getCommonParent + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + */ + public interface IURIResolver + { + /** + * Implement this method to provide custom URI resolution for + * your application. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + */ + function resolve(uri:URI) : URI; + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/MimeTypeMap.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/MimeTypeMap.as new file mode 100644 index 0000000000000000000000000000000000000000..b788b6c6e1c729d2c72b09421d4bb5f39b783438 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/MimeTypeMap.as @@ -0,0 +1,193 @@ +/* +Copyright (c) 1998 - 2002, Paul Johnston & Contributors +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. Redistributions in binary +form must reproduce the above copyright notice, this list of conditions and the +following disclaimer in the documentation and/or other materials provided with +the distribution. + +Neither the name of the author nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior +written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +package com.adobe.net +{ + public class MimeTypeMap + { + private var types:Array = + [["application/andrew-inset","ez"], + ["application/atom+xml","atom"], + ["application/mac-binhex40","hqx"], + ["application/mac-compactpro","cpt"], + ["application/mathml+xml","mathml"], + ["application/msword","doc"], + ["application/octet-stream","bin","dms","lha","lzh","exe","class","so","dll","dmg"], + ["application/oda","oda"], + ["application/ogg","ogg"], + ["application/pdf","pdf"], + ["application/postscript","ai","eps","ps"], + ["application/rdf+xml","rdf"], + ["application/smil","smi","smil"], + ["application/srgs","gram"], + ["application/srgs+xml","grxml"], + ["application/vnd.adobe.apollo-application-installer-package+zip","air"], + ["application/vnd.mif","mif"], + ["application/vnd.mozilla.xul+xml","xul"], + ["application/vnd.ms-excel","xls"], + ["application/vnd.ms-powerpoint","ppt"], + ["application/vnd.rn-realmedia","rm"], + ["application/vnd.wap.wbxml","wbxml"], + ["application/vnd.wap.wmlc","wmlc"], + ["application/vnd.wap.wmlscriptc","wmlsc"], + ["application/voicexml+xml","vxml"], + ["application/x-bcpio","bcpio"], + ["application/x-cdlink","vcd"], + ["application/x-chess-pgn","pgn"], + ["application/x-cpio","cpio"], + ["application/x-csh","csh"], + ["application/x-director","dcr","dir","dxr"], + ["application/x-dvi","dvi"], + ["application/x-futuresplash","spl"], + ["application/x-gtar","gtar"], + ["application/x-hdf","hdf"], + ["application/x-javascript","js"], + ["application/x-koan","skp","skd","skt","skm"], + ["application/x-latex","latex"], + ["application/x-netcdf","nc","cdf"], + ["application/x-sh","sh"], + ["application/x-shar","shar"], + ["application/x-shockwave-flash","swf"], + ["application/x-stuffit","sit"], + ["application/x-sv4cpio","sv4cpio"], + ["application/x-sv4crc","sv4crc"], + ["application/x-tar","tar"], + ["application/x-tcl","tcl"], + ["application/x-tex","tex"], + ["application/x-texinfo","texinfo","texi"], + ["application/x-troff","t","tr","roff"], + ["application/x-troff-man","man"], + ["application/x-troff-me","me"], + ["application/x-troff-ms","ms"], + ["application/x-ustar","ustar"], + ["application/x-wais-source","src"], + ["application/xhtml+xml","xhtml","xht"], + ["application/xml","xml","xsl"], + ["application/xml-dtd","dtd"], + ["application/xslt+xml","xslt"], + ["application/zip","zip"], + ["audio/basic","au","snd"], + ["audio/midi","mid","midi","kar"], + ["audio/mpeg","mp3","mpga","mp2"], + ["audio/x-aiff","aif","aiff","aifc"], + ["audio/x-mpegurl","m3u"], + ["audio/x-pn-realaudio","ram","ra"], + ["audio/x-wav","wav"], + ["chemical/x-pdb","pdb"], + ["chemical/x-xyz","xyz"], + ["image/bmp","bmp"], + ["image/cgm","cgm"], + ["image/gif","gif"], + ["image/ief","ief"], + ["image/jpeg","jpg","jpeg","jpe"], + ["image/png","png"], + ["image/svg+xml","svg"], + ["image/tiff","tiff","tif"], + ["image/vnd.djvu","djvu","djv"], + ["image/vnd.wap.wbmp","wbmp"], + ["image/x-cmu-raster","ras"], + ["image/x-icon","ico"], + ["image/x-portable-anymap","pnm"], + ["image/x-portable-bitmap","pbm"], + ["image/x-portable-graymap","pgm"], + ["image/x-portable-pixmap","ppm"], + ["image/x-rgb","rgb"], + ["image/x-xbitmap","xbm"], + ["image/x-xpixmap","xpm"], + ["image/x-xwindowdump","xwd"], + ["model/iges","igs","iges"], + ["model/mesh","msh","mesh","silo"], + ["model/vrml","wrl","vrml"], + ["text/calendar","ics","ifb"], + ["text/css","css"], + ["text/html","html","htm"], + ["text/plain","txt","asc"], + ["text/richtext","rtx"], + ["text/rtf","rtf"], + ["text/sgml","sgml","sgm"], + ["text/tab-separated-values","tsv"], + ["text/vnd.wap.wml","wml"], + ["text/vnd.wap.wmlscript","wmls"], + ["text/x-setext","etx"], + ["video/mpeg","mpg","mpeg","mpe"], + ["video/quicktime","mov","qt"], + ["video/vnd.mpegurl","m4u","mxu"], + ["video/x-flv","flv"], + ["video/x-msvideo","avi"], + ["video/x-sgi-movie","movie"], + ["x-conference/x-cooltalk","ice"]]; + + /** + * Returns the mimetype for the given extension. + */ + public function getMimeType(extension:String):String + { + extension = extension.toLocaleLowerCase(); + for each (var a:Array in types) + { + for each (var b:String in a) + { + if (b == extension) + { + return a[0]; + } + } + } + return null; + } + + /** + * Returns the prefered extension for the given mimetype. + */ + public function getExtension(mimetype:String):String + { + mimetype = mimetype.toLocaleLowerCase(); + for each (var a:Array in types) + { + if (a[0] == mimetype) + { + return a[1]; + } + } + return null; + } + + /** + * Adds a mimetype to the map. The order of the extensions matters. The most preferred should come first. + */ + public function addMimeType(mimetype:String, extensions:Array):void + { + var newType:Array = [mimetype]; + for each (var a:String in extensions) + { + newType.push(a); + } + types.push(newType); + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/URI.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/URI.as new file mode 100644 index 0000000000000000000000000000000000000000..b6e230ec0174b26231004ada314ccc06d6a155db --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/URI.as @@ -0,0 +1,2469 @@ +/* +Adobe Systems Incorporated(r) Source Code License Agreement +Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + +Please read this Source Code License Agreement carefully before using +the source code. + +Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable copyright license, to reproduce, +prepare derivative works of, publicly display, publicly perform, and +distribute this source code and such derivative works in source or +object code form without any attribution requirements. + +The name "Adobe Systems Incorporated" must not be used to endorse or promote products +derived from the source code without prior written permission. + +You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and +against any loss, damage, claims or lawsuits, including attorney's +fees that arise or result from your use or distribution of the source +code. + +THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT +ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF +NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA +OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.net +{ + import flash.utils.ByteArray; + + /** + * This class implements functions and utilities for working with URI's + * (Universal Resource Identifiers). For technical description of the + * URI syntax, please see RFC 3986 at http://www.ietf.org/rfc/rfc3986.txt + * or do a web search for "rfc 3986". + * + * <p>The most important aspect of URI's to understand is that URI's + * and URL's are not strings. URI's are complex data structures that + * encapsulate many pieces of information. The string version of a + * URI is the serialized representation of that data structure. This + * string serialization is used to provide a human readable + * representation and a means to transport the data over the network + * where it can then be parsed back into its' component parts.</p> + * + * <p>URI's fall into one of three categories: + * <ul> + * <li><scheme>:<scheme-specific-part>#<fragment> (non-hierarchical)</li> + * <li><scheme>:<authority><path>?<query>#<fragment> (hierarchical)</li> + * <li><path>?<query>#<fragment> (relative hierarchical)</li> + * </ul></p> + * + * <p>The query and fragment parts are optional.</p> + * + * <p>This class supports both non-hierarchical and hierarchical URI's</p> + * + * <p>This class is intended to be used "as-is" for the vast majority + * of common URI's. However, if your application requires a custom + * URI syntax (e.g. custom query syntax or special handling of + * non-hierarchical URI's), this class can be fully subclassed. If you + * intended to subclass URI, please see the source code for complete + * documation on protected members and protected fuctions.</p> + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + */ + public class URI + { + // Here we define which characters must be escaped for each + // URI part. The characters that must be escaped for each + // part differ depending on what would cause ambiguous parsing. + // RFC 3986 sec. 2.4 states that characters should only be + // encoded when they would conflict with subcomponent delimiters. + // We don't want to over-do the escaping. We only want to escape + // the minimum needed to prevent parsing problems. + + // space and % must be escaped in all cases. '%' is the delimiter + // for escaped characters. + public static const URImustEscape:String = " %"; + + // Baseline of what characters must be escaped + public static const URIbaselineEscape:String = URImustEscape + ":?#/@"; + + // Characters that must be escaped in the part part. + public static const URIpathEscape:String = URImustEscape + "?#"; + + // Characters that must be escaped in the query part, if setting + // the query as a whole string. If the query is set by + // name/value, URIqueryPartEscape is used instead. + public static const URIqueryEscape:String = URImustEscape + "#"; + + // This is what each name/value pair must escape "&=" as well + // so they don't conflict with the "param=value¶m2=value2" + // syntax. + public static const URIqueryPartEscape:String = URImustEscape + "#&="; + + // Non-hierarchical URI's can have query and fragment parts, but + // we also want to prevent '/' otherwise it might end up looking + // like a hierarchical URI to the parser. + public static const URInonHierEscape:String = URImustEscape + "?#/"; + + // Baseline uninitialized setting for the URI scheme. + public static const UNKNOWN_SCHEME:String = "unknown"; + + // The following bitmaps are used for performance enhanced + // character escaping. + + // Baseline characters that need to be escaped. Many parts use + // this. + protected static const URIbaselineExcludedBitmap:URIEncodingBitmap = + new URIEncodingBitmap(URIbaselineEscape); + + // Scheme escaping bitmap + protected static const URIschemeExcludedBitmap:URIEncodingBitmap = + URIbaselineExcludedBitmap; + + // User/pass escaping bitmap + protected static const URIuserpassExcludedBitmap:URIEncodingBitmap = + URIbaselineExcludedBitmap; + + // Authority escaping bitmap + protected static const URIauthorityExcludedBitmap:URIEncodingBitmap = + URIbaselineExcludedBitmap; + + // Port escaping bitmap + protected static const URIportExludedBitmap:URIEncodingBitmap = + URIbaselineExcludedBitmap; + + // Path escaping bitmap + protected static const URIpathExcludedBitmap:URIEncodingBitmap = + new URIEncodingBitmap(URIpathEscape); + + // Query (whole) escaping bitmap + protected static const URIqueryExcludedBitmap:URIEncodingBitmap = + new URIEncodingBitmap(URIqueryEscape); + + // Query (individual parts) escaping bitmap + protected static const URIqueryPartExcludedBitmap:URIEncodingBitmap = + new URIEncodingBitmap(URIqueryPartEscape); + + // Fragments are the last part in the URI. They only need to + // escape space, '#', and '%'. Turns out that is what query + // uses too. + protected static const URIfragmentExcludedBitmap:URIEncodingBitmap = + URIqueryExcludedBitmap; + + // Characters that need to be escaped in the non-hierarchical part + protected static const URInonHierexcludedBitmap:URIEncodingBitmap = + new URIEncodingBitmap(URInonHierEscape); + + // Values used by getRelation() + public static const NOT_RELATED:int = 0; + public static const CHILD:int = 1; + public static const EQUAL:int = 2; + public static const PARENT:int = 3; + + //------------------------------------------------------------------- + // protected class members + //------------------------------------------------------------------- + protected var _valid:Boolean = false; + protected var _relative:Boolean = false; + protected var _scheme:String = ""; + protected var _authority:String = ""; + protected var _username:String = ""; + protected var _password:String = ""; + protected var _port:String = ""; + protected var _path:String = ""; + protected var _query:String = ""; + protected var _fragment:String = ""; + protected var _nonHierarchical:String = ""; + protected static var _resolver:IURIResolver = null; + + + /** + * URI Constructor. If no string is given, this will initialize + * this URI object to a blank URI. + */ + public function URI(uri:String = null) : void + { + if (uri == null) + initialize(); + else + constructURI(uri); + } + + + /** + * @private + * Method that loads the URI from the given string. + */ + protected function constructURI(uri:String) : Boolean + { + if (!parseURI(uri)) + _valid = false; + + return isValid(); + } + + + /** + * @private Private initializiation. + */ + protected function initialize() : void + { + _valid = false; + _relative = false; + + _scheme = UNKNOWN_SCHEME; + _authority = ""; + _username = ""; + _password = ""; + _port = ""; + _path = ""; + _query = ""; + _fragment = ""; + + _nonHierarchical = ""; + } + + /** + * @private Accessor to explicitly set/get the hierarchical + * state of the URI. + */ + protected function set hierState(state:Boolean) : void + { + if (state) + { + // Clear the non-hierarchical data + _nonHierarchical = ""; + + // Also set the state vars while we are at it + if (_scheme == "" || _scheme == UNKNOWN_SCHEME) + _relative = true; + else + _relative = false; + + if (_authority.length == 0 && _path.length == 0) + _valid = false; + else + _valid = true; + } + else + { + // Clear the hierarchical data + _authority = ""; + _username = ""; + _password = ""; + _port = ""; + _path = ""; + + _relative = false; + + if (_scheme == "" || _scheme == UNKNOWN_SCHEME) + _valid = false; + else + _valid = true; + } + } + protected function get hierState() : Boolean + { + return (_nonHierarchical.length == 0); + } + + + /** + * @private Functions that performs some basic consistency validation. + */ + protected function validateURI() : Boolean + { + // Check the scheme + if (isAbsolute()) + { + if (_scheme.length <= 1 || _scheme == UNKNOWN_SCHEME) + { + // we probably parsed a C:\ type path or no scheme + return false; + } + else if (verifyAlpha(_scheme) == false) + return false; // Scheme contains bad characters + } + + if (hierState) + { + if (_path.search('\\') != -1) + return false; // local path + else if (isRelative() == false && _scheme == UNKNOWN_SCHEME) + return false; // It's an absolute URI, but it has a bad scheme + } + else + { + if (_nonHierarchical.search('\\') != -1) + return false; // some kind of local path + } + + // Looks like it's ok. + return true; + } + + + /** + * @private + * + * Given a URI in string format, parse that sucker into its basic + * components and assign them to this object. A URI is of the form: + * <scheme>:<authority><path>?<query>#<fragment> + * + * For simplicity, we parse the URI in the following order: + * + * 1. Fragment (anchors) + * 2. Query (CGI stuff) + * 3. Scheme ("http") + * 4. Authority (host name) + * 5. Username/Password (if any) + * 6. Port (server port if any) + * 7. Path (/homepages/mypage.html) + * + * The reason for this order is to minimize any parsing ambiguities. + * Fragments and queries can contain almost anything (they are parts + * that can contain custom data with their own syntax). Parsing + * them out first removes a large chance of parsing errors. This + * method expects well formed URI's, but performing the parse in + * this order makes us a little more tolerant of user error. + * + * REGEXP + * Why doesn't this use regular expressions to parse the URI? We + * have found that in a real world scenario, URI's are not always + * well formed. Sometimes characters that should have been escaped + * are not, and those situations would break a regexp pattern. This + * function attempts to be smart about what it is parsing based on + * location of characters relative to eachother. This function has + * been proven through real-world use to parse the vast majority + * of URI's correctly. + * + * NOTE + * It is assumed that the string in URI form is escaped. This function + * does not escape anything. If you constructed the URI string by + * hand, and used this to parse in the URI and still need it escaped, + * call forceEscape() on your URI object. + * + * Parsing Assumptions + * This routine assumes that the URI being passed is well formed. + * Passing things like local paths, malformed URI's, and the such + * will result in parsing errors. This function can handle + * - absolute hierarchical (e.g. "http://something.com/index.html), + * - relative hierarchical (e.g. "../images/flower.gif"), or + * - non-hierarchical URIs (e.g. "mailto:jsmith@fungoo.com"). + * + * Anything else will probably result in a parsing error, or a bogus + * URI object. + * + * Note that non-hierarchical URIs *MUST* have a scheme, otherwise + * they will be mistaken for relative URI's. + * + * If you are not sure what is being passed to you (like manually + * entered text from UI), you can construct a blank URI object and + * call unknownToURI() passing in the unknown string. + * + * @return true if successful, false if there was some kind of + * parsing error + */ + protected function parseURI(uri:String) : Boolean + { + var baseURI:String = uri; + var index:int, index2:int; + + // Make sure this object is clean before we start. If it was used + // before and we are now parsing a new URI, we don't want any stale + // info lying around. + initialize(); + + // Remove any fragments (anchors) from the URI + index = baseURI.indexOf("#"); + if (index != -1) + { + // Store the fragment piece if any + if (baseURI.length > (index + 1)) // +1 is to skip the '#' + _fragment = baseURI.substr(index + 1, baseURI.length - (index + 1)); + + // Trim off the fragment + baseURI = baseURI.substr(0, index); + } + + // We need to strip off any CGI parameters (eg '?param=bob') + index = baseURI.indexOf("?"); + if (index != -1) + { + if (baseURI.length > (index + 1)) + _query = baseURI.substr(index + 1, baseURI.length - (index + 1)); // +1 is to skip the '?' + + // Trim off the query + baseURI = baseURI.substr(0, index); + } + + // Now try to find the scheme part + index = baseURI.search(':'); + index2 = baseURI.search('/'); + + var containsColon:Boolean = (index != -1); + var containsSlash:Boolean = (index2 != -1); + + // This value is indeterminate if "containsColon" is false. + // (if there is no colon, does the slash come before or + // after said non-existing colon?) + var colonBeforeSlash:Boolean = (!containsSlash || index < index2); + + // If it has a colon and it's before the first slash, we will treat + // it as a scheme. If a slash is before a colon, there must be a + // stray colon in a path or something. In which case, the colon is + // not the separator for the scheme. Technically, we could consider + // this an error, but since this is not an ambiguous state (we know + // 100% that this has no scheme), we will keep going. + if (containsColon && colonBeforeSlash) + { + // We found a scheme + _scheme = baseURI.substr(0, index); + + // Normalize the scheme + _scheme = _scheme.toLowerCase(); + + baseURI = baseURI.substr(index + 1); + + if (baseURI.substr(0, 2) == "//") + { + // This is a hierarchical URI + _nonHierarchical = ""; + + // Trim off the "//" + baseURI = baseURI.substr(2, baseURI.length - 2); + } + else + { + // This is a non-hierarchical URI like "mailto:bob@mail.com" + _nonHierarchical = baseURI; + + if ((_valid = validateURI()) == false) + initialize(); // Bad URI. Clear it. + + // No more parsing to do for this case + return isValid(); + } + } + else + { + // No scheme. We will consider this a relative URI + _scheme = ""; + _relative = true; + _nonHierarchical = ""; + } + + // Ok, what we have left is everything after the <scheme>:// + + // Now that we have stripped off any query and fragment parts, we + // need to split the authority from the path + + if (isRelative()) + { + // Don't bother looking for the authority. It's a relative URI + _authority = ""; + _port = ""; + _path = baseURI; + } + else + { + // Check for malformed UNC style file://///server/type/path/ + // By the time we get here, we have already trimmed the "file://" + // so baseURI will be ///server/type/path. If baseURI only + // has one slash, we leave it alone because that is valid (that + // is the case of "file:///path/to/file.txt" where there is no + // server - implicit "localhost"). + if (baseURI.substr(0, 2) == "//") + { + // Trim all leading slashes + while(baseURI.charAt(0) == "/") + baseURI = baseURI.substr(1, baseURI.length - 1); + } + + index = baseURI.search('/'); + if (index == -1) + { + // No path. We must have passed something like "http://something.com" + _authority = baseURI; + _path = ""; + } + else + { + _authority = baseURI.substr(0, index); + _path = baseURI.substr(index, baseURI.length - index); + } + + // Check to see if the URI has any username or password information. + // For example: ftp://username:password@server.com + index = _authority.search('@'); + if (index != -1) + { + // We have a username and possibly a password + _username = _authority.substr(0, index); + + // Remove the username/password from the authority + _authority = _authority.substr(index + 1); // Skip the '@' + + // Now check to see if the username also has a password + index = _username.search(':'); + if (index != -1) + { + _password = _username.substring(index + 1, _username.length); + _username = _username.substr(0, index); + } + else + _password = ""; + } + else + { + _username = ""; + _password = ""; + } + + // Lastly, check to see if the authorty has a port number. + // This is parsed after the username/password to avoid conflicting + // with the ':' in the 'username:password' if one exists. + index = _authority.search(':'); + if (index != -1) + { + _port = _authority.substring(index + 1, _authority.length); // skip the ':' + _authority = _authority.substr(0, index); + } + else + { + _port = ""; + } + + // Lastly, normalize the authority. Domain names + // are case insensitive. + _authority = _authority.toLowerCase(); + } + + if ((_valid = validateURI()) == false) + initialize(); // Bad URI. Clear it + + return isValid(); + } + + + /******************************************************************** + * Copy function. + */ + public function copyURI(uri:URI) : void + { + this._scheme = uri._scheme; + this._authority = uri._authority; + this._username = uri._username; + this._password = uri._password; + this._port = uri._port; + this._path = uri._path; + this._query = uri._query; + this._fragment = uri._fragment; + this._nonHierarchical = uri._nonHierarchical; + + this._valid = uri._valid; + this._relative = uri._relative; + } + + + /** + * @private + * Checks if the given string only contains a-z or A-Z. + */ + protected function verifyAlpha(str:String) : Boolean + { + var pattern:RegExp = /[^a-z]/; + var index:int; + + str = str.toLowerCase(); + index = str.search(pattern); + + if (index == -1) + return true; + else + return false; + } + + /** + * Is this a valid URI? + * + * @return true if this object represents a valid URI, false + * otherwise. + */ + public function isValid() : Boolean + { + return this._valid; + } + + + /** + * Is this URI an absolute URI? An absolute URI is a complete, fully + * qualified reference to a resource. e.g. http://site.com/index.htm + * Non-hierarchical URI's are always absolute. + */ + public function isAbsolute() : Boolean + { + return !this._relative; + } + + + /** + * Is this URI a relative URI? Relative URI's do not have a scheme + * and only contain a relative path with optional anchor and query + * parts. e.g. "../reports/index.htm". Non-hierarchical URI's + * will never be relative. + */ + public function isRelative() : Boolean + { + return this._relative; + } + + + /** + * Does this URI point to a resource that is a directory/folder? + * The URI specification dictates that any path that ends in a slash + * is a directory. This is needed to be able to perform correct path + * logic when combining relative URI's with absolute URI's to + * obtain the correct absolute URI to a resource. + * + * @see URI.chdir + * + * @return true if this URI represents a directory resource, false + * if this URI represents a file resource. + */ + public function isDirectory() : Boolean + { + if (_path.length == 0) + return false; + + return (_path.charAt(path.length - 1) == '/'); + } + + + /** + * Is this URI a hierarchical URI? URI's can be + */ + public function isHierarchical() : Boolean + { + return hierState; + } + + + /** + * The scheme of the URI. + */ + public function get scheme() : String + { + return URI.unescapeChars(_scheme); + } + public function set scheme(schemeStr:String) : void + { + // Normalize the scheme + var normalized:String = schemeStr.toLowerCase(); + _scheme = URI.fastEscapeChars(normalized, URI.URIschemeExcludedBitmap); + } + + + /** + * The authority (host) of the URI. Only valid for + * hierarchical URI's. If the URI is relative, this will + * be an empty string. When setting this value, the string + * given is assumed to be unescaped. When retrieving this + * value, the resulting string is unescaped. + */ + public function get authority() : String + { + return URI.unescapeChars(_authority); + } + public function set authority(authorityStr:String) : void + { + // Normalize the authority + authorityStr = authorityStr.toLowerCase(); + + _authority = URI.fastEscapeChars(authorityStr, + URI.URIauthorityExcludedBitmap); + + // Only hierarchical URI's can have an authority, make + // sure this URI is of the proper format. + this.hierState = true; + } + + + /** + * The username of the URI. Only valid for hierarchical + * URI's. If the URI is relative, this will be an empty + * string. + * + * <p>The URI specification allows for authentication + * credentials to be embedded in the URI as such:</p> + * + * <p>http://user:passwd@host/path/to/file.htm</p> + * + * <p>When setting this value, the string + * given is assumed to be unescaped. When retrieving this + * value, the resulting string is unescaped.</p> + */ + public function get username() : String + { + return URI.unescapeChars(_username); + } + public function set username(usernameStr:String) : void + { + _username = URI.fastEscapeChars(usernameStr, URI.URIuserpassExcludedBitmap); + + // Only hierarchical URI's can have a username. + this.hierState = true; + } + + + /** + * The password of the URI. Similar to username. + * @see URI.username + */ + public function get password() : String + { + return URI.unescapeChars(_password); + } + public function set password(passwordStr:String) : void + { + _password = URI.fastEscapeChars(passwordStr, + URI.URIuserpassExcludedBitmap); + + // Only hierarchical URI's can have a password. + this.hierState = true; + } + + + /** + * The host port number. Only valid for hierarchical URI's. If + * the URI is relative, this will be an empty string. URI's can + * contain the port number of the remote host: + * + * <p>http://site.com:8080/index.htm</p> + */ + public function get port() : String + { + return URI.unescapeChars(_port); + } + public function set port(portStr:String) : void + { + _port = URI.escapeChars(portStr); + + // Only hierarchical URI's can have a port. + this.hierState = true; + } + + + /** + * The path portion of the URI. Only valid for hierarchical + * URI's. When setting this value, the string + * given is assumed to be unescaped. When retrieving this + * value, the resulting string is unescaped. + * + * <p>The path portion can be in one of two formats. 1) an absolute + * path, or 2) a relative path. An absolute path starts with a + * slash ('/'), a relative path does not.</p> + * + * <p>An absolute path may look like:</p> + * <listing>/full/path/to/my/file.htm</listing> + * + * <p>A relative path may look like:</p> + * <listing> + * path/to/my/file.htm + * ../images/logo.gif + * ../../reports/index.htm + * </listing> + * + * <p>Paths can be absolute or relative. Note that this not the same as + * an absolute or relative URI. An absolute URI can only have absolute + * paths. For example:</p> + * + * <listing>http:/site.com/path/to/file.htm</listing> + * + * <p>This absolute URI has an absolute path of "/path/to/file.htm".</p> + * + * <p>Relative URI's can have either absolute paths or relative paths. + * All of the following relative URI's are valid:</p> + * + * <listing> + * /absolute/path/to/file.htm + * path/to/file.htm + * ../path/to/file.htm + * </listing> + */ + public function get path() : String + { + return URI.unescapeChars(_path); + } + public function set path(pathStr:String) : void + { + this._path = URI.fastEscapeChars(pathStr, URI.URIpathExcludedBitmap); + + if (this._scheme == UNKNOWN_SCHEME) + { + // We set the path. This is a valid URI now. + this._scheme = ""; + } + + // Only hierarchical URI's can have a path. + hierState = true; + } + + + /** + * The query (CGI) portion of the URI. This part is valid for + * both hierarchical and non-hierarchical URI's. + * + * <p>This accessor should only be used if a custom query syntax + * is used. This URI class supports the common "param=value" + * style query syntax via the get/setQueryValue() and + * get/setQueryByMap() functions. Those functions should be used + * instead if the common syntax is being used. + * + * <p>The URI RFC does not specify any particular + * syntax for the query part of a URI. It is intended to allow + * any format that can be agreed upon by the two communicating hosts. + * However, most systems have standardized on the typical CGI + * format:</p> + * + * <listing>http://site.com/script.php?param1=value1¶m2=value2</listing> + * + * <p>This class has specific support for this query syntax</p> + * + * <p>This common query format is an array of name/value + * pairs with its own syntax that is different from the overall URI + * syntax. The query has its own escaping logic. For a query part + * to be properly escaped and unescaped, it must be split into its + * component parts. This accessor escapes/unescapes the entire query + * part without regard for it's component parts. This has the + * possibliity of leaving the query string in an ambiguious state in + * regards to its syntax. If the contents of the query part are + * important, it is recommended that get/setQueryValue() or + * get/setQueryByMap() are used instead.</p> + * + * If a different query syntax is being used, a subclass of URI + * can be created to handle that specific syntax. + * + * @see URI.getQueryValue, URI.getQueryByMap + */ + public function get query() : String + { + return URI.unescapeChars(_query); + } + public function set query(queryStr:String) : void + { + _query = URI.fastEscapeChars(queryStr, URI.URIqueryExcludedBitmap); + + // both hierarchical and non-hierarchical URI's can + // have a query. Do not set the hierState. + } + + /** + * Accessor to the raw query data. If you are using a custom query + * syntax, this accessor can be used to get and set the query part + * directly with no escaping/unescaping. This should ONLY be used + * if your application logic is handling custom query logic and + * handling the proper escaping of the query part. + */ + public function get queryRaw() : String + { + return _query; + } + public function set queryRaw(queryStr:String) : void + { + _query = queryStr; + } + + + /** + * The fragment (anchor) portion of the URI. This is valid for + * both hierarchical and non-hierarchical URI's. + */ + public function get fragment() : String + { + return URI.unescapeChars(_fragment); + } + public function set fragment(fragmentStr:String) : void + { + _fragment = URI.fastEscapeChars(fragmentStr, URIfragmentExcludedBitmap); + + // both hierarchical and non-hierarchical URI's can + // have a fragment. Do not set the hierState. + } + + + /** + * The non-hierarchical part of the URI. For example, if + * this URI object represents "mailto:somebody@company.com", + * this will contain "somebody@company.com". This is valid only + * for non-hierarchical URI's. + */ + public function get nonHierarchical() : String + { + return URI.unescapeChars(_nonHierarchical); + } + public function set nonHierarchical(nonHier:String) : void + { + _nonHierarchical = URI.fastEscapeChars(nonHier, URInonHierexcludedBitmap); + + // This is a non-hierarchical URI. + this.hierState = false; + } + + + /** + * Quick shorthand accessor to set the parts of this URI. + * The given parts are assumed to be in unescaped form. If + * the URI is non-hierarchical (e.g. mailto:) you will need + * to call SetScheme() and SetNonHierarchical(). + */ + public function setParts(schemeStr:String, authorityStr:String, + portStr:String, pathStr:String, queryStr:String, + fragmentStr:String) : void + { + this.scheme = schemeStr; + this.authority = authorityStr; + this.port = portStr; + this.path = pathStr; + this.query = queryStr; + this.fragment = fragmentStr; + + hierState = true; + } + + + /** + * URI escapes the given character string. This is similar in function + * to the global encodeURIComponent() function in ActionScript, but is + * slightly different in regards to which characters get escaped. This + * escapes the characters specified in the URIbaselineExluded set (see class + * static members). This is needed for this class to work properly. + * + * <p>If a different set of characters need to be used for the escaping, + * you may use fastEscapeChars() and specify a custom URIEncodingBitmap + * that contains the characters your application needs escaped.</p> + * + * <p>Never pass a full URI to this function. A URI can only be properly + * escaped/unescaped when split into its component parts (see RFC 3986 + * section 2.4). This is due to the fact that the URI component separators + * could be characters that would normally need to be escaped.</p> + * + * @param unescaped character string to be escaped. + * + * @return escaped character string + * + * @see encodeURIComponent + * @see fastEscapeChars + */ + static public function escapeChars(unescaped:String) : String + { + // This uses the excluded set by default. + return fastEscapeChars(unescaped, URI.URIbaselineExcludedBitmap); + } + + + /** + * Unescape any URI escaped characters in the given character + * string. + * + * <p>Never pass a full URI to this function. A URI can only be properly + * escaped/unescaped when split into its component parts (see RFC 3986 + * section 2.4). This is due to the fact that the URI component separators + * could be characters that would normally need to be escaped.</p> + * + * @param escaped the escaped string to be unescaped. + * + * @return unescaped string. + */ + static public function unescapeChars(escaped:String /*, onlyHighASCII:Boolean = false*/) : String + { + // We can just use the default AS function. It seems to + // decode everything correctly + var unescaped:String; + unescaped = decodeURIComponent(escaped); + return unescaped; + } + + /** + * Performance focused function that escapes the given character + * string using the given URIEncodingBitmap as the rule for what + * characters need to be escaped. This function is used by this + * class and can be used externally to this class to perform + * escaping on custom character sets. + * + * <p>Never pass a full URI to this function. A URI can only be properly + * escaped/unescaped when split into its component parts (see RFC 3986 + * section 2.4). This is due to the fact that the URI component separators + * could be characters that would normally need to be escaped.</p> + * + * @param unescaped the unescaped string to be escaped + * @param bitmap the set of characters that need to be escaped + * + * @return the escaped string. + */ + static public function fastEscapeChars(unescaped:String, bitmap:URIEncodingBitmap) : String + { + var escaped:String = ""; + var c:String; + var x:int, i:int; + + for (i = 0; i < unescaped.length; i++) + { + c = unescaped.charAt(i); + + x = bitmap.ShouldEscape(c); + if (x) + { + c = x.toString(16); + if (c.length == 1) + c = "0" + c; + + c = "%" + c; + c = c.toUpperCase(); + } + + escaped += c; + } + + return escaped; + } + + + /** + * Is this URI of a particular scheme type? For example, + * passing "http" to a URI object that represents the URI + * "http://site.com/" would return true. + * + * @param scheme scheme to check for + * + * @return true if this URI object is of the given type, false + * otherwise. + */ + public function isOfType(scheme:String) : Boolean + { + // Schemes are never case sensitive. Ignore case. + scheme = scheme.toLowerCase(); + return (this._scheme == scheme); + } + + + /** + * Get the value for the specified named in the query part. This + * assumes the query part of the URI is in the common + * "name1=value1&name2=value2" syntax. Do not call this function + * if you are using a custom query syntax. + * + * @param name name of the query value to get. + * + * @return the value of the query name, empty string if the + * query name does not exist. + */ + public function getQueryValue(name:String) : String + { + var map:Object; + var item:String; + var value:String; + + map = getQueryByMap(); + + for (item in map) + { + if (item == name) + { + value = map[item]; + return value; + } + } + + // Didn't find the specified key + return new String(""); + } + + + /** + * Set the given value on the given query name. If the given name + * does not exist, it will automatically add this name/value pair + * to the query. If null is passed as the value, it will remove + * the given item from the query. + * + * <p>This automatically escapes any characters that may conflict with + * the query syntax so that they are "safe" within the query. The + * strings passed are assumed to be literal unescaped name and value.</p> + * + * @param name name of the query value to set + * @param value value of the query item to set. If null, this will + * force the removal of this item from the query. + */ + public function setQueryValue(name:String, value:String) : void + { + var map:Object; + + map = getQueryByMap(); + + // If the key doesn't exist yet, this will create a new pair in + // the map. If it does exist, this will overwrite the previous + // value, which is what we want. + map[name] = value; + + setQueryByMap(map); + } + + + /** + * Get the query of the URI in an Object class that allows for easy + * access to the query data via Object accessors. For example: + * + * <listing> + * var query:Object = uri.getQueryByMap(); + * var value:String = query["param"]; // get a value + * query["param2"] = "foo"; // set a new value + * </listing> + * + * @return Object that contains the name/value pairs of the query. + * + * @see #setQueryByMap + * @see #getQueryValue + * @see #setQueryValue + */ + public function getQueryByMap() : Object + { + var queryStr:String; + var pair:String; + var pairs:Array; + var item:Array; + var name:String, value:String; + var index:int; + var map:Object = new Object(); + + + // We need the raw query string, no unescaping. + queryStr = this._query; + + pairs = queryStr.split('&'); + for each (pair in pairs) + { + if (pair.length == 0) + continue; + + item = pair.split('='); + + if (item.length > 0) + name = item[0]; + else + continue; // empty array + + if (item.length > 1) + value = item[1]; + else + value = ""; + + name = queryPartUnescape(name); + value = queryPartUnescape(value); + + map[name] = value; + } + + return map; + } + + + /** + * Set the query part of this URI using the given object as the + * content source. Any member of the object that has a value of + * null will not be in the resulting query. + * + * @param map object that contains the name/value pairs as + * members of that object. + * + * @see #getQueryByMap + * @see #getQueryValue + * @see #setQueryValue + */ + public function setQueryByMap(map:Object) : void + { + var item:String; + var name:String, value:String; + var queryStr:String = ""; + var tmpPair:String; + var foo:String; + + for (item in map) + { + name = item; + value = map[item]; + + if (value == null) + value = ""; + + // Need to escape the name/value pair so that they + // don't conflict with the query syntax (specifically + // '=', '&', and <whitespace>). + name = queryPartEscape(name); + value = queryPartEscape(value); + + tmpPair = name; + + if (value.length > 0) + { + tmpPair += "="; + tmpPair += value; + } + + if (queryStr.length != 0) + queryStr += '&'; // Add the separator + + queryStr += tmpPair; + } + + // We don't want to escape. We already escaped the + // individual name/value pairs. If we escaped the + // query string again by assigning it to "query", + // we would have double escaping. + _query = queryStr; + } + + + /** + * Similar to Escape(), except this also escapes characters that + * would conflict with the name/value pair query syntax. This is + * intended to be called on each individual "name" and "value" + * in the query making sure that nothing in the name or value + * strings contain characters that would conflict with the query + * syntax (e.g. '=' and '&'). + * + * @param unescaped unescaped string that is to be escaped. + * + * @return escaped string. + * + * @see #queryUnescape + */ + static public function queryPartEscape(unescaped:String) : String + { + var escaped:String = unescaped; + escaped = URI.fastEscapeChars(unescaped, URI.URIqueryPartExcludedBitmap); + return escaped; + } + + + /** + * Unescape the individual name/value string pairs. + * + * @param escaped escaped string to be unescaped + * + * @return unescaped string + * + * @see #queryEscape + */ + static public function queryPartUnescape(escaped:String) : String + { + var unescaped:String = escaped; + unescaped = unescapeChars(unescaped); + return unescaped; + } + + /** + * Output this URI as a string. The resulting string is properly + * escaped and well formed for machine processing. + */ + public function toString() : String + { + if (this == null) + return ""; + else + return toStringInternal(false); + } + + /** + * Output the URI as a string that is easily readable by a human. + * This outputs the URI with all escape sequences unescaped to + * their character representation. This makes the URI easier for + * a human to read, but the URI could be completely invalid + * because some unescaped characters may now cause ambiguous parsing. + * This function should only be used if you want to display a URI to + * a user. This function should never be used outside that specific + * case. + * + * @return the URI in string format with all escape sequences + * unescaped. + * + * @see #toString + */ + public function toDisplayString() : String + { + return toStringInternal(true); + } + + + /** + * @private + * + * The guts of toString() + */ + protected function toStringInternal(forDisplay:Boolean) : String + { + var uri:String = ""; + var part:String = ""; + + if (isHierarchical() == false) + { + // non-hierarchical URI + + uri += (forDisplay ? this.scheme : _scheme); + uri += ":"; + uri += (forDisplay ? this.nonHierarchical : _nonHierarchical); + } + else + { + // Hierarchical URI + + if (isRelative() == false) + { + // If it is not a relative URI, then we want the scheme and + // authority parts in the string. If it is relative, we + // do NOT want this stuff. + + if (_scheme.length != 0) + { + part = (forDisplay ? this.scheme : _scheme); + uri += part + ":"; + } + + if (_authority.length != 0 || isOfType("file")) + { + uri += "//"; + + // Add on any username/password associated with this + // authority + if (_username.length != 0) + { + part = (forDisplay ? this.username : _username); + uri += part; + + if (_password.length != 0) + { + part = (forDisplay ? this.password : _password); + uri += ":" + part; + } + + uri += "@"; + } + + // add the authority + part = (forDisplay ? this.authority : _authority); + uri += part; + + // Tack on the port number, if any + if (port.length != 0) + uri += ":" + port; + } + } + + // Tack on the path + part = (forDisplay ? this.path : _path); + uri += part; + + } // end hierarchical part + + // Both non-hier and hierarchical have query and fragment parts + + // Add on the query and fragment parts + if (_query.length != 0) + { + part = (forDisplay ? this.query : _query); + uri += "?" + part; + } + + if (fragment.length != 0) + { + part = (forDisplay ? this.fragment : _fragment); + uri += "#" + part; + } + + return uri; + } + + /** + * Forcefully ensure that this URI is properly escaped. + * + * <p>Sometimes URI's are constructed by hand using strings outside + * this class. In those cases, it is unlikely the URI has been + * properly escaped. This function forcefully escapes this URI + * by unescaping each part and then re-escaping it. If the URI + * did not have any escaping, the first unescape will do nothing + * and then the re-escape will properly escape everything. If + * the URI was already escaped, the unescape and re-escape will + * essentally be a no-op. This provides a safe way to make sure + * a URI is in the proper escaped form.</p> + */ + public function forceEscape() : void + { + // The accessors for each of the members will unescape + // and then re-escape as we get and assign them. + + // Handle the parts that are common for both hierarchical + // and non-hierarchical URI's + this.scheme = this.scheme; + this.setQueryByMap(this.getQueryByMap()); + this.fragment = this.fragment; + + if (isHierarchical()) + { + this.authority = this.authority; + this.path = this.path; + this.port = this.port; + this.username = this.username; + this.password = this.password; + } + else + { + this.nonHierarchical = this.nonHierarchical; + } + } + + + /** + * Does this URI point to a resource of the given file type? + * Given a file extension (or just a file name, this will strip the + * extension), check to see if this URI points to a file of that + * type. + * + * @param extension string that contains a file extension with or + * without a dot ("html" and ".html" are both valid), or a file + * name with an extension (e.g. "index.html"). + * + * @return true if this URI points to a resource with the same file + * file extension as the extension provided, false otherwise. + */ + public function isOfFileType(extension:String) : Boolean + { + var thisExtension:String; + var index:int; + + index = extension.lastIndexOf("."); + if (index != -1) + { + // Strip the extension + extension = extension.substr(index + 1); + } + else + { + // The caller passed something without a dot in it. We + // will assume that it is just a plain extension (e.g. "html"). + // What they passed is exactly what we want + } + + thisExtension = getExtension(true); + + if (thisExtension == "") + return false; + + // Compare the extensions ignoring case + if (compareStr(thisExtension, extension, false) == 0) + return true; + else + return false; + } + + + /** + * Get the ".xyz" file extension from the filename in the URI. + * For example, if we have the following URI: + * + * <listing>http://something.com/path/to/my/page.html?form=yes&name=bob#anchor</listing> + * + * <p>This will return ".html".</p> + * + * @param minusDot If true, this will strip the dot from the extension. + * If true, the above example would have returned "html". + * + * @return the file extension + */ + public function getExtension(minusDot:Boolean = false) : String + { + var filename:String = getFilename(); + var extension:String; + var index:int; + + if (filename == "") + return String(""); + + index = filename.lastIndexOf("."); + + // If it doesn't have an extension, or if it is a "hidden" file, + // it doesn't have an extension. Hidden files on unix start with + // a dot (e.g. ".login"). + if (index == -1 || index == 0) + return String(""); + + extension = filename.substr(index); + + // If the caller does not want the dot, remove it. + if (minusDot && extension.charAt(0) == ".") + extension = extension.substr(1); + + return extension; + } + + /** + * Quick function to retrieve the file name off the end of a URI. + * + * <p>For example, if the URI is:</p> + * <listing>http://something.com/some/path/to/my/file.html</listing> + * <p>this function will return "file.html".</p> + * + * @param minusExtension true if the file extension should be stripped + * + * @return the file name. If this URI is a directory, the return + * value will be empty string. + */ + public function getFilename(minusExtension:Boolean = false) : String + { + if (isDirectory()) + return String(""); + + var pathStr:String = this.path; + var filename:String; + var index:int; + + // Find the last path separator. + index = pathStr.lastIndexOf("/"); + + if (index != -1) + filename = pathStr.substr(index + 1); + else + filename = pathStr; + + if (minusExtension) + { + // The caller has requested that the extension be removed + index = filename.lastIndexOf("."); + + if (index != -1) + filename = filename.substr(0, index); + } + + return filename; + } + + + /** + * @private + * Helper function to compare strings. + * + * @return true if the two strings are identical, false otherwise. + */ + static protected function compareStr(str1:String, str2:String, + sensitive:Boolean = true) : Boolean + { + if (sensitive == false) + { + str1 = str1.toLowerCase(); + str2 = str2.toLowerCase(); + } + + return (str1 == str2) + } + + /** + * Based on the type of this URI (http, ftp, etc.) get + * the default port used for that protocol. This is + * just intended to be a helper function for the most + * common cases. + */ + public function getDefaultPort() : String + { + if (_scheme == "http") + return String("80"); + else if (_scheme == "ftp") + return String("21"); + else if (_scheme == "file") + return String(""); + else if (_scheme == "sftp") + return String("22"); // ssh standard port + else + { + // Don't know the port for this URI type + return String(""); + } + } + + /** + * @private + * + * This resolves the given URI if the application has a + * resolver interface defined. This function does not + * modify the passed in URI and returns a new URI. + */ + static protected function resolve(uri:URI) : URI + { + var copy:URI = new URI(); + copy.copyURI(uri); + + if (_resolver != null) + { + // A resolver class has been registered. Call it. + return _resolver.resolve(copy); + } + else + { + // No resolver. Nothing to do, but we don't + // want to reuse the one passed in. + return copy; + } + } + + /** + * Accessor to set and get the resolver object used by all URI + * objects to dynamically resolve URI's before comparison. + */ + static public function set resolver(resolver:IURIResolver) : void + { + _resolver = resolver; + } + static public function get resolver() : IURIResolver + { + return _resolver; + } + + /** + * Given another URI, return this URI object's relation to the one given. + * URI's can have 1 of 4 possible relationships. They can be unrelated, + * equal, parent, or a child of the given URI. + * + * @param uri URI to compare this URI object to. + * @param caseSensitive true if the URI comparison should be done + * taking case into account, false if the comparison should be + * performed case insensitive. + * + * @return URI.NOT_RELATED, URI.CHILD, URI.PARENT, or URI.EQUAL + */ + public function getRelation(uri:URI, caseSensitive:Boolean = true) : int + { + // Give the app a chance to resolve these URI's before we compare them. + var thisURI:URI = URI.resolve(this); + var thatURI:URI = URI.resolve(uri); + + if (thisURI.isRelative() || thatURI.isRelative()) + { + // You cannot compare relative URI's due to their lack of context. + // You could have two relative URI's that look like: + // ../../images/ + // ../../images/marketing/logo.gif + // These may appear related, but you have no overall context + // from which to make the comparison. The first URI could be + // from one site and the other URI could be from another site. + return URI.NOT_RELATED; + } + else if (thisURI.isHierarchical() == false || thatURI.isHierarchical() == false) + { + // One or both of the URI's are non-hierarchical. + if (((thisURI.isHierarchical() == false) && (thatURI.isHierarchical() == true)) || + ((thisURI.isHierarchical() == true) && (thatURI.isHierarchical() == false))) + { + // XOR. One is hierarchical and the other is + // non-hierarchical. They cannot be compared. + return URI.NOT_RELATED; + } + else + { + // They are both non-hierarchical + if (thisURI.scheme != thatURI.scheme) + return URI.NOT_RELATED; + + if (thisURI.nonHierarchical != thatURI.nonHierarchical) + return URI.NOT_RELATED; + + // The two non-hierarcical URI's are equal. + return URI.EQUAL; + } + } + + // Ok, this URI and the one we are being compared to are both + // absolute hierarchical URI's. + + if (thisURI.scheme != thatURI.scheme) + return URI.NOT_RELATED; + + if (thisURI.authority != thatURI.authority) + return URI.NOT_RELATED; + + var thisPort:String = thisURI.port; + var thatPort:String = thatURI.port; + + // Different ports are considered completely different servers. + if (thisPort == "") + thisPort = thisURI.getDefaultPort(); + if (thatPort == "") + thatPort = thatURI.getDefaultPort(); + + // Check to see if the port is the default port. + if (thisPort != thatPort) + return URI.NOT_RELATED; + + if (compareStr(thisURI.path, thatURI.path, caseSensitive)) + return URI.EQUAL; + + // Special case check. If we are here, the scheme, authority, + // and port match, and it is not a relative path, but the + // paths did not match. There is a special case where we + // could have: + // http://something.com/ + // http://something.com + // Technically, these are equal. So lets, check for this case. + var thisPath:String = thisURI.path; + var thatPath:String = thatURI.path; + + if ( (thisPath == "/" || thatPath == "/") && + (thisPath == "" || thatPath == "") ) + { + // We hit the special case. These two are equal. + return URI.EQUAL; + } + + // Ok, the paths do not match, but one path may be a parent/child + // of the other. For example, we may have: + // http://something.com/path/to/homepage/ + // http://something.com/path/to/homepage/images/logo.gif + // In this case, the first is a parent of the second (or the second + // is a child of the first, depending on which you compare to the + // other). To make this comparison, we must split the path into + // its component parts (split the string on the '/' path delimiter). + // We then compare the + var thisParts:Array, thatParts:Array; + var thisPart:String, thatPart:String; + var i:int; + + thisParts = thisPath.split("/"); + thatParts = thatPath.split("/"); + + if (thisParts.length > thatParts.length) + { + thatPart = thatParts[thatParts.length - 1]; + if (thatPart.length > 0) + { + // if the last part is not empty, the passed URI is + // not a directory. There is no way the passed URI + // can be a parent. + return URI.NOT_RELATED; + } + else + { + // Remove the empty trailing part + thatParts.pop(); + } + + // This may be a child of the one passed in + for (i = 0; i < thatParts.length; i++) + { + thisPart = thisParts[i]; + thatPart = thatParts[i]; + + if (compareStr(thisPart, thatPart, caseSensitive) == false) + return URI.NOT_RELATED; + } + + return URI.CHILD; + } + else if (thisParts.length < thatParts.length) + { + thisPart = thisParts[thisParts.length - 1]; + if (thisPart.length > 0) + { + // if the last part is not empty, this URI is not a + // directory. There is no way this object can be + // a parent. + return URI.NOT_RELATED; + } + else + { + // Remove the empty trailing part + thisParts.pop(); + } + + // This may be the parent of the one passed in + for (i = 0; i < thisParts.length; i++) + { + thisPart = thisParts[i]; + thatPart = thatParts[i]; + + if (compareStr(thisPart, thatPart, caseSensitive) == false) + return URI.NOT_RELATED; + } + + return URI.PARENT; + } + else + { + // Both URI's have the same number of path components, but + // it failed the equivelence check above. This means that + // the two URI's are not related. + return URI.NOT_RELATED; + } + + // If we got here, the scheme and authority are the same, + // but the paths pointed to two different locations that + // were in different parts of the file system tree + return URI.NOT_RELATED; + } + + /** + * Given another URI, return the common parent between this one + * and the provided URI. + * + * @param uri the other URI from which to find a common parent + * @para caseSensitive true if this operation should be done + * with case sensitive comparisons. + * + * @return the parent URI if successful, null otherwise. + */ + public function getCommonParent(uri:URI, caseSensitive:Boolean = true) : URI + { + var thisURI:URI = URI.resolve(this); + var thatURI:URI = URI.resolve(uri); + + if(!thisURI.isAbsolute() || !thatURI.isAbsolute() || + thisURI.isHierarchical() == false || + thatURI.isHierarchical() == false) + { + // Both URI's must be absolute hierarchical for this to + // make sense. + return null; + } + + var relation:int = thisURI.getRelation(thatURI); + if (relation == URI.NOT_RELATED) + { + // The given URI is not related to this one. No + // common parent. + return null; + } + + thisURI.chdir("."); + thatURI.chdir("."); + + var strBefore:String, strAfter:String; + do + { + relation = thisURI.getRelation(thatURI, caseSensitive); + if(relation == URI.EQUAL || relation == URI.PARENT) + break; + + // If strBefore and strAfter end up being the same, + // we know we are at the root of the path because + // chdir("..") is doing nothing. + strBefore = thisURI.toString(); + thisURI.chdir(".."); + strAfter = thisURI.toString(); + } + while(strBefore != strAfter); + + return thisURI; + } + + + /** + * This function is used to move around in a URI in a way similar + * to the 'cd' or 'chdir' commands on Unix. These operations are + * completely string based, using the context of the URI to + * determine the position within the path. The heuristics used + * to determine the action are based off Appendix C in RFC 2396. + * + * <p>URI paths that end in '/' are considered paths that point to + * directories, while paths that do not end in '/' are files. For + * example, if you execute chdir("d") on the following URI's:<br/> + * 1. http://something.com/a/b/c/ (directory)<br/> + * 2. http://something.com/a/b/c (not directory)<br/> + * you will get:<br/> + * 1. http://something.com/a/b/c/d<br/> + * 2. http://something.com/a/b/d<br/></p> + * + * <p>See RFC 2396, Appendix C for more info.</p> + * + * @param reference the URI or path to "cd" to. + * @param escape true if the passed reference string should be URI + * escaped before using it. + * + * @return true if the chdir was successful, false otherwise. + */ + public function chdir(reference:String, escape:Boolean = false) : Boolean + { + var uriReference:URI; + var ref:String = reference; + + if (escape) + ref = URI.escapeChars(reference); + + if (ref == "") + { + // NOOP + return true; + } + else if (ref.substr(0, 2) == "//") + { + // Special case. This is an absolute URI but without the scheme. + // Take the scheme from this URI and tack it on. This is + // intended to make working with chdir() a little more + // tolerant. + var finalStr:String = this.scheme + ":" + ref; + + return constructURI(finalStr); + } + else if (ref.charAt(0) == "?") + { + // A relative URI that is just a query part is essentially + // a "./?query". We tack on the "./" here to make the rest + // of our logic work. + ref = "./" + ref; + } + + // Parse the reference passed in as a URI. This way we + // get any query and fragments parsed out as well. + uriReference = new URI(ref); + + if (uriReference.isAbsolute() || + uriReference.isHierarchical() == false) + { + // If the URI given is a full URI, it replaces this one. + copyURI(uriReference); + return true; + } + + + var thisPath:String, thatPath:String; + var thisParts:Array, thatParts:Array; + var thisIsDir:Boolean = false, thatIsDir:Boolean = false; + var thisIsAbs:Boolean = false, thatIsAbs:Boolean = false; + var lastIsDotOperation:Boolean = false; + var curDir:String; + var i:int; + + thisPath = this.path; + thatPath = uriReference.path; + + if (thisPath.length > 0) + thisParts = thisPath.split("/"); + else + thisParts = new Array(); + + if (thatPath.length > 0) + thatParts = thatPath.split("/"); + else + thatParts = new Array(); + + if (thisParts.length > 0 && thisParts[0] == "") + { + thisIsAbs = true; + thisParts.shift(); // pop the first one off the array + } + if (thisParts.length > 0 && thisParts[thisParts.length - 1] == "") + { + thisIsDir = true; + thisParts.pop(); // pop the last one off the array + } + + if (thatParts.length > 0 && thatParts[0] == "") + { + thatIsAbs = true; + thatParts.shift(); // pop the first one off the array + } + if (thatParts.length > 0 && thatParts[thatParts.length - 1] == "") + { + thatIsDir = true; + thatParts.pop(); // pop the last one off the array + } + + if (thatIsAbs) + { + // The reference is an absolute path (starts with a slash). + // It replaces this path wholesale. + this.path = uriReference.path; + + // And it inherits the query and fragment + this.queryRaw = uriReference.queryRaw; + this.fragment = uriReference.fragment; + + return true; + } + else if (thatParts.length == 0 && uriReference.query == "") + { + // The reference must have only been a fragment. Fragments just + // get appended to whatever the current path is. We don't want + // to overwrite any query that may already exist, so this case + // only takes on the new fragment. + this.fragment = uriReference.fragment; + return true; + } + else if (thisIsDir == false && thisParts.length > 0) + { + // This path ends in a file. It goes away no matter what. + thisParts.pop(); + } + + // By default, this assumes the query and fragment of the reference + this.queryRaw = uriReference.queryRaw; + this.fragment = uriReference.fragment; + + // Append the parts of the path from the passed in reference + // to this object's path. + thisParts = thisParts.concat(thatParts); + + for(i = 0; i < thisParts.length; i++) + { + curDir = thisParts[i]; + lastIsDotOperation = false; + + if (curDir == ".") + { + thisParts.splice(i, 1); + i = i - 1; // account for removing this item + lastIsDotOperation = true; + } + else if (curDir == "..") + { + if (i >= 1) + { + if (thisParts[i - 1] == "..") + { + // If the previous is a "..", we must have skipped + // it due to this URI being relative. We can't + // collapse leading ".."s in a relative URI, so + // do nothing. + } + else + { + thisParts.splice(i - 1, 2); + i = i - 2; // move back to account for the 2 we removed + } + } + else + { + // This is the first thing in the path. + + if (isRelative()) + { + // We can't collapse leading ".."s in a relative + // path. Do noting. + } + else + { + // This is an abnormal case. We have dot-dotted up + // past the base of our "file system". This is a + // case where we had a /path/like/this.htm and were + // given a path to chdir to like this: + // ../../../../../../mydir + // Obviously, it has too many ".." and will take us + // up beyond the top of the URI. However, according + // RFC 2396 Appendix C.2, we should try to handle + // these abnormal cases appropriately. In this case, + // we will do what UNIX command lines do if you are + // at the root (/) of the filesystem and execute: + // # cd ../../../../../bin + // Which will put you in /bin. Essentially, the extra + // ".."'s will just get eaten. + + thisParts.splice(i, 1); + i = i - 1; // account for the ".." we just removed + } + } + + lastIsDotOperation = true; + } + } + + var finalPath:String = ""; + + // If the last thing in the path was a "." or "..", then this thing is a + // directory. If the last thing isn't a dot-op, then we don't want to + // blow away any information about the directory (hence the "|=" binary + // assignment). + thatIsDir = thatIsDir || lastIsDotOperation; + + // Reconstruct the path with the abs/dir info we have + finalPath = joinPath(thisParts, thisIsAbs, thatIsDir); + + // Set the path (automatically escaping it) + this.path = finalPath; + + return true; + } + + /** + * @private + * Join an array of path parts back into a URI style path string. + * This is used by the various path logic functions to recombine + * a path. This is different than the standard Array.join() + * function because we need to take into account the starting and + * ending path delimiters if this is an absolute path or a + * directory. + * + * @param parts the Array that contains strings of each path part. + * @param isAbs true if the given path is absolute + * @param isDir true if the given path is a directory + * + * @return the combined path string. + */ + protected function joinPath(parts:Array, isAbs:Boolean, isDir:Boolean) : String + { + var pathStr:String = ""; + var i:int; + + for (i = 0; i < parts.length; i++) + { + if (pathStr.length > 0) + pathStr += "/"; + + pathStr += parts[i]; + } + + // If this path is a directory, tack on the directory delimiter, + // but only if the path contains something. Adding this to an + // empty path would make it "/", which is an absolute path that + // starts at the root. + if (isDir && pathStr.length > 0) + pathStr += "/"; + + if (isAbs) + pathStr = "/" + pathStr; + + return pathStr; + } + + /** + * Given an absolute URI, make this relative URI absolute using + * the given URI as a base. This URI instance must be relative + * and the base_uri must be absolute. + * + * @param base_uri URI to use as the base from which to make + * this relative URI into an absolute URI. + * + * @return true if successful, false otherwise. + */ + public function makeAbsoluteURI(base_uri:URI) : Boolean + { + if (isAbsolute() || base_uri.isRelative()) + { + // This URI needs to be relative, and the base needs to be + // absolute otherwise we won't know what to do! + return false; + } + + // Make a copy of the base URI. We don't want to modify + // the passed URI. + var base:URI = new URI(); + base.copyURI(base_uri); + + // ChDir on the base URI. This will preserve any query + // and fragment we have. + if (base.chdir(toString()) == false) + return false; + + // It worked, so copy the base into this one + copyURI(base); + + return true; + } + + + /** + * Given a URI to use as a base from which this object should be + * relative to, convert this object into a relative URI. For example, + * if you have: + * + * <listing> + * var uri1:URI = new URI("http://something.com/path/to/some/file.html"); + * var uri2:URI = new URI("http://something.com/path/to/another/file.html"); + * + * uri1.MakeRelativePath(uri2);</listing> + * + * <p>uri1 will have a final value of "../some/file.html"</p> + * + * <p>Note! This function is brute force. If you have two URI's + * that are completely unrelated, this will still attempt to make + * the relative URI. In that case, you will most likely get a + * relative path that looks something like:</p> + * + * <p>../../../../../../some/path/to/my/file.html</p> + * + * @param base_uri the URI from which to make this URI relative + * + * @return true if successful, false if the base_uri and this URI + * are not related, of if error. + */ + public function makeRelativeURI(base_uri:URI, caseSensitive:Boolean = true) : Boolean + { + var base:URI = new URI(); + base.copyURI(base_uri); + + var thisParts:Array, thatParts:Array; + var finalParts:Array = new Array(); + var thisPart:String, thatPart:String, finalPath:String; + var pathStr:String = this.path; + var queryStr:String = this.queryRaw; + var fragmentStr:String = this.fragment; + var i:int; + var diff:Boolean = false; + var isDir:Boolean = false; + + if (isRelative()) + { + // We're already relative. + return true; + } + + if (base.isRelative()) + { + // The base is relative. A relative base doesn't make sense. + return false; + } + + + if ( (isOfType(base_uri.scheme) == false) || + (this.authority != base_uri.authority) ) + { + // The schemes and/or authorities are different. We can't + // make a relative path to something that is completely + // unrelated. + return false; + } + + // Record the state of this URI + isDir = isDirectory(); + + // We are based of the directory of the given URI. We need to + // make sure the URI is pointing to a directory. Changing + // directory to "." will remove any file name if the base is + // not a directory. + base.chdir("."); + + thisParts = pathStr.split("/"); + thatParts = base.path.split("/"); + + if (thisParts.length > 0 && thisParts[0] == "") + thisParts.shift(); + + if (thisParts.length > 0 && thisParts[thisParts.length - 1] == "") + { + isDir = true; + thisParts.pop(); + } + + if (thatParts.length > 0 && thatParts[0] == "") + thatParts.shift(); + if (thatParts.length > 0 && thatParts[thatParts.length - 1] == "") + thatParts.pop(); + + + // Now that we have the paths split into an array of directories, + // we can compare the two paths. We start from the left of side + // of the path and start comparing. When we either run out of + // directories (one path is longer than the other), or we find + // a directory that is different, we stop. The remaining parts + // of each path is then used to determine the relative path. For + // example, lets say we have: + // path we want to make relative: /a/b/c/d/e.txt + // path to use as base for relative: /a/b/f/ + // + // This loop will start at the left, and remove directories + // until we get a mismatch or run off the end of one of them. + // In this example, the result will be: + // c/d/e.txt + // f + // + // For every part left over in the base path, we prepend a ".." + // to the relative to get the final path: + // ../c/d/e.txt + while(thatParts.length > 0) + { + if (thisParts.length == 0) + { + // we matched all there is to match, we are done. + // This is the case where "this" object is a parent + // path of the given URI. eg: + // this.path = /a/b/ (thisParts) + // base.path = /a/b/c/d/e/ (thatParts) + break; + } + + thisPart = thisParts[0]; + thatPart = thatParts[0]; + + if (compareStr(thisPart, thatPart, caseSensitive)) + { + thisParts.shift(); + thatParts.shift(); + } + else + break; + } + + // If there are any path info left from the base URI, that means + // **this** object is above the given URI in the file tree. For + // each part left over in the given URI, we need to move up one + // directory to get where we are. + var dotdot:String = ".."; + for (i = 0; i < thatParts.length; i++) + { + finalParts.push(dotdot); + } + + // Append the parts of this URI to any dot-dot's we have + finalParts = finalParts.concat(thisParts); + + // Join the parts back into a path + finalPath = joinPath(finalParts, false /* not absolute */, isDir); + + if (finalPath.length == 0) + { + // The two URI's are exactly the same. The proper relative + // path is: + finalPath = "./"; + } + + // Set the parts of the URI, preserving the original query and + // fragment parts. + setParts("", "", "", finalPath, queryStr, fragmentStr); + + return true; + } + + /** + * Given a string, convert it to a URI. The string could be a + * full URI that is improperly escaped, a malformed URI (e.g. + * missing a protocol like "www.something.com"), a relative URI, + * or any variation there of. + * + * <p>The intention of this function is to take anything that a + * user might manually enter as a URI/URL and try to determine what + * they mean. This function differs from the URI constructor in + * that it makes some assumptions to make it easy to import user + * entered URI data.</p> + * + * <p>This function is intended to be a helper function. + * It is not all-knowning and will probably make mistakes + * when attempting to parse a string of unknown origin. If + * your applicaiton is receiving input from the user, your + * application should already have a good idea what the user + * should be entering, and your application should be + * pre-processing the user's input to make sure it is well formed + * before passing it to this function.</p> + * + * <p>It is assumed that the string given to this function is + * something the user may have manually entered. Given this, + * the URI string is probably unescaped or improperly escaped. + * This function will attempt to properly escape the URI by + * using forceEscape(). The result is that a toString() call + * on a URI that was created from unknownToURI() may not match + * the input string due to the difference in escaping.</p> + * + * @param unknown a potental URI string that should be parsed + * and loaded into this object. + * @param defaultScheme if it is determined that the passed string + * looks like a URI, but it is missing the scheme part, this + * string will be used as the missing scheme. + * + * @return true if the given string was successfully parsed into + * a valid URI object, false otherwise. + */ + public function unknownToURI(unknown:String, defaultScheme:String = "http") : Boolean + { + var temp:String; + + if (unknown.length == 0) + { + this.initialize(); + return false; + } + + // Some users love the backslash key. Fix it. + unknown = unknown.replace(/\\/g, "/"); + + // Check for any obviously missing scheme. + if (unknown.length >= 2) + { + temp = unknown.substr(0, 2); + if (temp == "//") + unknown = defaultScheme + ":" + unknown; + } + + if (unknown.length >= 3) + { + temp = unknown.substr(0, 3); + if (temp == "://") + unknown = defaultScheme + unknown; + } + + // Try parsing it as a normal URI + var uri:URI = new URI(unknown); + + if (uri.isHierarchical() == false) + { + if (uri.scheme == UNKNOWN_SCHEME) + { + this.initialize(); + return false; + } + + // It's a non-hierarchical URI + copyURI(uri); + forceEscape(); + return true; + } + else if ((uri.scheme != UNKNOWN_SCHEME) && + (uri.scheme.length > 0)) + { + if ( (uri.authority.length > 0) || + (uri.scheme == "file") ) + { + // file://... URI + copyURI(uri); + forceEscape(); // ensure proper escaping + return true; + } + else if (uri.authority.length == 0 && uri.path.length == 0) + { + // It's is an incomplete URI (eg "http://") + + setParts(uri.scheme, "", "", "", "", ""); + return false; + } + } + else + { + // Possible relative URI. We can only detect relative URI's + // that start with "." or "..". If it starts with something + // else, the parsing is ambiguous. + var path:String = uri.path; + + if (path == ".." || path == "." || + (path.length >= 3 && path.substr(0, 3) == "../") || + (path.length >= 2 && path.substr(0, 2) == "./") ) + { + // This is a relative URI. + copyURI(uri); + forceEscape(); + return true; + } + } + + // Ok, it looks like we are just a normal URI missing the scheme. Tack + // on the scheme. + uri = new URI(defaultScheme + "://" + unknown); + + // Check to see if we are good now + if (uri.scheme.length > 0 && uri.authority.length > 0) + { + // It was just missing the scheme. + copyURI(uri); + forceEscape(); // Make sure we are properly encoded. + return true; + } + + // don't know what this is + this.initialize(); + return false; + } + + } // end URI class +} // end package \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/URIEncodingBitmap.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/URIEncodingBitmap.as new file mode 100644 index 0000000000000000000000000000000000000000..9c0239cb945cf1545404250bf2471acd51212299 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/URIEncodingBitmap.as @@ -0,0 +1,142 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.net +{ + import flash.utils.ByteArray; + + /** + * This class implements an efficient lookup table for URI + * character escaping. This class is only needed if you + * create a derived class of URI to handle custom URI + * syntax. This class is used internally by URI. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0* + */ + public class URIEncodingBitmap extends ByteArray + { + /** + * Constructor. Creates an encoding bitmap using the given + * string of characters as the set of characters that need + * to be URI escaped. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + */ + public function URIEncodingBitmap(charsToEscape:String) : void + { + var i:int; + var data:ByteArray = new ByteArray(); + + // Initialize our 128 bits (16 bytes) to zero + for (i = 0; i < 16; i++) + this.writeByte(0); + + data.writeUTFBytes(charsToEscape); + data.position = 0; + + while (data.bytesAvailable) + { + var c:int = data.readByte(); + + if (c > 0x7f) + continue; // only escape low bytes + + var enc:int; + this.position = (c >> 3); + enc = this.readByte(); + enc |= 1 << (c & 0x7); + this.position = (c >> 3); + this.writeByte(enc); + } + } + + /** + * Based on the data table contained in this object, check + * if the given character should be escaped. + * + * @param char the character to be escaped. Only the first + * character in the string is used. Any other characters + * are ignored. + * + * @return the integer value of the raw UTF8 character. For + * example, if '%' is given, the return value is 37 (0x25). + * If the character given does not need to be escaped, the + * return value is zero. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + */ + public function ShouldEscape(char:String) : int + { + var data:ByteArray = new ByteArray(); + var c:int, mask:int; + + // write the character into a ByteArray so + // we can pull it out as a raw byte value. + data.writeUTFBytes(char); + data.position = 0; + c = data.readByte(); + + if (c & 0x80) + { + // don't escape high byte characters. It can make international + // URI's unreadable. We just want to escape characters that would + // make URI syntax ambiguous. + return 0; + } + else if ((c < 0x1f) || (c == 0x7f)) + { + // control characters must be escaped. + return c; + } + + this.position = (c >> 3); + mask = this.readByte(); + + if (mask & (1 << (c & 0x7))) + { + // we need to escape this, return the numeric value + // of the character + return c; + } + else + { + return 0; + } + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/proxies/RFC2817Socket.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/proxies/RFC2817Socket.as new file mode 100644 index 0000000000000000000000000000000000000000..c52ee39b606af8ddeea0d5dab6650ea4f9b759ea --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/net/proxies/RFC2817Socket.as @@ -0,0 +1,204 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +package com.adobe.net.proxies +{ + import flash.events.Event; + import flash.events.IOErrorEvent; + import flash.events.ProgressEvent; + import flash.net.Socket; + + /** + * This class allows TCP socket connections through HTTP proxies in accordance with + * RFC 2817: + * + * ftp://ftp.rfc-editor.org/in-notes/rfc2817.txt + * + * It can also be used to make direct connections to a destination, as well. If you + * pass the host and port into the constructor, no proxy will be used. You can also + * call connect, passing in the host and the port, and if you didn't set the proxy + * info, a direct connection will be made. A proxy is only used after you have called + * the setProxyInfo function. + * + * The connection to and negotiation with the proxy is completely hidden. All the + * same events are thrown whether you are using a proxy or not, and the data you + * receive from the target server will look exact as it would if you were connected + * to it directly rather than through a proxy. + * + * @author Christian Cantrell + * + **/ + public class RFC2817Socket + extends Socket + { + private var proxyHost:String = null; + private var host:String = null; + private var proxyPort:int = 0; + private var port:int = 0; + private var deferredEventHandlers:Object = new Object(); + private var buffer:String = new String(); + + /** + * Construct a new RFC2817Socket object. If you pass in the host and the port, + * no proxy will be used. If you want to use a proxy, instantiate with no + * arguments, call setProxyInfo, then call connect. + **/ + public function RFC2817Socket(host:String = null, port:int = 0) + { + if (host != null && port != 0) + { + super(host, port); + } + } + + /** + * Set the proxy host and port number. Your connection will only proxied if + * this function has been called. + **/ + public function setProxyInfo(host:String, port:int):void + { + this.proxyHost = host; + this.proxyPort = port; + + var deferredSocketDataHandler:Object = this.deferredEventHandlers[ProgressEvent.SOCKET_DATA]; + var deferredConnectHandler:Object = this.deferredEventHandlers[Event.CONNECT]; + + if (deferredSocketDataHandler != null) + { + super.removeEventListener(ProgressEvent.SOCKET_DATA, deferredSocketDataHandler.listener, deferredSocketDataHandler.useCapture); + } + + if (deferredConnectHandler != null) + { + super.removeEventListener(Event.CONNECT, deferredConnectHandler.listener, deferredConnectHandler.useCapture); + } + } + + /** + * Connect to the specified host over the specified port. If you want your + * connection proxied, call the setProxyInfo function first. + **/ + public override function connect(host:String, port:int):void + { + if (this.proxyHost == null) + { + this.redirectConnectEvent(); + this.redirectSocketDataEvent(); + super.connect(host, port); + } + else + { + this.host = host; + this.port = port; + super.addEventListener(Event.CONNECT, this.onConnect); + super.addEventListener(ProgressEvent.SOCKET_DATA, this.onSocketData); + super.connect(this.proxyHost, this.proxyPort); + } + } + + private function onConnect(event:Event):void + { + this.writeUTFBytes("CONNECT "+this.host+":"+this.port+" HTTP/1.1\n\n"); + this.flush(); + this.redirectConnectEvent(); + } + + private function onSocketData(event:ProgressEvent):void + { + while (this.bytesAvailable != 0) + { + this.buffer += this.readUTFBytes(1); + if (this.buffer.search(/\r?\n\r?\n$/) != -1) + { + this.checkResponse(event); + break; + } + } + } + + private function checkResponse(event:ProgressEvent):void + { + var responseCode:String = this.buffer.substr(this.buffer.indexOf(" ")+1, 3); + + if (responseCode.search(/^2/) == -1) + { + var ioError:IOErrorEvent = new IOErrorEvent(IOErrorEvent.IO_ERROR); + ioError.text = "Error connecting to the proxy ["+this.proxyHost+"] on port ["+this.proxyPort+"]: " + this.buffer; + this.dispatchEvent(ioError); + } + else + { + this.redirectSocketDataEvent(); + this.dispatchEvent(new Event(Event.CONNECT)); + if (this.bytesAvailable > 0) + { + this.dispatchEvent(event); + } + } + this.buffer = null; + } + + private function redirectConnectEvent():void + { + super.removeEventListener(Event.CONNECT, onConnect); + var deferredEventHandler:Object = this.deferredEventHandlers[Event.CONNECT]; + if (deferredEventHandler != null) + { + super.addEventListener(Event.CONNECT, deferredEventHandler.listener, deferredEventHandler.useCapture, deferredEventHandler.priority, deferredEventHandler.useWeakReference); + } + } + + private function redirectSocketDataEvent():void + { + super.removeEventListener(ProgressEvent.SOCKET_DATA, onSocketData); + var deferredEventHandler:Object = this.deferredEventHandlers[ProgressEvent.SOCKET_DATA]; + if (deferredEventHandler != null) + { + super.addEventListener(ProgressEvent.SOCKET_DATA, deferredEventHandler.listener, deferredEventHandler.useCapture, deferredEventHandler.priority, deferredEventHandler.useWeakReference); + } + } + + public override function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int=0.0, useWeakReference:Boolean=false):void + { + if (type == Event.CONNECT || type == ProgressEvent.SOCKET_DATA) + { + this.deferredEventHandlers[type] = {listener:listener,useCapture:useCapture, priority:priority, useWeakReference:useWeakReference}; + } + else + { + super.addEventListener(type, listener, useCapture, priority, useWeakReference); + } + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSON.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSON.as new file mode 100644 index 0000000000000000000000000000000000000000..1d2477e21e565d8113307424b979fbca16949b82 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSON.as @@ -0,0 +1,88 @@ +/* +Adobe Systems Incorporated(r) Source Code License Agreement +Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + +Please read this Source Code License Agreement carefully before using +the source code. + +Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable copyright license, to reproduce, +prepare derivative works of, publicly display, publicly perform, and +distribute this source code and such derivative works in source or +object code form without any attribution requirements. + +The name "Adobe Systems Incorporated" must not be used to endorse or promote products +derived from the source code without prior written permission. + +You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and +against any loss, damage, claims or lawsuits, including attorney's +fees that arise or result from your use or distribution of the source +code. + +THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT +ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF +NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA +OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.serialization.json { + + /** + * This class provides encoding and decoding of the JSON format. + * + * Example usage: + * <code> + * // create a JSON string from an internal object + * JSON.encode( myObject ); + * + * // read a JSON string into an internal object + * var myObject:Object = JSON.decode( jsonString ); + * </code> + */ + public class JSON { + + + /** + * Encodes a object into a JSON string. + * + * @param o The object to create a JSON string for + * @return the JSON string representing o + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function encode( o:Object ):String { + + var encoder:JSONEncoder = new JSONEncoder( o ); + return encoder.getString(); + + } + + /** + * Decodes a JSON string into a native object. + * + * @param s The JSON string representing the object + * @return A native object as specified by s + * @throw JSONParseError + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function decode( s:String ):* { + + var decoder:JSONDecoder = new JSONDecoder( s ) + return decoder.getValue(); + + } + + } + +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONDecoder.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONDecoder.as new file mode 100644 index 0000000000000000000000000000000000000000..ba35ebbccf0854fe909c0404b404426b6d65191d --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONDecoder.as @@ -0,0 +1,224 @@ +/* +Adobe Systems Incorporated(r) Source Code License Agreement +Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + +Please read this Source Code License Agreement carefully before using +the source code. + +Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable copyright license, to reproduce, +prepare derivative works of, publicly display, publicly perform, and +distribute this source code and such derivative works in source or +object code form without any attribution requirements. + +The name "Adobe Systems Incorporated" must not be used to endorse or promote products +derived from the source code without prior written permission. + +You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and +against any loss, damage, claims or lawsuits, including attorney's +fees that arise or result from your use or distribution of the source +code. + +THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT +ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF +NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA +OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.serialization.json { + + public class JSONDecoder { + + /** The value that will get parsed from the JSON string */ + private var value:*; + + /** The tokenizer designated to read the JSON string */ + private var tokenizer:JSONTokenizer; + + /** The current token from the tokenizer */ + private var token:JSONToken; + + /** + * Constructs a new JSONDecoder to parse a JSON string + * into a native object. + * + * @param s The JSON string to be converted + * into a native object + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public function JSONDecoder( s:String ) { + + tokenizer = new JSONTokenizer( s ); + + nextToken(); + value = parseValue(); + } + + /** + * Gets the internal object that was created by parsing + * the JSON string passed to the constructor. + * + * @return The internal object representation of the JSON + * string that was passed to the constructor + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public function getValue():* { + return value; + } + + /** + * Returns the next token from the tokenzier reading + * the JSON string + */ + private function nextToken():JSONToken { + return token = tokenizer.getNextToken(); + } + + /** + * Attempt to parse an array + */ + private function parseArray():Array { + // create an array internally that we're going to attempt + // to parse from the tokenizer + var a:Array = new Array(); + + // grab the next token from the tokenizer to move + // past the opening [ + nextToken(); + + // check to see if we have an empty array + if ( token.type == JSONTokenType.RIGHT_BRACKET ) { + // we're done reading the array, so return it + return a; + } + + // deal with elements of the array, and use an "infinite" + // loop because we could have any amount of elements + while ( true ) { + // read in the value and add it to the array + a.push ( parseValue() ); + + // after the value there should be a ] or a , + nextToken(); + + if ( token.type == JSONTokenType.RIGHT_BRACKET ) { + // we're done reading the array, so return it + return a; + } else if ( token.type == JSONTokenType.COMMA ) { + // move past the comma and read another value + nextToken(); + } else { + tokenizer.parseError( "Expecting ] or , but found " + token.value ); + } + } + return null; + } + + /** + * Attempt to parse an object + */ + private function parseObject():Object { + // create the object internally that we're going to + // attempt to parse from the tokenizer + var o:Object = new Object(); + + // store the string part of an object member so + // that we can assign it a value in the object + var key:String + + // grab the next token from the tokenizer + nextToken(); + + // check to see if we have an empty object + if ( token.type == JSONTokenType.RIGHT_BRACE ) { + // we're done reading the object, so return it + return o; + } + + // deal with members of the object, and use an "infinite" + // loop because we could have any amount of members + while ( true ) { + + if ( token.type == JSONTokenType.STRING ) { + // the string value we read is the key for the object + key = String( token.value ); + + // move past the string to see what's next + nextToken(); + + // after the string there should be a : + if ( token.type == JSONTokenType.COLON ) { + + // move past the : and read/assign a value for the key + nextToken(); + o[key] = parseValue(); + + // move past the value to see what's next + nextToken(); + + // after the value there's either a } or a , + if ( token.type == JSONTokenType.RIGHT_BRACE ) { + // // we're done reading the object, so return it + return o; + + } else if ( token.type == JSONTokenType.COMMA ) { + // skip past the comma and read another member + nextToken(); + } else { + tokenizer.parseError( "Expecting } or , but found " + token.value ); + } + } else { + tokenizer.parseError( "Expecting : but found " + token.value ); + } + } else { + tokenizer.parseError( "Expecting string but found " + token.value ); + } + } + return null; + } + + /** + * Attempt to parse a value + */ + private function parseValue():Object + { + // Catch errors when the input stream ends abruptly + if ( token == null ) + { + tokenizer.parseError( "Unexpected end of input" ); + } + + switch ( token.type ) { + case JSONTokenType.LEFT_BRACE: + return parseObject(); + + case JSONTokenType.LEFT_BRACKET: + return parseArray(); + + case JSONTokenType.STRING: + case JSONTokenType.NUMBER: + case JSONTokenType.TRUE: + case JSONTokenType.FALSE: + case JSONTokenType.NULL: + return token.value; + + default: + tokenizer.parseError( "Unexpected " + token.value ); + + } + return null; + } + } +} diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONEncoder.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONEncoder.as new file mode 100644 index 0000000000000000000000000000000000000000..7c40224953bdc6a770db0f82e0aa66e74d7f8732 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONEncoder.as @@ -0,0 +1,309 @@ +/* +Adobe Systems Incorporated(r) Source Code License Agreement +Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + +Please read this Source Code License Agreement carefully before using +the source code. + +Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable copyright license, to reproduce, +prepare derivative works of, publicly display, publicly perform, and +distribute this source code and such derivative works in source or +object code form without any attribution requirements. + +The name "Adobe Systems Incorporated" must not be used to endorse or promote products +derived from the source code without prior written permission. + +You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and +against any loss, damage, claims or lawsuits, including attorney's +fees that arise or result from your use or distribution of the source +code. + +THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT +ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF +NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA +OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.serialization.json { + import flash.utils.describeType; + + public class JSONEncoder { + + /** The string that is going to represent the object we're encoding */ + private var jsonString:String; + + /** + * Creates a new JSONEncoder. + * + * @param o The object to encode as a JSON string + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public function JSONEncoder( value:* ) { + jsonString = convertToString( value ); + + } + + /** + * Gets the JSON string from the encoder. + * + * @return The JSON string representation of the object + * that was passed to the constructor + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public function getString():String { + return jsonString; + } + + /** + * Converts a value to it's JSON string equivalent. + * + * @param value The value to convert. Could be any + * type (object, number, array, etc) + */ + private function convertToString( value:* ):String { + + // determine what value is and convert it based on it's type + if ( value is String ) { + // escape the string so it's formatted correctly + return escapeString( value as String ); + + } else if ( value is Number ) { + + // only encode numbers that finate + return isFinite( value as Number) ? value.toString() : "null"; + + } else if ( value is Boolean ) { + + // convert boolean to string easily + return value ? "true" : "false"; + + } else if ( value is Array ) { + + // call the helper method to convert an array + return arrayToString( value as Array ); + + } else if ( value is Object && value != null ) { + + // call the helper method to convert an object + return objectToString( value ); + } + return "null"; + } + + /** + * Escapes a string accoding to the JSON specification. + * + * @param str The string to be escaped + * @return The string with escaped special characters + * according to the JSON specification + */ + private function escapeString( str:String ):String { + // create a string to store the string's jsonstring value + var s:String = ""; + // current character in the string we're processing + var ch:String; + // store the length in a local variable to reduce lookups + var len:Number = str.length; + + // loop over all of the characters in the string + for ( var i:int = 0; i < len; i++ ) { + + // examine the character to determine if we have to escape it + ch = str.charAt( i ); + switch ( ch ) { + + case '"': // quotation mark + s += "\\\""; + break; + + //case '/': // solidus + // s += "\\/"; + // break; + + case '\\': // reverse solidus + s += "\\\\"; + break; + + case '\b': // bell + s += "\\b"; + break; + + case '\f': // form feed + s += "\\f"; + break; + + case '\n': // newline + s += "\\n"; + break; + + case '\r': // carriage return + s += "\\r"; + break; + + case '\t': // horizontal tab + s += "\\t"; + break; + + default: // everything else + + // check for a control character and escape as unicode + if ( ch < ' ' ) { + // get the hex digit(s) of the character (either 1 or 2 digits) + var hexCode:String = ch.charCodeAt( 0 ).toString( 16 ); + + // ensure that there are 4 digits by adjusting + // the # of zeros accordingly. + var zeroPad:String = hexCode.length == 2 ? "00" : "000"; + + // create the unicode escape sequence with 4 hex digits + s += "\\u" + zeroPad + hexCode; + } else { + + // no need to do any special encoding, just pass-through + s += ch; + + } + } // end switch + + } // end for loop + + return "\"" + s + "\""; + } + + /** + * Converts an array to it's JSON string equivalent + * + * @param a The array to convert + * @return The JSON string representation of <code>a</code> + */ + private function arrayToString( a:Array ):String { + // create a string to store the array's jsonstring value + var s:String = ""; + + // loop over the elements in the array and add their converted + // values to the string + for ( var i:int = 0; i < a.length; i++ ) { + // when the length is 0 we're adding the first element so + // no comma is necessary + if ( s.length > 0 ) { + // we've already added an element, so add the comma separator + s += "," + } + + // convert the value to a string + s += convertToString( a[i] ); + } + + // KNOWN ISSUE: In ActionScript, Arrays can also be associative + // objects and you can put anything in them, ie: + // myArray["foo"] = "bar"; + // + // These properties aren't picked up in the for loop above because + // the properties don't correspond to indexes. However, we're + // sort of out luck because the JSON specification doesn't allow + // these types of array properties. + // + // So, if the array was also used as an associative object, there + // may be some values in the array that don't get properly encoded. + // + // A possible solution is to instead encode the Array as an Object + // but then it won't get decoded correctly (and won't be an + // Array instance) + + // close the array and return it's string value + return "[" + s + "]"; + } + + /** + * Converts an object to it's JSON string equivalent + * + * @param o The object to convert + * @return The JSON string representation of <code>o</code> + */ + private function objectToString( o:Object ):String + { + // create a string to store the object's jsonstring value + var s:String = ""; + + + // determine if o is a class instance or a plain object + var classInfo:XML = describeType( o ); + + if ( classInfo.@name.toString() == "Object" ) + { + // the value of o[key] in the loop below - store this + // as a variable so we don't have to keep looking up o[key] + // when testing for valid values to convert + var value:Object; + + // loop over the keys in the object and add their converted + // values to the string + for ( var key:String in o ) + { + // assign value to a variable for quick lookup + value = o[key]; + + // don't add function's to the JSON string + if ( value is Function ) + { + // skip this key and try another + continue; + } + + // Modified by api, skip nulls + if (value == null) { + continue; + } + + // when the length is 0 we're adding the first item so + // no comma is necessary + if ( s.length > 0 ) { + // we've already added an item, so add the comma separator + s += ","; + } + + s += escapeString( key ) + ":" + convertToString( value ); + } + } + else // o is a class instance + { + // Loop over all of the variables and accessors in the class and + // serialize them along with their values. + var exposed:XMLList = classInfo.*.(hasOwnProperty("metadata") && metadata.@name=="Value"); + for each (var v:XML in exposed) { +// log.debug("metadata " + exposed.metadata); +// for each ( var v:XML in exposed..*.( name() == "variable" || name() == "accessor" ) ) { + if (o[ v.@name ] != null) { + // When the length is 0 we're adding the first item so + // no comma is necessary + if ( s.length > 0 ) { + // We've already added an item, so add the comma separator + s += "," + } + s += (v.metadata.arg.@key == "name" ? v.metadata.arg.@value : escapeString(v.@name.toString())) + ":" + + convertToString( o[ v.@name ] ); + } + } + + } + + return "{" + s + "}"; + } + + + } + +} diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONParseError.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONParseError.as new file mode 100644 index 0000000000000000000000000000000000000000..b8c0ecfadde71169ee68d78f31be8dd4fb96468b --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONParseError.as @@ -0,0 +1,90 @@ +/* +Adobe Systems Incorporated(r) Source Code License Agreement +Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + +Please read this Source Code License Agreement carefully before using +the source code. + +Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable copyright license, to reproduce, +prepare derivative works of, publicly display, publicly perform, and +distribute this source code and such derivative works in source or +object code form without any attribution requirements. + +The name "Adobe Systems Incorporated" must not be used to endorse or promote products +derived from the source code without prior written permission. + +You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and +against any loss, damage, claims or lawsuits, including attorney's +fees that arise or result from your use or distribution of the source +code. + +THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT +ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF +NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA +OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.serialization.json { + + /** + * + * + */ + public class JSONParseError extends Error { + + /** The location in the string where the error occurred */ + private var _location:int; + + /** The string in which the parse error occurred */ + private var _text:String; + + /** + * Constructs a new JSONParseError. + * + * @param message The error message that occured during parsing + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public function JSONParseError( message:String = "", location:int = 0, text:String = "") { + super( message ); + //name = "JSONParseError"; + _location = location; + _text = text; + } + + /** + * Provides read-only access to the location variable. + * + * @return The location in the string where the error occurred + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public function get location():int { + return _location; + } + + /** + * Provides read-only access to the text variable. + * + * @return The string in which the error occurred + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public function get text():String { + return _text; + } + } + +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONToken.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONToken.as new file mode 100644 index 0000000000000000000000000000000000000000..51e3714958577384cb3ad9609d2ef8c57fa00076 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONToken.as @@ -0,0 +1,107 @@ +/* +Adobe Systems Incorporated(r) Source Code License Agreement +Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + +Please read this Source Code License Agreement carefully before using +the source code. + +Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable copyright license, to reproduce, +prepare derivative works of, publicly display, publicly perform, and +distribute this source code and such derivative works in source or +object code form without any attribution requirements. + +The name "Adobe Systems Incorporated" must not be used to endorse or promote products +derived from the source code without prior written permission. + +You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and +against any loss, damage, claims or lawsuits, including attorney's +fees that arise or result from your use or distribution of the source +code. + +THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT +ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF +NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA +OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.serialization.json { + + public class JSONToken { + + private var _type:int; + private var _value:Object; + + /** + * Creates a new JSONToken with a specific token type and value. + * + * @param type The JSONTokenType of the token + * @param value The value of the token + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public function JSONToken( type:int = -1 /* JSONTokenType.UNKNOWN */, value:Object = null ) { + _type = type; + _value = value; + } + + /** + * Returns the type of the token. + * + * @see com.adobe.serialization.json.JSONTokenType + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public function get type():int { + return _type; + } + + /** + * Sets the type of the token. + * + * @see com.adobe.serialization.json.JSONTokenType + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public function set type( value:int ):void { + _type = value; + } + + /** + * Gets the value of the token + * + * @see com.adobe.serialization.json.JSONTokenType + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public function get value():Object { + return _value; + } + + /** + * Sets the value of the token + * + * @see com.adobe.serialization.json.JSONTokenType + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public function set value ( v:Object ):void { + _value = v; + } + + } + +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONTokenType.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONTokenType.as new file mode 100644 index 0000000000000000000000000000000000000000..398a0f47f8f62bc192e52464cc291868ba642edc --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONTokenType.as @@ -0,0 +1,70 @@ +/* +Adobe Systems Incorporated(r) Source Code License Agreement +Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + +Please read this Source Code License Agreement carefully before using +the source code. + +Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable copyright license, to reproduce, +prepare derivative works of, publicly display, publicly perform, and +distribute this source code and such derivative works in source or +object code form without any attribution requirements. + +The name "Adobe Systems Incorporated" must not be used to endorse or promote products +derived from the source code without prior written permission. + +You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and +against any loss, damage, claims or lawsuits, including attorney's +fees that arise or result from your use or distribution of the source +code. + +THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT +ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF +NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA +OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.serialization.json { + + /** + * Class containing constant values for the different types + * of tokens in a JSON encoded string. + */ + public class JSONTokenType { + + public static const UNKNOWN:int = -1; + + public static const COMMA:int = 0; + + public static const LEFT_BRACE:int = 1; + + public static const RIGHT_BRACE:int = 2; + + public static const LEFT_BRACKET:int = 3; + + public static const RIGHT_BRACKET:int = 4; + + public static const COLON:int = 6; + + public static const TRUE:int = 7; + + public static const FALSE:int = 8; + + public static const NULL:int = 9; + + public static const STRING:int = 10; + + public static const NUMBER:int = 11; + + } + +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONTokenizer.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONTokenizer.as new file mode 100644 index 0000000000000000000000000000000000000000..2bfe0550980984cfe976e3bf868d6f98a98607f8 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/serialization/json/JSONTokenizer.as @@ -0,0 +1,558 @@ +/* +Adobe Systems Incorporated(r) Source Code License Agreement +Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + +Please read this Source Code License Agreement carefully before using +the source code. + +Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, +no-charge, royalty-free, irrevocable copyright license, to reproduce, +prepare derivative works of, publicly display, publicly perform, and +distribute this source code and such derivative works in source or +object code form without any attribution requirements. + +The name "Adobe Systems Incorporated" must not be used to endorse or promote products +derived from the source code without prior written permission. + +You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and +against any loss, damage, claims or lawsuits, including attorney's +fees that arise or result from your use or distribution of the source +code. + +THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT +ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF +NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA +OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.serialization.json { + + public class JSONTokenizer { + + /** The object that will get parsed from the JSON string */ + private var obj:Object; + + /** The JSON string to be parsed */ + private var jsonString:String; + + /** The current parsing location in the JSON string */ + private var loc:int; + + /** The current character in the JSON string during parsing */ + private var ch:String; + + /** + * Constructs a new JSONDecoder to parse a JSON string + * into a native object. + * + * @param s The JSON string to be converted + * into a native object + */ + public function JSONTokenizer( s:String ) { + jsonString = s; + loc = 0; + + // prime the pump by getting the first character + nextChar(); + } + + /** + * Gets the next token in the input sting and advances + * the character to the next character after the token + */ + public function getNextToken():JSONToken { + var token:JSONToken = new JSONToken(); + + // skip any whitespace / comments since the last + // token was read + skipIgnored(); + + // examine the new character and see what we have... + switch ( ch ) { + + case '{': + token.type = JSONTokenType.LEFT_BRACE; + token.value = '{'; + nextChar(); + break + + case '}': + token.type = JSONTokenType.RIGHT_BRACE; + token.value = '}'; + nextChar(); + break + + case '[': + token.type = JSONTokenType.LEFT_BRACKET; + token.value = '['; + nextChar(); + break + + case ']': + token.type = JSONTokenType.RIGHT_BRACKET; + token.value = ']'; + nextChar(); + break + + case ',': + token.type = JSONTokenType.COMMA; + token.value = ','; + nextChar(); + break + + case ':': + token.type = JSONTokenType.COLON; + token.value = ':'; + nextChar(); + break; + + case 't': // attempt to read true + var possibleTrue:String = "t" + nextChar() + nextChar() + nextChar(); + + if ( possibleTrue == "true" ) { + token.type = JSONTokenType.TRUE; + token.value = true; + nextChar(); + } else { + parseError( "Expecting 'true' but found " + possibleTrue ); + } + + break; + + case 'f': // attempt to read false + var possibleFalse:String = "f" + nextChar() + nextChar() + nextChar() + nextChar(); + + if ( possibleFalse == "false" ) { + token.type = JSONTokenType.FALSE; + token.value = false; + nextChar(); + } else { + parseError( "Expecting 'false' but found " + possibleFalse ); + } + + break; + + case 'n': // attempt to read null + + var possibleNull:String = "n" + nextChar() + nextChar() + nextChar(); + + if ( possibleNull == "null" ) { + token.type = JSONTokenType.NULL; + token.value = null; + nextChar(); + } else { + parseError( "Expecting 'null' but found " + possibleNull ); + } + + break; + + case '"': // the start of a string + token = readString(); + break; + + case "'": // the start of a string + token = readString(); + break; + + default: + // see if we can read a number + if ( isDigit( ch ) || ch == '-' ) { + token = readNumber(); + } else if ( ch == '' ) { + // check for reading past the end of the string + return null; + } else { + // not sure what was in the input string - it's not + // anything we expected + parseError( "Unexpected " + ch + " encountered" ); + } + } + + return token; + } + + /** + * Attempts to read a string from the input string. Places + * the character location at the first character after the + * string. It is assumed that ch is " before this method is called. + * + * @return the JSONToken with the string value if a string could + * be read. Throws an error otherwise. + */ + private function readString():JSONToken { + // the token for the string we'll try to read + var token:JSONToken = new JSONToken(); + token.type = JSONTokenType.STRING; + + // the string to store the string we'll try to read + var string:String = ""; + + // advance past the first " + nextChar(); + + while ( ch != '"' && ch != "'" && ch != '' ) { + + // unescape the escape sequences in the string + if ( ch == '\\' ) { + + // get the next character so we know what + // to unescape + nextChar(); + + switch ( ch ) { + + case '"': // quotation mark + string += '"'; + break; + + case "'": + string += "'"; + break; + + case '/': // solidus + string += "/"; + break; + + case '\\': // reverse solidus + string += '\\'; + break; + + case 'b': // bell + string += '\b'; + break; + + case 'f': // form feed + string += '\f'; + break; + + case 'n': // newline + string += '\n'; + break; + + case 'r': // carriage return + string += '\r'; + break; + + case 't': // horizontal tab + string += '\t' + break; + + case 'u': + // convert a unicode escape sequence + // to it's character value - expecting + // 4 hex digits + + // save the characters as a string we'll convert to an int + var hexValue:String = ""; + + // try to find 4 hex characters + for ( var i:int = 0; i < 4; i++ ) { + // get the next character and determine + // if it's a valid hex digit or not + if ( !isHexDigit( nextChar() ) ) { + parseError( " Excepted a hex digit, but found: " + ch ); + } + // valid, add it to the value + hexValue += ch; + } + + // convert hexValue to an integer, and use that + // integrer value to create a character to add + // to our string. + string += String.fromCharCode( parseInt( hexValue, 16 ) ); + + break; + + default: + // couldn't unescape the sequence, so just + // pass it through + string += '\\' + ch; + + } + + } else { + // didn't have to unescape, so add the character to the string + string += ch; + + } + + // move to the next character + nextChar(); + + } + + // we read past the end of the string without closing it, which + // is a parse error + if ( ch == '' ) { + parseError( "Unterminated string literal" ); + } + + // move past the closing " in the input string + nextChar(); + + // attach to the string to the token so we can return it + token.value = string; + + return token; + } + + /** + * Attempts to read a number from the input string. Places + * the character location at the first character after the + * number. + * + * @return The JSONToken with the number value if a number could + * be read. Throws an error otherwise. + */ + private function readNumber():JSONToken { + // the token for the number we'll try to read + var token:JSONToken = new JSONToken(); + token.type = JSONTokenType.NUMBER; + + // the string to accumulate the number characters + // into that we'll convert to a number at the end + var input:String = ""; + + // check for a negative number + if ( ch == '-' ) { + input += '-'; + nextChar(); + } + + // the number must start with a digit + if ( !isDigit( ch ) ) + { + parseError( "Expecting a digit" ); + } + + // 0 can only be the first digit if it + // is followed by a decimal point + if ( ch == '0' ) + { + input += ch; + nextChar(); + + // make sure no other digits come after 0 + if ( isDigit( ch ) ) + { + parseError( "A digit cannot immediately follow 0" ); + } + } + else + { + // read numbers while we can + while ( isDigit( ch ) ) { + input += ch; + nextChar(); + } + } + + // check for a decimal value + if ( ch == '.' ) { + input += '.'; + nextChar(); + + // after the decimal there has to be a digit + if ( !isDigit( ch ) ) + { + parseError( "Expecting a digit" ); + } + + // read more numbers to get the decimal value + while ( isDigit( ch ) ) { + input += ch; + nextChar(); + } + } + + // check for scientific notation + if ( ch == 'e' || ch == 'E' ) + { + input += "e" + nextChar(); + // check for sign + if ( ch == '+' || ch == '-' ) + { + input += ch; + nextChar(); + } + + // require at least one number for the exponent + // in this case + if ( !isDigit( ch ) ) + { + parseError( "Scientific notation number needs exponent value" ); + } + + // read in the exponent + while ( isDigit( ch ) ) + { + input += ch; + nextChar(); + } + } + + // convert the string to a number value + var num:Number = Number( input ); + + if ( isFinite( num ) && !isNaN( num ) ) { + token.value = num; + return token; + } else { + parseError( "Number " + num + " is not valid!" ); + } + return null; + } + + /** + * Reads the next character in the input + * string and advances the character location. + * + * @return The next character in the input string, or + * null if we've read past the end. + */ + private function nextChar():String { + return ch = jsonString.charAt( loc++ ); + } + + /** + * Advances the character location past any + * sort of white space and comments + */ + private function skipIgnored():void { + skipWhite(); + skipComments(); + skipWhite(); + } + + /** + * Skips comments in the input string, either + * single-line or multi-line. Advances the character + * to the first position after the end of the comment. + */ + private function skipComments():void { + if ( ch == '/' ) { + // Advance past the first / to find out what type of comment + nextChar(); + switch ( ch ) { + case '/': // single-line comment, read through end of line + + // Loop over the characters until we find + // a newline or until there's no more characters left + do { + nextChar(); + } while ( ch != '\n' && ch != '' ) + + // move past the \n + nextChar(); + + break; + + case '*': // multi-line comment, read until closing */ + + // move past the opening * + nextChar(); + + // try to find a trailing */ + while ( true ) { + if ( ch == '*' ) { + // check to see if we have a closing / + nextChar(); + if ( ch == '/') { + // move past the end of the closing */ + nextChar(); + break; + } + } else { + // move along, looking if the next character is a * + nextChar(); + } + + // when we're here we've read past the end of + // the string without finding a closing */, so error + if ( ch == '' ) { + parseError( "Multi-line comment not closed" ); + } + } + + break; + + // Can't match a comment after a /, so it's a parsing error + default: + parseError( "Unexpected " + ch + " encountered (expecting '/' or '*' )" ); + } + } + + } + + + /** + * Skip any whitespace in the input string and advances + * the character to the first character after any possible + * whitespace. + */ + private function skipWhite():void { + + // As long as there are spaces in the input + // stream, advance the current location pointer + // past them + while ( isWhiteSpace( ch ) ) { + nextChar(); + } + + } + + /** + * Determines if a character is whitespace or not. + * + * @return True if the character passed in is a whitespace + * character + */ + private function isWhiteSpace( ch:String ):Boolean { + return ( ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r' ); + } + + /** + * Determines if a character is a digit [0-9]. + * + * @return True if the character passed in is a digit + */ + private function isDigit( ch:String ):Boolean { + return ( ch >= '0' && ch <= '9' ); + } + + /** + * Determines if a character is a digit [0-9]. + * + * @return True if the character passed in is a digit + */ + private function isHexDigit( ch:String ):Boolean { + // get the uppercase value of ch so we only have + // to compare the value between 'A' and 'F' + var uc:String = ch.toUpperCase(); + + // a hex digit is a digit of A-F, inclusive ( using + // our uppercase constraint ) + return ( isDigit( ch ) || ( uc >= 'A' && uc <= 'F' ) ); + } + + /** + * Raises a parsing error with a specified message, tacking + * on the error location and the original string. + * + * @param message The message indicating why the error occurred + */ + public function parseError( message:String ):void { + throw new JSONParseError( message, loc, jsonString ); + } + } + +} diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/ArrayUtil.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/ArrayUtil.as new file mode 100644 index 0000000000000000000000000000000000000000..c53560291234b3b0dcd54a3a8f87e4cc223d8168 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/ArrayUtil.as @@ -0,0 +1,190 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.utils +{ + + /** + * Class that contains static utility methods for manipulating and working + * with Arrays. + * + * Note that all APIs assume that they are working with well formed arrays. + * i.e. they will only manipulate indexed values. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public class ArrayUtil + { + + /** + * Determines whether the specified array contains the specified value. + * + * @param arr The array that will be checked for the specified value. + * + * @param value The object which will be searched for within the array + * + * @return True if the array contains the value, False if it does not. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function arrayContainsValue(arr:Array, value:Object):Boolean + { + return (arr.indexOf(value) != -1); + } + + /** + * Remove all instances of the specified value from the array, + * + * @param arr The array from which the value will be removed + * + * @param value The object that will be removed from the array. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function removeValueFromArray(arr:Array, value:Object):void + { + var len:uint = arr.length; + + for(var i:Number = len; i > -1; i--) + { + if(arr[i] === value) + { + arr.splice(i, 1); + } + } + } + + /** + * Create a new array that only contains unique instances of objects + * in the specified array. + * + * Basically, this can be used to remove duplication object instances + * from an array + * + * @param arr The array which contains the values that will be used to + * create the new array that contains no duplicate values. + * + * @return A new array which only contains unique items from the specified + * array. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function createUniqueCopy(a:Array):Array + { + var newArray:Array = new Array(); + + var len:Number = a.length; + var item:Object; + + for (var i:uint = 0; i < len; ++i) + { + item = a[i]; + + if(ArrayUtil.arrayContainsValue(newArray, item)) + { + continue; + } + + newArray.push(item); + } + + return newArray; + } + + /** + * Creates a copy of the specified array. + * + * Note that the array returned is a new array but the items within the + * array are not copies of the items in the original array (but rather + * references to the same items) + * + * @param arr The array that will be copies + * + * @return A new array which contains the same items as the array passed + * in. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function copyArray(arr:Array):Array + { + return arr.slice(); + } + + /** + * Compares two arrays and returns a boolean indicating whether the arrays + * contain the same values at the same indexes. + * + * @param arr1 The first array that will be compared to the second. + * + * @param arr2 The second array that will be compared to the first. + * + * @return True if the arrays contains the same values at the same indexes. + False if they do not. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function arraysAreEqual(arr1:Array, arr2:Array):Boolean + { + if(arr1.length != arr2.length) + { + return false; + } + + var len:Number = arr1.length; + + for(var i:Number = 0; i < len; i++) + { + if(arr1[i] !== arr2[i]) + { + return false; + } + } + + return true; + } + } +} diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/DateUtil.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/DateUtil.as new file mode 100644 index 0000000000000000000000000000000000000000..5d5d792d69065939fe489a995e04c5f95b69e41a --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/DateUtil.as @@ -0,0 +1,702 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.utils +{ + import mx.formatters.DateBase; + + /** + * Class that contains static utility methods for manipulating and working + * with Dates. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public class DateUtil + { + + /** + * Returns the English Short Month name (3 letters) for the Month that + * the Date represents. + * + * @param d The Date instance whose month will be used to retrieve the + * short month name. + * + * @return An English 3 Letter Month abbreviation. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see SHORT_MONTH + */ + public static function getShortMonthName(d:Date):String + { + return DateBase.monthNamesShort[d.getMonth()]; + } + + /** + * Returns the index of the month that the short month name string + * represents. + * + * @param m The 3 letter abbreviation representing a short month name. + * + * @param Optional parameter indicating whether the search should be case + * sensitive + * + * @return A int that represents that month represented by the specifed + * short name. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see SHORT_MONTH + */ + public static function getShortMonthIndex(m:String):int + { + return DateBase.monthNamesShort.indexOf(m); + } + + /** + * Returns the English full Month name for the Month that + * the Date represents. + * + * @param d The Date instance whose month will be used to retrieve the + * full month name. + * + * @return An English full month name. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see FULL_MONTH + */ + public static function getFullMonthName(d:Date):String + { + return DateBase.monthNamesLong[d.getMonth()]; + } + + /** + * Returns the index of the month that the full month name string + * represents. + * + * @param m A full month name. + * + * @return A int that represents that month represented by the specifed + * full month name. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see FULL_MONTH + */ + public static function getFullMonthIndex(m:String):int + { + return DateBase.monthNamesLong.indexOf(m); + } + + /** + * Returns the English Short Day name (3 letters) for the day that + * the Date represents. + * + * @param d The Date instance whose day will be used to retrieve the + * short day name. + * + * @return An English 3 Letter day abbreviation. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see SHORT_DAY + */ + public static function getShortDayName(d:Date):String + { + return DateBase.dayNamesShort[d.getDay()]; + } + + /** + * Returns the index of the day that the short day name string + * represents. + * + * @param m A short day name. + * + * @return A int that represents that short day represented by the specifed + * full month name. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see SHORT_DAY + */ + public static function getShortDayIndex(d:String):int + { + return DateBase.dayNamesShort.indexOf(d); + } + + /** + * Returns the English full day name for the day that + * the Date represents. + * + * @param d The Date instance whose day will be used to retrieve the + * full day name. + * + * @return An English full day name. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see FULL_DAY + */ + public static function getFullDayName(d:Date):String + { + return DateBase.dayNamesLong[d.getDay()]; + } + + /** + * Returns the index of the day that the full day name string + * represents. + * + * @param m A full day name. + * + * @return A int that represents that full day represented by the specifed + * full month name. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see FULL_DAY + */ + public static function getFullDayIndex(d:String):int + { + return DateBase.dayNamesLong.indexOf(d); + } + + /** + * Returns a two digit representation of the year represented by the + * specified date. + * + * @param d The Date instance whose year will be used to generate a two + * digit string representation of the year. + * + * @return A string that contains a 2 digit representation of the year. + * Single digits will be padded with 0. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function getShortYear(d:Date):String + { + var dStr:String = String(d.getFullYear()); + + if(dStr.length < 3) + { + return dStr; + } + + return (dStr.substr(dStr.length - 2)); + } + + /** + * Compares two dates and returns an integer depending on their relationship. + * + * Returns -1 if d1 is greater than d2. + * Returns 1 if d2 is greater than d1. + * Returns 0 if both dates are equal. + * + * @param d1 The date that will be compared to the second date. + * @param d2 The date that will be compared to the first date. + * + * @return An int indicating how the two dates compare. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function compareDates(d1:Date, d2:Date):int + { + var d1ms:Number = d1.getTime(); + var d2ms:Number = d2.getTime(); + + if(d1ms > d2ms) + { + return -1; + } + else if(d1ms < d2ms) + { + return 1; + } + else + { + return 0; + } + } + + /** + * Returns a short hour (0 - 12) represented by the specified date. + * + * If the hour is less than 12 (0 - 11 AM) then the hour will be returned. + * + * If the hour is greater than 12 (12 - 23 PM) then the hour minus 12 + * will be returned. + * + * @param d1 The Date from which to generate the short hour + * + * @return An int between 0 and 13 ( 1 - 12 ) representing the short hour. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function getShortHour(d:Date):int + { + var h:int = d.hours; + + if(h == 0 || h == 12) + { + return 12; + } + else if(h > 12) + { + return h - 12; + } + else + { + return h; + } + } + + /** + * Returns a string indicating whether the date represents a time in the + * ante meridiem (AM) or post meridiem (PM). + * + * If the hour is less than 12 then "AM" will be returned. + * + * If the hour is greater than 12 then "PM" will be returned. + * + * @param d1 The Date from which to generate the 12 hour clock indicator. + * + * @return A String ("AM" or "PM") indicating which half of the day the + * hour represents. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function getAMPM(d:Date):String + { + return (d.hours > 11)? "PM" : "AM"; + } + + /** + * Parses dates that conform to RFC822 into Date objects. This method also + * supports four-digit years (not supported in RFC822), but two-digit years + * (referring to the 20th century) are fine, too. + * + * This function is useful for parsing RSS .91, .92, and 2.0 dates. + * + * @param str + * + * @returns + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see http://asg.web.cmu.edu/rfc/rfc822.html + */ + public static function parseRFC822(str:String):Date + { + var finalDate:Date; + try + { + var dateParts:Array = str.split(" "); + var day:String = null; + + if (dateParts[0].search(/\d/) == -1) + { + day = dateParts.shift().replace(/\W/, ""); + } + + var date:Number = Number(dateParts.shift()); + var month:Number = Number(DateUtil.getShortMonthIndex(dateParts.shift())); + var year:Number = Number(dateParts.shift()); + var timeParts:Array = dateParts.shift().split(":"); + var hour:Number = int(timeParts.shift()); + var minute:Number = int(timeParts.shift()); + var second:Number = (timeParts.length > 0) ? int(timeParts.shift()): 0; + + var milliseconds:Number = Date.UTC(year, month, date, hour, minute, second, 0); + + var timezone:String = dateParts.shift(); + var offset:Number = 0; + + if (timezone.search(/\d/) == -1) + { + switch(timezone) + { + case "UT": + offset = 0; + break; + case "UTC": + offset = 0; + break; + case "GMT": + offset = 0; + break; + case "EST": + offset = (-5 * 3600000); + break; + case "EDT": + offset = (-4 * 3600000); + break; + case "CST": + offset = (-6 * 3600000); + break; + case "CDT": + offset = (-5 * 3600000); + break; + case "MST": + offset = (-7 * 3600000); + break; + case "MDT": + offset = (-6 * 3600000); + break; + case "PST": + offset = (-8 * 3600000); + break; + case "PDT": + offset = (-7 * 3600000); + break; + case "Z": + offset = 0; + break; + case "A": + offset = (-1 * 3600000); + break; + case "M": + offset = (-12 * 3600000); + break; + case "N": + offset = (1 * 3600000); + break; + case "Y": + offset = (12 * 3600000); + break; + default: + offset = 0; + } + } + else + { + var multiplier:Number = 1; + var oHours:Number = 0; + var oMinutes:Number = 0; + if (timezone.length != 4) + { + if (timezone.charAt(0) == "-") + { + multiplier = -1; + } + timezone = timezone.substr(1, 4); + } + oHours = Number(timezone.substr(0, 2)); + oMinutes = Number(timezone.substr(2, 2)); + offset = (((oHours * 3600000) + (oMinutes * 60000)) * multiplier); + } + + finalDate = new Date(milliseconds - offset); + + if (finalDate.toString() == "Invalid Date") + { + throw new Error("This date does not conform to RFC822."); + } + } + catch (e:Error) + { + var eStr:String = "Unable to parse the string [" +str+ "] into a date. "; + eStr += "The internal error was: " + e.toString(); + throw new Error(eStr); + } + return finalDate; + } + + /** + * Returns a date string formatted according to RFC822. + * + * @param d + * + * @returns + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see http://asg.web.cmu.edu/rfc/rfc822.html + */ + public static function toRFC822(d:Date):String + { + var date:Number = d.getUTCDate(); + var hours:Number = d.getUTCHours(); + var minutes:Number = d.getUTCMinutes(); + var seconds:Number = d.getUTCSeconds(); + var sb:String = new String(); + sb += DateBase.dayNamesShort[d.getUTCDay()]; + sb += ", "; + + if (date < 10) + { + sb += "0"; + } + sb += date; + sb += " "; + //sb += DateUtil.SHORT_MONTH[d.getUTCMonth()]; + sb += DateBase.monthNamesShort[d.getUTCMonth()]; + sb += " "; + sb += d.getUTCFullYear(); + sb += " "; + if (hours < 10) + { + sb += "0"; + } + sb += hours; + sb += ":"; + if (minutes < 10) + { + sb += "0"; + } + sb += minutes; + sb += ":"; + if (seconds < 10) + { + sb += "0"; + } + sb += seconds; + sb += " GMT"; + return sb; + } + + /** + * Parses dates that conform to the W3C Date-time Format into Date objects. + * + * This function is useful for parsing RSS 1.0 and Atom 1.0 dates. + * + * @param str + * + * @returns + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see http://www.w3.org/TR/NOTE-datetime + */ + public static function parseW3CDTF(str:String):Date + { + var finalDate:Date; + try + { + var dateStr:String = str.substring(0, str.indexOf("T")); + var timeStr:String = str.substring(str.indexOf("T")+1, str.length); + var dateArr:Array = dateStr.split("-"); + var year:Number = Number(dateArr.shift()); + var month:Number = Number(dateArr.shift()); + var date:Number = Number(dateArr.shift()); + + var multiplier:Number; + var offsetHours:Number; + var offsetMinutes:Number; + var offsetStr:String; + + if (timeStr.indexOf("Z") != -1) + { + multiplier = 1; + offsetHours = 0; + offsetMinutes = 0; + timeStr = timeStr.replace("Z", ""); + } + else if (timeStr.indexOf("+") != -1) + { + multiplier = 1; + offsetStr = timeStr.substring(timeStr.indexOf("+")+1, timeStr.length); + offsetHours = Number(offsetStr.substring(0, offsetStr.indexOf(":"))); + offsetMinutes = Number(offsetStr.substring(offsetStr.indexOf(":")+1, offsetStr.length)); + timeStr = timeStr.substring(0, timeStr.indexOf("+")); + } + else // offset is - + { + multiplier = -1; + offsetStr = timeStr.substring(timeStr.indexOf("-")+1, timeStr.length); + offsetHours = Number(offsetStr.substring(0, offsetStr.indexOf(":"))); + offsetMinutes = Number(offsetStr.substring(offsetStr.indexOf(":")+1, offsetStr.length)); + timeStr = timeStr.substring(0, timeStr.indexOf("-")); + } + var timeArr:Array = timeStr.split(":"); + var hour:Number = Number(timeArr.shift()); + var minutes:Number = Number(timeArr.shift()); + var secondsArr:Array = (timeArr.length > 0) ? String(timeArr.shift()).split(".") : null; + var seconds:Number = (secondsArr != null && secondsArr.length > 0) ? Number(secondsArr.shift()) : 0; + var milliseconds:Number = (secondsArr != null && secondsArr.length > 0) ? Number(secondsArr.shift()) : 0; + var utc:Number = Date.UTC(year, month-1, date, hour, minutes, seconds, milliseconds); + var offset:Number = (((offsetHours * 3600000) + (offsetMinutes * 60000)) * multiplier); + finalDate = new Date(utc - offset); + + if (finalDate.toString() == "Invalid Date") + { + throw new Error("This date does not conform to W3CDTF."); + } + } + catch (e:Error) + { + var eStr:String = "Unable to parse the string [" +str+ "] into a date. "; + eStr += "The internal error was: " + e.toString(); + throw new Error(eStr); + } + return finalDate; + } + + /** + * Returns a date string formatted according to W3CDTF. + * + * @param d + * @param includeMilliseconds Determines whether to include the + * milliseconds value (if any) in the formatted string. + * + * @returns + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see http://www.w3.org/TR/NOTE-datetime + */ + public static function toW3CDTF(d:Date,includeMilliseconds:Boolean=false):String + { + var date:Number = d.getUTCDate(); + var month:Number = d.getUTCMonth(); + var hours:Number = d.getUTCHours(); + var minutes:Number = d.getUTCMinutes(); + var seconds:Number = d.getUTCSeconds(); + var milliseconds:Number = d.getUTCMilliseconds(); + var sb:String = new String(); + + sb += d.getUTCFullYear(); + sb += "-"; + + //thanks to "dom" who sent in a fix for the line below + if (month + 1 < 10) + { + sb += "0"; + } + sb += month + 1; + sb += "-"; + if (date < 10) + { + sb += "0"; + } + sb += date; + sb += "T"; + if (hours < 10) + { + sb += "0"; + } + sb += hours; + sb += ":"; + if (minutes < 10) + { + sb += "0"; + } + sb += minutes; + sb += ":"; + if (seconds < 10) + { + sb += "0"; + } + sb += seconds; + if (includeMilliseconds && milliseconds > 0) + { + sb += "."; + sb += milliseconds; + } + sb += "-00:00"; + return sb; + } + + /** + * Converts a date into just after midnight. + */ + public static function makeMorning(d:Date):Date + { + var d:Date = new Date(d.time); + d.hours = 0; + d.minutes = 0; + d.seconds = 0; + d.milliseconds = 0; + return d; + } + + /** + * Converts a date into just befor midnight. + */ + public static function makeNight(d:Date):Date + { + var d:Date = new Date(d.time); + d.hours = 23; + d.minutes = 59; + d.seconds = 59; + d.milliseconds = 999; + return d; + } + + /** + * Sort of converts a date into UTC. + */ + public static function getUTCDate(d:Date):Date + { + var nd:Date = new Date(); + var offset:Number = d.getTimezoneOffset() * 60 * 1000; + nd.setTime(d.getTime() + offset); + return nd; + } + } +} diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/DictionaryUtil.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/DictionaryUtil.as new file mode 100644 index 0000000000000000000000000000000000000000..4c71c0696122ef0f2b9b21db688c4a424776707e --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/DictionaryUtil.as @@ -0,0 +1,90 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.utils +{ + import flash.utils.Dictionary; + + public class DictionaryUtil + { + + /** + * Returns an Array of all keys within the specified dictionary. + * + * @param d The Dictionary instance whose keys will be returned. + * + * @return Array of keys contained within the Dictionary + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function getKeys(d:Dictionary):Array + { + var a:Array = new Array(); + + for (var key:Object in d) + { + a.push(key); + } + + return a; + } + + /** + * Returns an Array of all values within the specified dictionary. + * + * @param d The Dictionary instance whose values will be returned. + * + * @return Array of values contained within the Dictionary + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function getValues(d:Dictionary):Array + { + var a:Array = new Array(); + + for each (var value:Object in d) + { + a.push(value); + } + + return a; + } + + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/IntUtil.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/IntUtil.as new file mode 100644 index 0000000000000000000000000000000000000000..591edc0af35e80b3773adf0768a1cb69bbaa43f3 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/IntUtil.as @@ -0,0 +1,69 @@ + +package com.adobe.utils { + + import flash.utils.Endian; + + /** + * Contains reusable methods for operations pertaining + * to int values. + */ + public class IntUtil { + + /** + * Rotates x left n bits + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function rol ( x:int, n:int ):int { + return ( x << n ) | ( x >>> ( 32 - n ) ); + } + + /** + * Rotates x right n bits + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function ror ( x:int, n:int ):uint { + var nn:int = 32 - n; + return ( x << nn ) | ( x >>> ( 32 - nn ) ); + } + + /** String for quick lookup of a hex character based on index */ + private static var hexChars:String = "0123456789abcdef"; + + /** + * Outputs the hex value of a int, allowing the developer to specify + * the endinaness in the process. Hex output is lowercase. + * + * @param n The int value to output as hex + * @param bigEndian Flag to output the int as big or little endian + * @return A string of length 8 corresponding to the + * hex representation of n ( minus the leading "0x" ) + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function toHex( n:int, bigEndian:Boolean = false ):String { + var s:String = ""; + + if ( bigEndian ) { + for ( var i:int = 0; i < 4; i++ ) { + s += hexChars.charAt( ( n >> ( ( 3 - i ) * 8 + 4 ) ) & 0xF ) + + hexChars.charAt( ( n >> ( ( 3 - i ) * 8 ) ) & 0xF ); + } + } else { + for ( var x:int = 0; x < 4; x++ ) { + s += hexChars.charAt( ( n >> ( x * 8 + 4 ) ) & 0xF ) + + hexChars.charAt( ( n >> ( x * 8 ) ) & 0xF ); + } + } + + return s; + } + } + +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/NumberFormatter.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/NumberFormatter.as new file mode 100644 index 0000000000000000000000000000000000000000..53b2501778c6e98ddb5a195cedde96f4f19e3999 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/NumberFormatter.as @@ -0,0 +1,77 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.utils +{ + + /** + * Class that contains static utility methods for formatting Numbers + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + * + * @see #mx.formatters.NumberFormatter + */ + public class NumberFormatter + { + + /** + * Formats a number to include a leading zero if it is a single digit + * between -1 and 10. + * + * @param n The number that will be formatted + * + * @return A string with single digits between -1 and 10 padded with a + * leading zero. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function addLeadingZero(n:Number):String + { + var out:String = String(n); + + if(n < 10 && n > -1) + { + out = "0" + out; + } + + return out; + } + + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/StringUtil.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/StringUtil.as new file mode 100644 index 0000000000000000000000000000000000000000..810fd349cf0ef1090d669053be1278da48eae3d5 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/StringUtil.as @@ -0,0 +1,273 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.utils +{ + + /** + * Class that contains static utility methods for manipulating Strings. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public class StringUtil + { + + + /** + * Does a case insensitive compare or two strings and returns true if + * they are equal. + * + * @param s1 The first string to compare. + * + * @param s2 The second string to compare. + * + * @returns A boolean value indicating whether the strings' values are + * equal in a case sensitive compare. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function stringsAreEqual(s1:String, s2:String, + caseSensitive:Boolean):Boolean + { + if(caseSensitive) + { + return (s1 == s2); + } + else + { + return (s1.toUpperCase() == s2.toUpperCase()); + } + } + + /** + * Removes whitespace from the front and the end of the specified + * string. + * + * @param input The String whose beginning and ending whitespace will + * will be removed. + * + * @returns A String with whitespace removed from the begining and end + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function trim(input:String):String + { + return StringUtil.ltrim(StringUtil.rtrim(input)); + } + + /** + * Removes whitespace from the front of the specified string. + * + * @param input The String whose beginning whitespace will will be removed. + * + * @returns A String with whitespace removed from the begining + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function ltrim(input:String):String + { + var size:Number = input.length; + for(var i:Number = 0; i < size; i++) + { + if(input.charCodeAt(i) > 32) + { + return input.substring(i); + } + } + return ""; + } + + /** + * Removes whitespace from the end of the specified string. + * + * @param input The String whose ending whitespace will will be removed. + * + * @returns A String with whitespace removed from the end + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function rtrim(input:String):String + { + var size:Number = input.length; + for(var i:Number = size; i > 0; i--) + { + if(input.charCodeAt(i - 1) > 32) + { + return input.substring(0, i); + } + } + + return ""; + } + + /** + * Determines whether the specified string begins with the spcified prefix. + * + * @param input The string that the prefix will be checked against. + * + * @param prefix The prefix that will be tested against the string. + * + * @returns True if the string starts with the prefix, false if it does not. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function beginsWith(input:String, prefix:String):Boolean + { + return (prefix == input.substring(0, prefix.length)); + } + + /** + * Determines whether the specified string ends with the spcified suffix. + * + * @param input The string that the suffic will be checked against. + * + * @param prefix The suffic that will be tested against the string. + * + * @returns True if the string ends with the suffix, false if it does not. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function endsWith(input:String, suffix:String):Boolean + { + return (suffix == input.substring(input.length - suffix.length)); + } + + /** + * Removes all instances of the remove string in the input string. + * + * @param input The string that will be checked for instances of remove + * string + * + * @param remove The string that will be removed from the input string. + * + * @returns A String with the remove string removed. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function remove(input:String, remove:String):String + { + return StringUtil.replace(input, remove, ""); + } + + /** + * Replaces all instances of the replace string in the input string + * with the replaceWith string. + * + * @param input The string that instances of replace string will be + * replaces with removeWith string. + * + * @param replace The string that will be replaced by instances of + * the replaceWith string. + * + * @param replaceWith The string that will replace instances of replace + * string. + * + * @returns A new String with the replace string replaced with the + * replaceWith string. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function replace(input:String, replace:String, replaceWith:String):String + { + //change to StringBuilder + var sb:String = new String(); + var found:Boolean = false; + + var sLen:Number = input.length; + var rLen:Number = replace.length; + + for (var i:Number = 0; i < sLen; i++) + { + if(input.charAt(i) == replace.charAt(0)) + { + found = true; + for(var j:Number = 0; j < rLen; j++) + { + if(!(input.charAt(i + j) == replace.charAt(j))) + { + found = false; + break; + } + } + + if(found) + { + sb += replaceWith; + i = i + (rLen - 1); + continue; + } + } + sb += input.charAt(i); + } + //TODO : if the string is not found, should we return the original + //string? + return sb; + } + + /** + * Specifies whether the specified string is either non-null, or contains + * characters (i.e. length is greater that 0) + * + * @param s The string which is being checked for a value + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + * @tiptext + */ + public static function stringHasValue(s:String):Boolean + { + //todo: this needs a unit test + return (s != null && s.length > 0); + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/XMLUtil.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/XMLUtil.as new file mode 100644 index 0000000000000000000000000000000000000000..8524a0b0939b542d5bcdf23e77056e0a2e730b03 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/utils/XMLUtil.as @@ -0,0 +1,171 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.utils +{ + + public class XMLUtil + { + /** + * Constant representing a text node type returned from XML.nodeKind. + * + * @see XML.nodeKind() + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + */ + public static const TEXT:String = "text"; + + /** + * Constant representing a comment node type returned from XML.nodeKind. + * + * @see XML.nodeKind() + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + */ + public static const COMMENT:String = "comment"; + + /** + * Constant representing a processing instruction type returned from XML.nodeKind. + * + * @see XML.nodeKind() + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + */ + public static const PROCESSING_INSTRUCTION:String = "processing-instruction"; + + /** + * Constant representing an attribute type returned from XML.nodeKind. + * + * @see XML.nodeKind() + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + */ + public static const ATTRIBUTE:String = "attribute"; + + /** + * Constant representing a element type returned from XML.nodeKind. + * + * @see XML.nodeKind() + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + */ + public static const ELEMENT:String = "element"; + + /** + * Checks whether the specified string is valid and well formed XML. + * + * @param data The string that is being checked to see if it is valid XML. + * + * @return A Boolean value indicating whether the specified string is + * valid XML. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + */ + public static function isValidXML(data:String):Boolean + { + var xml:XML; + + try + { + xml = new XML(data); + } + catch(e:Error) + { + return false; + } + + if(xml.nodeKind() != XMLUtil.ELEMENT) + { + return false; + } + + return true; + } + + /** + * Returns the next sibling of the specified node relative to the node's parent. + * + * @param x The node whose next sibling will be returned. + * + * @return The next sibling of the node. null if the node does not have + * a sibling after it, or if the node has no parent. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + */ + public static function getNextSibling(x:XML):XML + { + return XMLUtil.getSiblingByIndex(x, 1); + } + + /** + * Returns the sibling before the specified node relative to the node's parent. + * + * @param x The node whose sibling before it will be returned. + * + * @return The sibling before the node. null if the node does not have + * a sibling before it, or if the node has no parent. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + */ + public static function getPreviousSibling(x:XML):XML + { + return XMLUtil.getSiblingByIndex(x, -1); + } + + protected static function getSiblingByIndex(x:XML, count:int):XML + { + var out:XML; + + try + { + out = x.parent().children()[x.childIndex() + count]; + } + catch(e:Error) + { + return null; + } + + return out; + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/webapis/ServiceBase.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/webapis/ServiceBase.as new file mode 100644 index 0000000000000000000000000000000000000000..27ffbb02e87abc59d6eed97e48454d9f9b33cd60 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/webapis/ServiceBase.as @@ -0,0 +1,51 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +package com.adobe.webapis +{ + import flash.events.EventDispatcher; + + /** + * Base class for remote service classes. + */ + public class ServiceBase extends EventDispatcher + { + public function ServiceBase() + { + } + + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/webapis/URLLoaderBase.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/webapis/URLLoaderBase.as new file mode 100644 index 0000000000000000000000000000000000000000..41e7b331de9c6426fe0f68a8321705f8077b7490 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/webapis/URLLoaderBase.as @@ -0,0 +1,111 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package com.adobe.webapis +{ + import flash.events.IOErrorEvent; + import flash.events.SecurityErrorEvent; + import flash.events.ProgressEvent; + + import com.adobe.net.DynamicURLLoader; + + /** + * Dispatched when data is + * received as the download operation progresses. + * + * @eventType flash.events.ProgressEvent.PROGRESS + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + */ + [Event(name="progress", type="flash.events.ProgressEvent")] + + /** + * Dispatched if a call to the server results in a fatal + * error that terminates the download. + * + * @eventType flash.events.IOErrorEvent.IO_ERROR + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + */ + [Event(name="ioError", type="flash.events.IOErrorEvent")] + + /** + * A securityError event occurs if a call attempts to + * load data from a server outside the security sandbox. + * + * @eventType flash.events.SecurityErrorEvent.SECURITY_ERROR + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + */ + [Event(name="securityError", type="flash.events.SecurityErrorEvent")] + + /** + * Base class for services that utilize URLLoader + * to communicate with remote APIs / Services. + * + * @langversion ActionScript 3.0 + * @playerversion Flash 9.0 + */ + public class URLLoaderBase extends ServiceBase + { + protected function getURLLoader():DynamicURLLoader + { + var loader:DynamicURLLoader = new DynamicURLLoader(); + loader.addEventListener("progress", onProgress); + loader.addEventListener("ioError", onIOError); + loader.addEventListener("securityError", onSecurityError); + + return loader; + } + + private function onIOError(event:IOErrorEvent):void + { + dispatchEvent(event); + } + + private function onSecurityError(event:SecurityErrorEvent):void + { + dispatchEvent(event); + } + + private function onProgress(event:ProgressEvent):void + { + dispatchEvent(event); + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/webapis/events/ServiceEvent.as b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/webapis/events/ServiceEvent.as new file mode 100644 index 0000000000000000000000000000000000000000..2f341a2842f378c9cc910dfda6a19e3994f91409 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/corelib/src/com/adobe/webapis/events/ServiceEvent.as @@ -0,0 +1,78 @@ +/* + Adobe Systems Incorporated(r) Source Code License Agreement + Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved. + + Please read this Source Code License Agreement carefully before using + the source code. + + Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license, to reproduce, + prepare derivative works of, publicly display, publicly perform, and + distribute this source code and such derivative works in source or + object code form without any attribution requirements. + + The name "Adobe Systems Incorporated" must not be used to endorse or promote products + derived from the source code without prior written permission. + + You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and + against any loss, damage, claims or lawsuits, including attorney's + fees that arise or result from your use or distribution of the source + code. + + THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT + ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, + BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF + NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA + OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +package com.adobe.webapis.events +{ + + import flash.events.Event; + + /** + * Event class that contains data loaded from remote services. + * + * @author Mike Chambers + */ + public class ServiceEvent extends Event + { + private var _data:Object = new Object(); + + /** + * Constructor for ServiceEvent class. + * + * @param type The type of event that the instance represents. + */ + public function ServiceEvent(type:String, bubbles:Boolean = false, + cancelable:Boolean=false) + { + super(type, bubbles, cancelable); + } + + /** + * This object contains data loaded in response + * to remote service calls, and properties associated with that call. + */ + public function get data():Object + { + return _data; + } + + public function set data(d:Object):void + { + _data = d; + } + + + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/flexunit/flexunit.swc b/typo3/contrib/flowplayer/lib/flexunit/flexunit.swc new file mode 100644 index 0000000000000000000000000000000000000000..70bd0cd845e456eb1da3a2801508b8969717c485 Binary files /dev/null and b/typo3/contrib/flowplayer/lib/flexunit/flexunit.swc differ diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/com/mosesSupposes/go/tutorials/SizeTweenMG.as b/typo3/contrib/flowplayer/lib/goasp/src_go/com/mosesSupposes/go/tutorials/SizeTweenMG.as new file mode 100644 index 0000000000000000000000000000000000000000..fb027a22b6912b2477a935c60022902a5512afb3 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/com/mosesSupposes/go/tutorials/SizeTweenMG.as @@ -0,0 +1,202 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.mosesSupposes.go.tutorials +{ + import flash.display.DisplayObject; + + import org.goasap.interfaces.IManageable; + import org.goasap.items.LinearGo; + + /** + * This example handles both width & height tweens and is compatible + * with OverlapMonitor. It also supports user-set start properties. + * For a more basic example see WidthTween. + * + * <p>Setup: <code>GoEngine.addManager( new OverlapMonitor() );</code></p> + * + * @see WidthTween + * + * @author Moses Gunesch + */ + public class SizeTweenMG extends LinearGo implements IManageable { + + // -== Public Properties ==- + + // See notes in WidthTween + // Another strategy for multiple props is to define constants then + // store props in an array. We'll keep it simple for this example. + public function get width() : Number { + return _width; + } + public function set width(value : Number):void { + if (_state==STOPPED) + _width = value; + } + + public function get height() : Number { + return _height; + } + public function set height(value : Number):void { + if (_state==STOPPED) + _height = value; + } + + // Start settings are not a standard convention, just an option you can choose to provide if you want. + public function get startWidth() : Number { + return _startWidth; + } + public function set startWidth(value : Number):void { + if (_state==STOPPED) + _startWidth = value; + } + + public function get startHeight() : Number { + return _startHeight; + } + public function set startHeight(value : Number):void { + if (_state==STOPPED) + _startHeight = value; + } + + public function get target() : DisplayObject { + return _target; + } + public function set target(obj : DisplayObject):void { + if (_state==STOPPED) + _target = obj; + } + + // -== Protected Properties ==- + + protected var _target : DisplayObject; + protected var _width : Number; + protected var _height : Number; + protected var _startWidth : Number; + protected var _startHeight : Number; + protected var _tweenStartWidth : Number; // used during the tween so that the user-set property isn't altered. + protected var _tweenStartHeight : Number; // used during the tween so that the user-set property isn't altered. + protected var _changeWidth : Number; + protected var _changeHeight : Number; + + // -== Public Methods ==- + + // See notes in WidthTween + public function SizeTweenMG( target : DisplayObject=null, + widthTo : Number=NaN, + heightTo : Number=NaN, + delay : Number=NaN, + duration : Number=NaN, + easing : Function=null ) + { + super(delay, duration, easing); + _target = target; + _width = widthTo; + _height = heightTo; + } + + // See notes in WidthTween + override public function start():Boolean + { + if (!_target || (isNaN(_width) && isNaN(_height))) + return false; + + _changeWidth = NaN; + _changeHeight = NaN; + if (!isNaN(_width)) { + // Start settings are not a standard convention, just an option you can choose to provide if you want. + if (isNaN(_startWidth)) + _tweenStartWidth = _target.width; + else + _target.width = _tweenStartWidth = _startWidth; + + // The useRelative property is a standard Go convention that each subclass must implement manually. + _changeWidth = (useRelative ? _width : _width - _tweenStartWidth); + } + + if (!isNaN(_height)) { + if (isNaN(_startHeight)) + _tweenStartHeight = _target.height; + else + _target.height = _tweenStartHeight = _startHeight; + + _changeHeight = (useRelative ? _height : _height - _tweenStartHeight); + } + return (super.start()); + } + + // See notes in WidthTween + override protected function onUpdate(type:String) : void { + // The useRounding property is a standard Go convention that can be implemented by calling correctValue() . + if (!isNaN(_changeWidth)) + _target.width = super.correctValue(_tweenStartWidth + _changeWidth * _position); + + if (!isNaN(_changeHeight)) + _target.height = super.correctValue(_tweenStartHeight + _changeHeight * _position); + + } + + // -== IManageable Implementation ==- + + // The following methods make the tween class compatible with OverlapMonitor + // or other managers. Please open the docs for the IManageable interface as you + // review these 4 methods, so you get a clear picture of how the system works. + + // All animation targets currently being handled. + public function getActiveTargets() : Array { + return [ _target ]; + } + + // All property-strings currently being handled. + public function getActiveProperties() : Array { + var a:Array = new Array(); + if (!isNaN(_changeWidth)) + a.push("width"); + if (!isNaN(_changeHeight)) + a.push("height"); + return a; + } + + // This method is the only complex one of the four. The general idea is to determine if there's any + // direct -- or indirect! -- overlap between the strings passed in & actively-tweening properties. + // There are some tricky things about it though -- Hit the docs, soldier! :) + public function isHandling(properties : Array) : Boolean { + if (!isNaN(_changeWidth)) { + if (properties.indexOf("width")>-1) return true; + if (properties.indexOf("scaleX")>-1) return true; + } + if (!isNaN(_changeHeight)) { + if (properties.indexOf("height")>-1) return true; + if (properties.indexOf("scaleY")>-1) return true; + } + return false; + } + + // When there's a conflict the manager calls this method so you can stop the tween. + public function releaseHandling(...params) : void { + //trace(this + " releaseHandling()"); + super.stop(); + } + + // Try interrupting the tween with another tween on the same target to see if it works! + // (Remember to run the setup command to activate OverlapMonitor, see header doc in this class.) + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/com/mosesSupposes/go/tutorials/WidthTween.as b/typo3/contrib/flowplayer/lib/goasp/src_go/com/mosesSupposes/go/tutorials/WidthTween.as new file mode 100644 index 0000000000000000000000000000000000000000..167c836e7bc826e39a442a400c25ab88b1515fa9 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/com/mosesSupposes/go/tutorials/WidthTween.as @@ -0,0 +1,119 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.mosesSupposes.go.tutorials +{ + import flash.display.DisplayObject; + + import org.goasap.items.LinearGo; + + /** + * A basic example of how you could build a tween on LinearGo. + * + * @see SizeTweenMg SizeTweenMg: a similar example that works with OverlapMonitor + * + * @author Moses Gunesch + */ + public class WidthTween extends LinearGo { + + // -== Public Properties ==- + + + // In this example, the tween class has a width property, but the point of Go is that + // the design is left up to you. If you prefer to parse an object or XML, or accept an + // array of properties and targets, all of that is left up to you. + public function get width() : Number { + return _width; + } + public function set width(value : Number):void { + if (_state==STOPPED) + _width = value; + } + + + // See note above width getter, same applies here. Note that I've picked a specific datatype + // for my tween target, but again it's wide open, including the variable name. The only thing + // that tends to be universal is that you need at least one target and at least one property. + public function get target() : DisplayObject { + return _target; + } + public function set target(obj : DisplayObject):void { + if (_state==STOPPED) + _target = obj; + } + + + // -== Protected Properties ==- + protected var _target : DisplayObject; + protected var _width : Number; + protected var _startWidth : Number; + protected var _changeWidth : Number; + + + // -== Public Methods ==- + + // You can design your own constructor for your tween classes of course! + public function WidthTween( target : DisplayObject=null, + widthTo : Number=NaN, + delay : Number=NaN, + duration : Number=NaN, + easing : Function=null ) + { + super(delay, duration, easing); + _target = target; + _width = widthTo; + } + + + // CONVENTION ALERT! + + // * Be aware that there are two standard conventions in Go that need to be + // implemented manually by each LinearGo subclass, numbered below. + + + override public function start():Boolean + { + if (!_target || !_width || isNaN(_width)) + return false; + + _startWidth = _target.width; // Store start & change values for use in onUpdate. + + // Convention #1: useRelative (*see note above) + _changeWidth = (useRelative + ? _width // relative positioning: like if the user set -10, we should change "by" that much. + : _width - _startWidth); // absolute positioning: the tween spans the difference from existing width. + + return (super.start()); + } + + + // Convention #2:useRounding (*see note above) + // Always call correctValue() on tween values before setting them to targets. + // This fixes NaNs to 0 and applies Math.round based on the useRounding setting. + override protected function onUpdate(type:String) : void + { + // Basic tween implementation using the formula Value=Start+(Change*Position). + // Position is a 0-1 multiplier run by LinearGo. + + _target.width = super.correctValue( _startWidth + _changeWidth * _position ); + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/GoEngine.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/GoEngine.as new file mode 100644 index 0000000000000000000000000000000000000000..9a1e1b47eed3e70b465acd7d52a861b2b31d5d6e --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/GoEngine.as @@ -0,0 +1,462 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap { + import flash.display.Sprite; + import flash.events.Event; + import flash.events.TimerEvent; + import flash.utils.Dictionary; + import flash.utils.Timer; + import flash.utils.getQualifiedClassName; + import flash.utils.getTimer; + + import org.goasap.errors.DuplicateManagerError; + import org.goasap.interfaces.IManageable; + import org.goasap.interfaces.IManager; + import org.goasap.interfaces.IUpdatable; + import org.goasap.interfaces.ILiveManager; + + /** + * Provides <code>update</code> calls to <code>IUpdatable</code> instances on their specified <code>pulseInterval</code>. + * + * <p><b>Using these Docs</b></p> + * + * <p><i>Protected methods and properties have been excluded in almost all + * cases, but are documented in the classes. Exceptions include key protected + * methods or properties that are integral for writing subclasses or understanding + * the basic mechanics of the system. Many Go classes can be used as is without + * subclassing, so the documentation offers an uncluttered view of their public + * usage.</i></p> + * + * <p><b>Introduction to Go</b></p> + * + * <p>The Go ActionScript Animation Platform ("GOASAP") is a lightweight, portable + * set of generic base classes for buliding AS3 animation tools. It provides structure + * and core functionality, but does not define the specifics of animation-handling + * classes like tweens.</p> + * + * <p><i>Important: Store your custom Go classes in a package bearing your + * own classpath, not in the core package! This will help avoid confusion + * with other authors' work.</i></p> + * + * <p>You may modify any class in the goasap package to suit your project's needs.</p> + * + * <p>Go is a community initiative led by Moses Gunesch at + * <a href="http://www.mosessupposes.com/" target="_top">MosesSupposes.com</a>. Please visit the + * <a href="http://www.goasap.org/" target="_top">Go website</a> for more information.</p> + * + * <p><b>GoEngine</b></p> + * + * <p>GoEngine sits at the center of the Go system, and along with the IUpdatable + * interface is the only required element for using Go. GoEngine references two other + * interfaces for adding system-wide managers, IManager and IManageable. + * All other classes in the go package are merely one suggestion of how a + * system could be structured within Go, and may be considered optional + * elements. To create an API using the provided classes, you simply need + * to extend the item classes LinearGo and PhysicsGo to create animation items.</p> + * + * <p>GoEngine serves two purposes: first, it keeps a large system efficient + * by stacking and running updates on blocks of items. Note that any IUpdatable + * instance may specify its own pulseInterval; items with matching pulses + * are grouped into queues for efficiency. Its second purpose is centralization. + * By using a single hub for pulse-driven items of all types, management classes + * can be attached to GoEngine to run processes across items. This is done voluntarily + * by the end-user with <code>addManager()</code>, which keeps management entirely + * compile-optional and extensible. See the documentation for <code>IManager</code> + * to learn more about Go's management architeture.</p> + * + * <p>You normally don't need to modify this class to use Go. While Go items typically + * only use <code>addItem</code> and <code>removeItem</code>, your project's code might + * use GoEngine to register managers, or to pause, resume or stop all Go animation in + * a SWF at once.</p> + * + * <p></i>{In the game of Go, the wooden playing board, or Goban, features a grid + * on which black & white go-ishi stones are laid at its intersections.}</i></p> + * + * @see org.goasap.items.LinearGo LinearGo + * @see org.goasap.interfaces.IManager IManager + * @author Moses Gunesch + */ + public class GoEngine + { + // -== Constants ==- + + public static const INFO:String = "GoASAP 0.4.9 (c) Moses Gunesch, MIT Licensed."; + + // -== Settable Class Defaults ==- + + /** + * A pulseInterval that runs on the player's natural framerate, + * which is often most efficient. + */ + public static const ENTER_FRAME : int = -1; + + // -== Protected Properties ==- + + // Note: Various formats for item data have been experimented with including breaking the item lists out into + // a GoEngineList class, which was nicer-looking but did not perform well. Since GoEngine doesn't normally + // require active work, this less-pretty but efficient flat-data format was opted for. A minor weakness of this + // format is its use of a Dictionary, which means update calls are not ordered like they would be with an Array. + // The Dictionary stores items' pulseInterval values, which is safer than relying on items to not change them. + // Tests also show that Dictionary performs faster than Array for accessing and deleting items. + private static var managerTable : Object = new Object(); // registration list of IManager instances + private static var managers : Array = new Array(); // ordered registration list of IManager instances + private static var liveManagers : uint = 0; + private static var timers : Dictionary = new Dictionary(false); // key: pulseInterval, value: Timer for that pulse + private static var items : Dictionary = new Dictionary(false); // key: IUpdatable item, value: pulseInterval at add. + private static var itemCounts : Dictionary = new Dictionary(false); // key: pulseInterval, value: item count for that pulse + private static var pulseSprite : Sprite; // used for ENTER_FRAME pulse + private static var paused : Boolean = false; + + // These additional lists enables caching of items that are added during the update cycle for the same pulse. + // This prevents groups & sequences from going out of sync by ensuring that each cycle completes before new items are added. + private static var lockedPulses : Dictionary = new Dictionary(false); // key: pulseInterval, value: true + private static var delayedPulses : Dictionary = new Dictionary(false); // key: pulseInterval, value: true + private static var addQueue : Dictionary = new Dictionary(false); // key: IUpdatable item, value: true + + // -== Public Class Methods ==- + + /** + * @param className A string naming the manager class, such as "OverlapMonitor". + * @return The manager instance, if registered. + * @see #addManager() + * @see #removeManager() + */ + public static function getManager(className:String) : IManager + { + return managerTable[ className ]; + } + + /** + * Enables the extending of this class' functionality with a tight + * coupling to an IManager. + * + * <p>Tight coupling is crucial in such a time-sensitive context; + * standard events are too asynchronous. All items that implement + * IManageable are reported to registered managers as they add and + * remove themselves from GoEngine.</p> + * + * <p>Managers normally act as singletons within the Go system (which + * you are welcome to modify). This method throws a DuplicateManagerError + * if an instance of the same manager class is already registered. Use a + * try/catch block when calling this method if your program might duplicate + * managers, or use getManager() to check for prior registration.</p> + * + * @param instance An instance of a manager you wish to add. + * @see #getManager() + * @see #removeManager() + */ + public static function addManager( instance:IManager ):void + { + var className:String = getQualifiedClassName(instance); + className = className.slice(className.lastIndexOf("::")+2); + if (managerTable[ className ]) { + throw new DuplicateManagerError( className ); + return; + } + managerTable[ className ] = instance; + managers.push(instance); + if (instance is ILiveManager) liveManagers++; + } + + /** + * Unregisters any manager set in <code>addManager</code>. + * + * @param className A string naming the manager class, such as "OverlapMonitor". + * @see #getManager() + * @see #addManager() + */ + public static function removeManager( className:String ):void + { + managers.splice(managers.indexOf(managerTable[ className ]), 1); + if (managerTable[ className ] is ILiveManager) + liveManagers--; + delete managerTable[ className ]; // leave last + } + + /** + * Test whether an item is currently stored and being updated by the engine. + * + * @param item Any object implementing IUpdatable + * @return Whether the IUpdatable is in the engine + */ + public static function hasItem( item:IUpdatable ):Boolean + { + return (items[ item ]!=null); + } + + /** + * Adds an IUpdatable instance to an update-queue corresponding to + * the item's pulseInterval property. + * + * @param item Any object implementing IUpdatable that wishes + * to receive update calls on a pulse. + * + * @return Returns false only if this item was already in the + * engine under the same pulse. (If an existing item is added + * but the pulseInterval has changed it will be removed, + * re-added, and true will be returned.) + * + * @see #removeItem() + */ + public static function addItem( item:IUpdatable ):Boolean + { + // Group items by pulse for efficient update cycles. + var interval:int = item.pulseInterval; + if (items[ item ]) { + if (items[ item ] == item.pulseInterval) + return false; + else + removeItem(item); + } + if (lockedPulses[ interval ]==true) { // this prevents items from being added during an update loop in progress. + delayedPulses[ interval ] = true; // flags update to clear the queue when the in-progress loop completes. + addQueue[ item ] = true; // for tightest syncing of item groups, read the documentation under GoItem.update(). + } + items[ item ] = interval; // Tether item to original pulseint. Used in removeItem & setPaused(false). + if (!timers[ interval ]) { + addPulse( interval ); + itemCounts[ interval ] = 1; + } + else { + itemCounts[ interval ] ++; + } + // Report IManageable instances to registered managers + if (item is IManageable) { + for each (var manager:IManager in managers) + manager.reserve( item as IManageable ); + } + return true; + } + + /** + * Removes an item from the queue and removes its pulse timer if + * the queue is depleted. + * + * @param item Any IUpdatable previously added that wishes + * to stop receiving update calls. + * + * @return Returns false if the item was not in the engine. + * + * @see #addItem() + */ + public static function removeItem( item:IUpdatable ):Boolean + { + if (items[ item ]==null) + return false; + var interval: int = items[ item ]; + if ( -- itemCounts[ interval ] == 0 ) { + removePulse( interval ); + delete itemCounts[ interval ]; + } + delete items[ item ]; + delete addQueue[ item ]; // * see note following update + // Report IManageable item removal to registered managers. + if (item is IManageable) { + for each (var manager:IManager in managers) + manager.release( item as IManageable ); + } + return true; + } + + /** + * Removes all items and resets the engine, + * or removes just items running on a specific pulse. + * + * @param pulseInterval Optionally filter by a specific pulse + * such as ENTER_FRAME or a number of milliseconds. + * @return The number of items successfully removed. + * @see #removeItem() + */ + public static function clear(pulseInterval:Number = NaN) : uint + { + var all:Boolean = (isNaN(pulseInterval)); + var n:Number = 0; + for (var item:Object in items) { + if (all || items[ item ]==pulseInterval) + if (removeItem(item as IUpdatable)==true) + n++; + } + return n; + } + + /** + * Retrieves number of active items in the engine + * or active items running on a specific pulse. + * + * @param pulseInterval Optionally filter by a specific pulseInterval + * such as ENTER_FRAME or a number of milliseconds. + * + * @return Number of active items in the Engine. + */ + public static function getCount(pulseInterval:Number = NaN) : uint + { + if (!isNaN(pulseInterval)) + return (itemCounts[pulseInterval]); + var n:Number = 0; + for each (var count: int in itemCounts) + n += count; + return n; + } + + /** + * @return The paused state of engine. + * @see #setPaused() + */ + public static function getPaused() : Boolean { + return paused; + } + + /** + * Pauses or resumes all animation globally by suspending processing, + * and calls pause() or resume() on each item with those methods. + * + * <p>The return value only reflects how many items had pause() or resume() + * called on them, but the GoEngine.getPaused() state will change if any + * pulses are suspended or resumed.</p> + * + * @param pause Pass false to resume if currently paused. + * @param pulseInterval Optionally filter by a specific pulse + * such as ENTER_FRAME or a number of milliseconds. + * @return The number of items on which a pause() or resume() + * method was called (0 doesn't necessarily reflect + * whether the GoEngine.getPaused() state changed, it + * may simply indicate that no items had that method). + * @see #resume() + */ + public static function setPaused(pause:Boolean=true, pulseInterval:Number = NaN) : uint + { + if (paused==pause) return 0; + var n:Number = 0; + var pulseChanged:Boolean = false; + var all:Boolean = (isNaN(pulseInterval)); + var method:String = (pause ? "pause" : "resume"); + for (var item:Object in items) { + var pulse:int = (items[item] as int); + if (all || pulse==pulseInterval) { + pulseChanged = (pulseChanged || (pause ? removePulse(pulse) : addPulse(pulse))); + // call pause or resume on the item if it has such a method. + if (item.hasOwnProperty(method)) { + if (item[method] is Function) { + item[method].apply(item); + n++; + } + } + } + } + if (pulseChanged) + paused = pause; + return n; + } + + // -== Private Class Methods ==- + + /** + * Executes the update queue corresponding to the dispatcher's interval. + * + * @param event TimerEvent or Sprite ENTER_FRAME Event + */ + private static function update(event:Event) : void + { + var currentTime:Number = getTimer(); + var pulse:int = (event is TimerEvent ? ( event.target as Timer ).delay : ENTER_FRAME); + lockedPulses[ pulse ] = true; + var doLiveUpdate:Boolean = (liveManagers > 0); + var updated:Array; + if (doLiveUpdate) updated = []; // syncs the live manager list to items actually updated + for (var item:* in items) { + if (items[ item ]==pulse && !addQueue[ item ]) { + (item as IUpdatable).update(currentTime); + if (doLiveUpdate) updated.push(item); + } + } + lockedPulses[ pulse ] = false; + if (delayedPulses[ pulse ]) { + for (item in addQueue) + delete addQueue[ item ]; + delete delayedPulses[ pulse ]; + } +// updateAfterEvent() should not be needed as long as items follow tight-syncing instructions in GoItem.update() documentation. +// if (pulse!=ENTER_FRAME) (event as TimerEvent).updateAfterEvent(); + if (doLiveUpdate) + for each (var manager:Object in managers) + if (manager is ILiveManager) + (manager as ILiveManager).onUpdate(pulse, updated, currentTime); // * see note + } +// * note: In one rare case that has not been reported yet but is theoretically possible, the 'updated' list +// passed could contain already-released items. This could only happen if the item is removed & released +// just after the main update cycle but before the the doLiveUpdate() routine runs. If you encounter this issue +// please report it to the GoASAP mailing list, it's too involved to bother with before it's a problem. + + /** + * Creates new timers when a previously unused interval is specified, + * and tracks the number of items associated with that interval. + * + * @param pulse The pulseInterval requested + * @return Whether a pulse was added + */ + private static function addPulse(pulse : int) : Boolean + { + if (pulse==ENTER_FRAME) { + if (!pulseSprite) { + timers[ENTER_FRAME] = pulseSprite = new Sprite(); + pulseSprite.addEventListener(Event.ENTER_FRAME, update); + } + return true; + } + var t:Timer = timers[ pulse ] as Timer; + if (!t) { + t = timers[ pulse ] = new Timer(pulse); + (timers[ pulse ] as Timer).addEventListener(TimerEvent.TIMER, update); + t.start(); + return true; + } + return false; + } + + /** + * Tracks whether a removed item was the last one using a timer + * and if so, removes that timer. + * + * @param pulse The pulseInterval corresponding to an item being removed. + * @return Whether a pulse was removed + */ + private static function removePulse(pulse : int) : Boolean + { + if (pulse==ENTER_FRAME) { + if (pulseSprite) { + pulseSprite.removeEventListener(Event.ENTER_FRAME, update); + delete timers[ ENTER_FRAME ]; + pulseSprite = null; + return true; + } + } + var t:Timer = timers[ pulse ] as Timer; + if (t) { + t.stop(); + t.removeEventListener(TimerEvent.TIMER, update); + delete timers[ pulse ]; + return true; + } + return false; + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/PlayableBase.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/PlayableBase.as new file mode 100644 index 0000000000000000000000000000000000000000..7d48192f671765ec8008d368984f2dcb9a5bfff0 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/PlayableBase.as @@ -0,0 +1,161 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap { + import flash.events.EventDispatcher; + import flash.utils.Dictionary; + import flash.utils.getQualifiedClassName; + + import org.goasap.errors.InstanceNotAllowedError; + import org.goasap.interfaces.IPlayableBase; + + /** + * Top-level abstract base class for playable classes that provides a standard + * set of play-state constants and an instance playableID value. + * + * <p>Playable classes in the Go system should normally extend this base class + * and implement the IPlayable interface. This is not mandatory since utilities + * normally reference playable items via the IPlayable datatype; However they also + * refer directly to the constants defined here, so those should be adhered to even + * if this class is not directly extended.</p> + * + * <p>Important memory management issue: Playable items that are not added to + * GoEngine can get garbage collected during play. It is a convention of the Go + * system that such items store a reference to themselves during play that is + * removed in stop(). See <a href="#_playRetainer">_playRetainer</a> for more.</p> + * + * @author Moses Gunesch + */ + public class PlayableBase extends EventDispatcher implements IPlayableBase { + + // -== Standard Go Play-state Constants ==- + + /** + * Instance play is currently stopped. + */ + public static const STOPPED : String = "STOPPED"; + + /** + * Instance play is currently paused. + */ + public static const PAUSED : String = "PAUSED"; + + /** + * Instance is currently playing a delay, but has not started playing. + * Delays are a non-universal feature that must be custom-implemented, + * so some subclasses of PlayableBase don't use this constant. + */ + public static const PLAYING_DELAY : String = "PLAYING_DELAY"; + + /** + * Instance play is currently playing. + */ + public static const PLAYING : String = "PLAYING"; + + + // -== Public Properties ==- + + /** + * An arbitrary id value for the convenient identification of any + * instance, automatically set to an instance count by this class. + */ + public function get playableID() : * { + return _id; + } + public function set playableID(value: *):void { + _id = value; + } + + /** + * Returns the value of one of this class' play-state constants. + * @see #STOPPED + * @see #PAUSED + * @see #PLAYING_DELAY + * @see #PLAYING + */ + public function get state() : String { + return _state; + } + + // -== Protected Properties ==- + + /** + * @private + */ + private static var _idCounter : int = -1; + /** + * @private + */ + protected var _state : String = STOPPED; + /** + * @private + */ + protected var _id : *; + /** + * Memory-management: Read this if you're subclassing PlayableBase but not adding your + * instance to GoEngine. + * + * <p>Subclasses that do not add themselves to GoEngine during play should stash a + * this-reference here in start() and delete it in stop. This prevents instance from + * getting GC'd during play. For an example see SequenceBase's start and stop methods.</p> + * + * <p>This step is not necessary if GoEngine.addItem is used, which keeps a live reference + * during play.</p> + * + * <p>This protected static var is just a convenience. You can mimic the technique of + * stashing a this-reference using any static property, to temporarily protect the object + * being referenced from garbage collection.</p> + * + * @see org.goasap.utils.SequenceBase SequenceBase + */ + protected static var _playRetainer : Dictionary = new Dictionary(false); + + + // -== Public Methods ==- + + /** + * Throws an InstanceNotAllowedError if directly instantiated, also sets a + * default playableID to an instance count number. + */ + public function PlayableBase() : void { + var className:String = getQualifiedClassName(this); + if (className.slice(className.lastIndexOf("::")+2) == "PlayableBase") { + throw new InstanceNotAllowedError("PlayableBase"); + } + playableID = ++ _idCounter; + } + + /** + * Appends the regular toString value with the instance's playableID. + * + * @return String representation of this instance. + */ + override public function toString():String { + var s:String = super.toString(); + var addLast:Boolean = (s.charAt(s.length-1)=="]"); + if (addLast) s = s.slice(0,-1); + if (playableID is String) s += " playableID:\"" + playableID + "\""; + else s += " playableID:" + playableID; + if (addLast) s += "]"; + return s; + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/errors/DuplicateManagerError.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/errors/DuplicateManagerError.as new file mode 100644 index 0000000000000000000000000000000000000000..dba3ade28c7ed5e592369bea81eca524989806ff --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/errors/DuplicateManagerError.as @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.errors { + + /** + * Throw this error if a manager is already registered. + * + * @author Moses Gunesch + */ + public class DuplicateManagerError extends Error { + + /** + * Error message "An instance of "+ className +" was already added to GoEngine." + * + * @param className The name of the duplicate manager's class. + */ + public function DuplicateManagerError(className:String) { + super("An instance of "+ className +" was already added to GoEngine."); + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/errors/EasingFormatError.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/errors/EasingFormatError.as new file mode 100644 index 0000000000000000000000000000000000000000..d8fb322c471f5754e618a3585faddaaa65d2a2ec --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/errors/EasingFormatError.as @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.errors { + + /** + * Throw this error if an easing function called with the params 1,1,1,1 does not return a Number. + * + * @author Moses Gunesch + */ + public class EasingFormatError extends Error { + + /** + * Error message "Easing function not valid." + */ + public function EasingFormatError() { + super("Easing function not valid."); + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/errors/InstanceNotAllowedError.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/errors/InstanceNotAllowedError.as new file mode 100644 index 0000000000000000000000000000000000000000..ef7b70321e83a32eb294e2edd233585012e5c5d3 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/errors/InstanceNotAllowedError.as @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.errors { + + /** + * Throw this error if a base class is directly instantiated but + * is not usable on its own. + * + * @author Moses Gunesch + */ + public class InstanceNotAllowedError extends Error { + + /** + * Error message "Direct use of "+ className +" is not allowed, use subclasses only." + * + * @param className The name of the class throwing the error + */ + public function InstanceNotAllowedError(className:String) { + super("Direct use of "+ className +" is not allowed, use subclasses only."); + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/events/GoEvent.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/events/GoEvent.as new file mode 100644 index 0000000000000000000000000000000000000000..4e9dc90fb641474c2c0fce317901d543e05d7d18 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/events/GoEvent.as @@ -0,0 +1,106 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.events { + import flash.events.Event; + + /** + * Standard event set for all playable Go classes. + * + * @author Moses Gunesch + */ + public class GoEvent extends Event + { + /** + * Indicates a playable instance is starting. + * + * @eventType playableStart + */ + public static const START : String = 'playableStart'; + + + /** + * Indicates a playable instance is updating. + * + * @eventType playableUpdate + */ + public static const UPDATE : String = 'playableUpdate'; + + + /** + * Indicates a playable instance was paused. + * + * @eventType playableUpdate + */ + public static const PAUSE : String = 'playablePause'; + + + /** + * Indicates a playable instance was restarted from a paused state. + * + * @eventType playableUpdate + */ + public static const RESUME : String = 'playableResume'; + + + /** + * Indicates a playable instance has completed a cycle or loop and is starting the next one. + * + * @eventType playableUpdate + */ + public static const CYCLE : String = 'playableCycle'; + + + /** + * Indicates a playable instance was manually stopped. + * + * @eventType playableStop + */ + public static const STOP : String = 'playableStop'; + + + /** + * Indicates a playable instance that can end on its own has successfully finished. + * + * @eventType playableComplete + * @see #STOP + */ + public static const COMPLETE : String = 'playableComplete'; + + + /** + * Enables additional objects or data to be packaged in any GoEvent. This provides some + * general flexibility, but subclass GoEvent to define specific conventions when possible. + */ + public var extra : *; + + + /** + * @param type The event type; indicates the action that triggered the event. + * @param bubbles Specifies whether the event can bubble up the display list hierarchy. + * @param cancelable Specifies whether the behavior associated with the event can be prevented. + */ + public function GoEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false) + { + super(type, bubbles, cancelable); + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/events/SequenceEvent.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/events/SequenceEvent.as new file mode 100644 index 0000000000000000000000000000000000000000..0156a803c3f595440c9ef4acea4f5cef9ecc6fae --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/events/SequenceEvent.as @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.events { + import flash.events.Event; + + /** + * Event for all Go sequence classes. + * + * @author Moses Gunesch + */ + public class SequenceEvent extends Event { + + /** + * Indicates a sequence is advancing to its next step. + * + * @eventType sequenceAdvance + */ + public static const ADVANCE : String = "sequenceAdvance"; + + public function SequenceEvent(type : String, bubbles : Boolean = false, cancelable : Boolean = false) { + super(type, bubbles, cancelable); + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/ILiveManager.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/ILiveManager.as new file mode 100644 index 0000000000000000000000000000000000000000..fc68d9229006e87fa4d5c4b6edd762e3986f4e3a --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/ILiveManager.as @@ -0,0 +1,85 @@ +/** + * Copyright (c) 2008 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.interfaces { + import org.goasap.interfaces.IManager; + + /** + * Instances receive a callback from GoEngine after each update cycle, + * allowing managers to more easily perform ongoing processes during animation. + * + * <p><font color="#CC0000">[This is a more advanced manager interface, so if + * you are just getting started with Go's management system it is suggested that + * you focus on <code>IManager</code> & <code>IManageable</code>, and save this + * section for when you need it.]</font> </p> + * + * <p>Hypothetical examples:</p> + * <ul> + * <li>An updater class that refreshes (rerenders) a 3D scene after all + * animations have processed each pulse.</li> + * <li>A hitTest manager that allows all items to update their positions + * first, then tests for hits between them.</li> + * </ul> + * <p>Each <code>ILiveManager</code> receives a special onUpdate() callback + * after GoEngine completes each pulse cycle for any particular pulseInterval. + * This callback receives three things: the pulseInterval associated with the + * cycle, an array containing the items updated, and the synced current-time value + * that was sent to all the items as update() was called. (Background: GoEngine + * stores different lists for every different pulseInterval specified by animation + * items. Usually users will stick to a single pulseInterval but at times it can + * be beneficial to run some animations slower than others – such as the readouts + * in a spaceship game's cockpit which don't need to refresh as often and can free + * up processing power for the game if they don't.)</p> + * + * <p>The list of updated items only includes items actually updated, which at + * times can differ slightly from the items that have been added to GoEngine and + * sent to the manager's reserve() method. (Background: when items are added to + * GoEngine during its update cycle, it defers updating them until the next pulse + * so as not to disrupt the cycle in progress.) Therefore, even though <code>ILiveManager</code> + * extends <code>IManager</code> and contains reserve() and release() methods, + * those methods are often not needed here, since you can filter and make use of + * the incoming array of updated items on each update. This can also relieve such + * managers from needing to store and manage complex handler lists (as + * <code>OverlapMonitor</code> does).</p> + * + * <p><code>ILiveManager</code> instances registered using <code>GoEngine.addManager()</code> + * are stored in an ordered list. You can control the priority of updates in a + * program by adding certain managers before others.</p> + * + * @see IManager + * @see IManageable + * @see org.goasap.GoEngine#addManager GoEngine.addManager() + * + * @author Moses Gunesch + */ + public interface ILiveManager extends IManager + { + + /** + * GoEngine pings this function after each update() cycle for each pulse. + * + * @param pulseInterval The pulse interval for this update cycle (-1 is ENTER_FRAME) + * @param handlers The list of handlers actually updated during this cycle + * @param currentTime The clock time that was passed to items during update + */ + function onUpdate(pulseInterval:int, handlers:Array, currentTime : Number):void; + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/IManageable.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/IManageable.as new file mode 100644 index 0000000000000000000000000000000000000000..37cd2f32240d879b17b9dd68114ced553759924a --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/IManageable.as @@ -0,0 +1,116 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.interfaces { + + /** + * Makes udpatable items usable by IManager instances. + * + * <p>The Go system decouples manager classes so they remain compile- + * optional for the end user, who must explicitly register an instance + * of each desired manager for use with GoEngine. <i>To uphold this system + * it is extremely important that item classes do not import or make + * direct reference to specific manager classes. If you need to make a + * reference to a manager from any item class, datatype to manager interfaces + * like IManager, not manager classes like OverlapMonitor.</i></p> + * + * @see IManager + * + * @author Moses Gunesch + */ + public interface IManageable extends IUpdatable + { + /** + * IManageable requirement. + * + * @return All animation targets currently being handled. + */ + function getActiveTargets () : Array; + + + /** + * IManageable requirement. + * + * <p>This list is often passed to the <code>isHandling</code> method of other active + * IManageable items. <i>DO NOT return all properties the item handles in general, + * only ones the instance is currently tweening or setting.</i> The list can include + * any custom property names the item defines.</p> + * + * @return All property-strings currently being handled. + */ + function getActiveProperties () : Array; + + + /** + * IManageable requirement: + * + * Return true if any of the property strings passed in overlap with any + * properties being actively handled. + * + * <p><b>Direct matching:</b></p> + * + * <p>First and foremost, test for a direct match with al properties the item + * is currently handling on all targets. For example, if the item is actively + * setting a 'width' property on any of its animation targets: + * <br><br> + * <code>if (properties.indexOf("width")>-1) return true;</code></p> + * + * <p><b>Indirect matching:</b></p> + * + * <p>You must be sure to check for indirect, as well as direct matches. + * This is very important and can at times require some creative thought + * on your part. Try to keep isHandling code effiecient to reduce processing + * and filesize across batches of items.</p> + * + * <ol> + * <li><i>Overlap,</i> like 'width' and 'scaleX'. These would certainly conflict if + * two different Go items were allowed to handle them at once on the same target. + * Overlaps might not always be this obvious, so think creatively.<br><br></li> + * + * <li><i>Multi-property groups.</i> If the item is setting multiple properties at + * once for a single result, such as a bezier-curve tween that operates on both x + * and y, and may also define a custom property like 'bezier', be sure to return + * true if any of those properties are passed in.<br><br></li> + * + * <li><i>Multi-property groups with overlap,</i> in which both of the above occurs. + * Consider a class with custom 'scale' and 'size' properties that tween <i>scaleX/scaleY</i> + * and <i>width/height</i>. Overlap occurs between entire groups of properties: + * <i>scaleX/width/scale/size</i> and <i>scaleY/height/scale/size</i>. You must check + * whether each property passed in conflicts with this item's active properties using + * those groupings to check for any indirect match.</li> + * </ol> + * + * @param properties A list of properties to test for active overlap. + * @return Whether any active overlap occurred with any property passed in. + */ + function isHandling (properties : Array) : Boolean; + + + /** + * IManageable requirement: Normally this method should stop the instance. + * + * @param params Gives more complex managers leeway to send additional information + * like specific targets or properties to release, etc. + */ + function releaseHandling (...params) : void; + + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/IManager.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/IManager.as new file mode 100644 index 0000000000000000000000000000000000000000..279b3d04817708e67bc918e6d022679c64abea3b --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/IManager.as @@ -0,0 +1,132 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.interfaces { + + /** + * Makes an object compatible with <code>GoEngine.addManager()</code> + * <font color="#CC0000">[This section updated recently!]</font></p> + * <p><b>What are managers?</b></p> + * + * <p>Tweens and other animation items are not aware of other items while they + * run; by contrast, manager classes can monitor and interact with many active + * items at once. <code>OverlapMonitor</code>, a manager shipped with GoASAP, + * prevents situations like two different tween instances trying to animate the + * x property of a single sprite at the same time. This type of conflict needs + * a system-level manager that can look at multiple items as they operate. Managers + * can be used to automate any general process within an animation system. + * This sounds dry, but it can be a creative opportunity as well: imagine a manager + * that automatically motion-blurs targets based on their velocity, for example. + * Working at the system level gives you power that you don't have at the GoItem level, + * and opens up a new range of possibilites. For example, a custom game engine would + * be built primarily at the management level.</p> + * + * <p>There is a distinct difference in the Go system between <i>managers</i> and + * <i>utilities</i>, although both typically work with batches of Go items. Utilities + * are tools designed to be directly used at a project level, such as a sequence or + * animation syntax parser (even <code>GoItems</code> like tween classes are essentially + * utilities). In contrast, managers are self-sufficient entities that, once registered + * to <code>GoEngine</code>, operate in the background without requiring any direct + * interaction at runtime.</p> + * + * <p><b>About Go's Decoupled Management system</b></p> + * + * <p>The downside of managers in general is that they can add overhead as they perform + * their additional processes, slowing your system down. Prefab tween engines usually "bake" + * management features into their core code, locking you into any processing cost incurred as + * well as whichever set of features the author decided were important. GoASAP's management + * layer is designed specifically to solve these problems, and is GoASAP's most unique + * architectural feature. It leverages the centralized pulse engine as a registration hub + * for any number of managers, then leaves it up to the end user which managers to register + * per project.</p> + * + * <p>This layer stays <i>optional</i> at all levels: it is optional to make tweens or other + * animation items manageable in the first place (by implementing <code>IManageable</code>), + * but it is very easy to write your own custom managers (that implement <code>IManager</code>). + * Then even after implementation, it still remains optional for the end-user whether to add + * any particular manager to GoEngine at runtime. By choosing not to add any managers if they + * aren't needed in a project, Go can stay ultimately streamlined and limit its footprint to + * just code that is used. It's also very easy to create custom managers to meet the needs + * of a challenging project. You can activate these custom tools at runtime this time, then + * ignore them until needed again. This allows you to tie your custom program code very tightly + * into your animation engine, but keeps those customizations neatly 'decoupled.'</p> + * + * <p><b>Go Manager types</b></p> + * + * <p>Go currently provides two manager interfaces to choose from, <code>IManager</code> and + * <code>ILiveManager</code>. An <code>IManager</code> is notified every time any <code>IManageable</code> + * item is added or removed from GoEngine. This is the interface used by <code>OverlapMonitor</code> + * for example, which only needs to detect conflicts as new items are added. The second interface, + * <code>ILiveManager</code>, is for situations where you want a manager to actively handle items + * as they update.</p> + * + * <p><b>Implementing <code>IManager</code></b></p> + * + * <p>This interface has two methods that are called by <code>GoEngine</code>, <code>reserve()</code> + * and <code>release()</code>. The first method is called when any item that implements <code>IManageable</code> + * is added to the engine, and the second is called when such an item is removed. This means that + * instances of a tween class that implements <code>IManageable</code>, for example, can be + * trapped by the manager while their play cycle is active. Managers can do whatever they want + * with the items, but the <code>IManageable</code> interface ensures that they can always get + * the <i>active animation targets and properties</i> from the item, determine <i>property overlap</i> + * between items, and ask items to <i>stop playing</i> when necessary. There are no rules for what you + * write in the <code>reserve()</code> or <code>release()</code> methods, except that you should not + * call <code>release()</code> directly from <code>reserve()</code>, but instead ask an item to stop via + * a <code>IManageable.releaseHandling()</code> call. <code>GoEngine</code> will call <code>release()</code> + * on the manager once the item has truly been stopped.</p> + * + * <p>You can also extend <code>IManageable</code> to add special functionality that a manager might use + * on an item, or even just to create a new marker datatype without adding any custom methods. This enables + * your custom managers to sniff for a particular interface type in order to determine which items to store, + * monitor, or alter. The general rule is that items like tweens are considered working code, so you might + * end up changing the management implementations on different sets of tweens based on your project needs. + * Regardless of implementation on the manageable side, managers will remain decoupled in that they need + * to be registered into <code>GoEngine</code> to be compiled and used in a project. As a general rule + * you should try to have managers and managed items only reference each other via interfaces so that no + * classes are forced to be compiled until they are used directly in a project.</p> + * + * @see IManageable + * @see org.goasap.managers.OverlapMonitor OverlapMonitor + * @see org.goasap.GoEngine#addManager GoEngine.addManager + * + * @author Moses Gunesch + */ + public interface IManager + { + + /** + * GoEngine reporting that an IManageable is being added to its pulse list. + * + * @param handler IManageable to query + */ + function reserve(handler:IManageable):void; + + + /** + * GoEngine reporting that an IManageable is being removed from its pulse list. + * + * <p>This method should NOT directly stop the item, stopping an item results in + * a release() call from GoEngine. This method should simply remove the item from + * any internal lists and unsubscribe all listeners on the item.</p> + */ + function release(handler:IManageable):void; + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/IPlayable.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/IPlayable.as new file mode 100644 index 0000000000000000000000000000000000000000..d8b37f73cb681fdda1479d7667a8bc3fd1170f51 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/IPlayable.as @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.interfaces { + + /** + * Extends IPlayableBase to define a standard set of play controls. + * + * <p>The most typical way to create a playable class is to extend PlayableBase, + * (which provides state constants and an id property), then manually implement + * this interface to provide play controls.</p> + * + * @see org.goasap.PlayableBase PlayableBase + * @author Moses Gunesch + */ + public interface IPlayable extends IPlayableBase + { + /** + * Start playing. + */ + function start () : Boolean; + + /** + * Stop playing. + */ + function stop () : Boolean; + + /** + * Pause play. + */ + function pause () : Boolean; + + /** + * Resume paused play. + */ + function resume () : Boolean; + + /** + * @param position Index indicating point in animation to skipTo. + * (Remember that you can rename paramters when + * implementing an interface in AS3, for example + * "seconds" or "index" instead of "position.") + */ + function skipTo (position : Number) : Boolean; + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/IPlayableBase.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/IPlayableBase.as new file mode 100644 index 0000000000000000000000000000000000000000..78b067551ae07832657a315a0352a5ebc117ae5e --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/IPlayableBase.as @@ -0,0 +1,29 @@ + +package org.goasap.interfaces { + import flash.events.IEventDispatcher; + + /** + * Defines the portion of the IPlayable interface used by the PlayableBase + * class, which provides a standard set of play-state constants used in Go. + * + * @author Moses Gunesch + */ + public interface IPlayableBase extends IEventDispatcher { + + /** + * Normally this should only return one of the standard play-state + * constants defined in the PlayableBase class. + */ + function get state () : String; + + /** + * An arbitrary id value for the convenient identification of any + * playable instance. + * + * PlayableBase sets this property to an instance-count by default, + * which can be overwritten in program code with any value. + */ + function get playableID () : *; + function set playableID (value: *) : void; + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/IUpdatable.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/IUpdatable.as new file mode 100644 index 0000000000000000000000000000000000000000..df7cbfbdee9897d2bae27ed25488e2c2dbca86b5 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/interfaces/IUpdatable.as @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.interfaces { + + /** + * Makes any object compatible with GoEngine. + * + * @author Moses Gunesch + */ + public interface IUpdatable + { + + /** + * Perform updates on a pulse. + * + * @param currentTime A clock time that should be used instead of getTimer + * in performing update calculations. (The value is usually + * not more than a couple milliseconds different than getTimer + * but using it tightly syncs all items in the timer group + * and can make a perceptible difference.) + */ + function update (currentTime : Number) : void; + + + /** + * Defines the pulse on which update is called. + * + * @return A number of milliseconds for Timer-based updates or GoEngine.ENTER_FRAME (-1) + * for updates synced to the Flash Player's framerate. + */ + function get pulseInterval() : int; + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/items/GoItem.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/items/GoItem.as new file mode 100644 index 0000000000000000000000000000000000000000..7332ef3edb0804f2af7133a6948c73bd47845908 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/items/GoItem.as @@ -0,0 +1,209 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.items { + import org.goasap.GoEngine; + import org.goasap.PlayableBase; + import org.goasap.interfaces.IUpdatable; + + /** + * Abstract base animation class for other base classes like LinearGo and PhysicsGo. + * + * <p>This class extends PlayableBase to add features common to any animation item, + * either linear or physics (LinearGo and PhysicsGo both extend this class). + * Animation items add themselves to GoEngine to run on a pulse, so the IUpdatable + * interface is implemented here, although update() needs to be subclassed.</p> + * + * <p>Animation items should individually implement the standard <code>useRounding</code> + * and <code>useRelative</code> options. Three user-accessible class default settings + * are provided for those and <code>pulseInterval</code>, while play-state constants + * live in the superclass PlayableBase.</p> + * + * @author Moses Gunesch + */ + public class GoItem extends PlayableBase implements IUpdatable + { + // -== Settable Class Defaults ==- + + /** + * Class default for the instance property <code>pulseInterval</code>. + * + * <p>GoEngine.ENTER_FRAME seems to run the smoothest in real-world contexts. + * The open-source TweenBencher utility shows that timer-based framerates like + * 33 milliseconds can perform best for thousands of simultaneous animations, + * but in practical contexts timer-based animations tend to stutter.</p> + * + * @default GoEngine.ENTER_FRAME + * @see #pulseInterval + */ + public static var defaultPulseInterval : Number = GoEngine.ENTER_FRAME; + + /** + * Class default for the instance property <code>useRounding</code>. + * @default false + * @see #useRounding + */ + public static var defaultUseRounding : Boolean = false; + + /** + * Class default for the instance property <code>useRelative</code>. + * @default false + * @see #useRelative + */ + public static var defaultUseRelative : Boolean = false; + + /** + * Alters the play speed for instances of any subclass that factors + * this value into its calculations, such as LinearGo. + * + * <p>A setting of 2 should result in half-speed animations, while a setting + * of .5 should double animation speed. Note that changing this property at + * runtime does not usually affect already-playing items.</p> + * + * <p>This property is a Go convention, and all subclasses of GoItem (on the + * LinearGo base class level, but not on the item level extending LinearGo) + * need to implement it individually.</p> + * @default 1 + */ + public static var timeMultiplier : Number = 1; + + // -== Public Properties ==- + + /** + * Required by IUpdatable: Defines the pulse on which <code>update</code> is called. + * + * <p> + * Can be a number of milliseconds for Timer-based updates or + * <code>GoEngine.ENTER_FRAME</code> (-1) for updates synced to the + * Flash Player's framerate. If not set manually, the class + * default <code>defaultPulseInterval</code> is adopted. + * </p> + * + * @see #defaultPulseInterval + * @see org.goasap.GoEngine#ENTER_FRAME GoEngine.ENTER_FRAME + */ + public function get pulseInterval() : int { + return _pulse; + } + public function set pulseInterval(interval:int) : void { + if (_state==STOPPED && (interval >= 0 || interval==GoEngine.ENTER_FRAME)) { + _pulse = interval; + } + } + + /** + * CONVENTION ALERT: <i>This property is considered a Go convention, and subclasses must + * implement it individually by calling the correctValue() method on all calculated values + * before applying them to targets.</i> + * + * <p>The correctValue method fixes NaN's as 0 and applies Math.round if useRounding is active.</p> + * + * @see correctValue() + * @see LinearGo#onUpdate() + */ + public var useRounding : Boolean = defaultUseRounding; + + /** + * CONVENTION ALERT: <i>This property is considered a Go convention, and subclasses must implement + * it individually.</i> Indicates that values should be treated as relative instead of absolute. + * + * <p>When true, user-set values should be calculated as + * relative to their existing value ("from" vs. "to"), when possible. + * See an example in the documentation for <code>LinearGo.start</code>. + * </p> + * <p> + * Items that handle more than one property at once, such as a bezier + * curve, might want to implement a useRelative option for each property + * instead of using this overall item property, which is included here + * to define a convention for standard single-property items. + * </p> + * + * @see #defaultUseRelative + */ + public var useRelative : Boolean = defaultUseRelative; + + + // -== Protected Properties ==- + + /** + * @private + */ + protected var _pulse : int = defaultPulseInterval; + + // -== Public Methods ==- + + /** + * Constructor. + */ + public function GoItem() { + super(); + } + + /** + * IMPORTANT: <i>Subclasses need to implement this functionality + * individually</i>. When updating animation targets, always call + * <code>correctValue</code> on results first. This corrects any + * NaN's to 0 and applies Math.round if <code>useRounding</code> + * is active. + * + * <p>For example, a LinearGo <code>onUpdate</code> method might contain:</p> + * <pre> + * target[ prop ] = correctValue(start + (change * _position)); + * </pre> + * + * @see #useRounding + * @see #defaultUseRounding + */ + public function correctValue(value:Number):Number + { + if (isNaN(value)) + return 0; + + if (useRounding) // thanks John Grden + return value = ((value%1==0) + ? value + : ((value%1>=.5) + ? int(value)+1 + : int(value))); + + return value; + } + + /** + * Required by IUpdatable: Perform updates on a pulse. + * + * <p>The <i>currentTime</i> parameter enables tight visual syncing of groups of items. + * To ensure the tightest possible synchronization, do not set any internal start-time + * vars in the item until the first update() call is received, then set to the currentTime + * provided by GoEngine. This ensures that groups of items added in a for-loop all have the + * exact same start times, which may otherwise differ by a few milliseconds.</p> + * + * @param currentTime A clock time that should be used instead of getTimer + * to store any start-time vars on the first update call + * and for performing update calculations. The value is usually + * no more than a few milliseconds different than getTimer, + * but using it tightly syncs item groups visually. + */ + public function update(currentTime : Number) : void { + // override this method. + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/items/LinearGo.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/items/LinearGo.as new file mode 100644 index 0000000000000000000000000000000000000000..ceaa8598d1ca70716f1405685f8426d16845e145 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/items/LinearGo.as @@ -0,0 +1,854 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.items { + import flash.utils.getTimer; + + import org.goasap.GoEngine; + import org.goasap.errors.EasingFormatError; + import org.goasap.events.GoEvent; + import org.goasap.interfaces.IPlayable; + import org.goasap.managers.LinearGoRepeater; + + /** + * Dispatched during an animation's first update after the delay + * has completed, if one was set. Any number of callbacks may also be + * associated with this event using <code>addCallback</code>. + * @eventType org.goasap.events.START + */ + [Event(name="START", type="org.goasap.events.GoEvent")] + + /** + * Dispatched on the animation's update pulse. Any number of callbacks + * may also be associated with this event using <code>addCallback</code>. + * @eventType org.goasap.events.UPDATE + */ + [Event(name="UPDATE", type="org.goasap.events.GoEvent")] + + /** + * Dispatched when pause() is called successfully. Any number of callbacks + * may also be associated with this event using <code>addCallback</code>. + * @eventType org.goasap.events.PAUSE + */ + [Event(name="PAUSE", type="org.goasap.events.GoEvent")] + + /** + * Dispatched when resume() is called successfully. Any number of callbacks + * may also be associated with this event using <code>addCallback</code>. + * @eventType org.goasap.events.RESUME + */ + [Event(name="RESUME", type="org.goasap.events.GoEvent")] + + /** + * Dispatched at the end of each cycle if the tween has more than one. + * Any number of callbacks may also be associated with this event using + * <code>addCallback</code>. + * @eventType org.goasap.events.CYCLE + */ + [Event(name="CYCLE", type="org.goasap.events.GoEvent")] + + /** + * Dispatched if an animation is manually stopped. Any number of callbacks + * may also be associated with this event using <code>addCallback</code>. + * @eventType org.goasap.events.STOP + */ + [Event(name="STOP", type="org.goasap.events.GoEvent")] + + /** + * Dispatched on an animation's final update, just after the last update event. + * Any number of callbacks may also be associated with this event using + * <code>addCallback</code>. + * @eventType org.goasap.events.COMPLETE + */ + [Event(name="COMPLETE", type="org.goasap.events.GoEvent")] + + /** + * LinearGo extends the base class GoItem to define a playable A-to-B animation. + * + * <p><b>LinearGo: A very simple tween</b></p> + * + * <p>A LinearGo instance is a playable object that animates a single number. It dispatches events + * and callbacks associated with the animation's start, update and completion. Instances can be used + * directly, or easily subclassed to build custom tweening APIs. LinearGo extends GoItem, which + * provides basic settings shared by physics and tween items. These include play-state contants and + * a <code>state</code> property, <code>pulseInterval</code>, and the two common animation options + * <code>useRounding</code> and <code>useRelative</code>.</p> + * + * <p>The tween can be customized using the instance properties <code>duration</code>, <code>easing</code> + * and <code>delay</code>. The number crunched by a LinearGo is readable in its <code>position</code> + * property. This number always starts at 0 and completes at 1, regardless of the tween's duration + * or easing (those parameters are factored in to produce accurate fractional in-between values). + * As the tween runs, you can use <code>position</code> as a multiplier to animate virtually anything: + * motion, alpha, a sound level, the values in a ColorTransform, BitmapFilter, a 3D scene, and so on. + * Note that at times position may be less than 0 or greater than 1 depending on the easing function.</p> + * + * <p>The START event occurs just before the first update (after the delay). UPDATE is fired once on + * <i>every</i> update pulse, and COMPLETE just after the final update. The STOP event is fired by LinearGo + * only if a tween is stopped before it completes. Additional events are fired on PAUSE, RESUME and at + * the end of each CYCLE if the tween plays more than one cycle. Besides standard events, you can store + * callback functions (method-closures) using <code>addCallback</code>. Any number of callbacks can be + * associated with each GoEvent type. This alternative to the standard event model was included in + * LinearGo since it's a common feature of many modern tweening APIs, and very slightly more efficient + * than standard events.</p> + * + * <p>LinearGo can play multiple back-and-forth tween cycles or repeat forward-play any number of times. + * This functionality is handled by the LinearGo's <code>repeater</code> instance, which has settings for + * alternate easing on reverse-cycles, infinite cycling, plus <code>currentCycle</code> and <code>done</code> + * state properties.</p> + * + * <p><b>Subclassing to create custom tweens</b></p> + * + * <p><i>Important: Store your custom tween classes in a package bearing your own classpath, not in the core + * package! This will help avoid confusion with other authors' work.</i></p> + * + * <p>It's possible to build virtually any tweening API over LinearGo because all of the specifics are left + * up to you: target objects, tweenable properties, tween values — and importantly, the datatypes of all of these.</p> + * + * <p>A basic subclass can be created in three steps: Gathering target & property information, subclassing the + * <code>start</code> method to set up the tween, and finally subclassing the <code>onUpdate</code> method + * to affect the tween. The first step, gathering tween target and property information, can be done by writing + * getter/setter properties, customizing the constructor, or both. Consider various options such as allowing for + * single vs. multiple target objects, open vs. specific tween properties, and so on. The next step, subclassing + * <code>start</code>, involves figuring the tween's amount of change and implementing a standard Go convention, + * <code>useRelative</code>. This option should enable the user to declare tween values as relative to existing + * values instead of as fixed absolutes. In the final step, you subclass <code>onUpdate</code> to apply the tween, + * using the <code>_position</code> calculated by this base class:</p> + * + * <pre>target[ propName ] = super.correctValue(start + change * _position);</pre> + * + * <p>The helper method <code>correctValue</code> is provided in the superclass GoItem, to clean up NaN values + * and apply rounding when <code>useRounding</code> is activated. That's it — events and callbacks are + * dispatched by LinearGo, so subclasses can remain simple.</p> + * + * <p>An optional fourth step will make your custom tween compatible with Go managers. To do this, implement + * the IManageable interface. (OverlapMonitor prevents different tween instances from handling the same + * property at once; you can build other managers as well.)</p> + * + * {In the game of Go a black or white stone is called a go-ishi.} + * + * @author Moses Gunesch + */ + public class LinearGo extends GoItem implements IPlayable + { + // -== Settable Class Defaults ==- + + /** + * Class default for the instance property delay. + * @default 0 + * @see #delay + */ + public static var defaultDelay : Number = 0; + + /** + * Class default for the instance property duration. + * @default 1 + * @see #duration + */ + public static var defaultDuration : Number = 1; + + /** + * Class default for the instance property easing. + * Note that this property is left null until the first LinearGo + * is instantiated, at which time it is set to Quintic.easeOut. + * @default fl.motion.easing.Quintic.easeOut + * @see #easing + */ + public static var defaultEasing:Function; + + /** + * Normal default easing, this is Quintic.easeOut. + * (The two default easings in this class are included because there's + * currently no single easing classpath shared between Flash & Flex.) + */ + public static function easeOut(t:Number, b:Number, c:Number, d:Number) : Number { + return c * ((t = t / d - 1) * t * t * t * t + 1) + b; + }; + + // -== Class Methods ==- + + /** + * An alternative default easing with no acceleration. + * (The two default easings in this class are included because there's + * currently no single easing classpath shared between Flash & Flex.) + */ + public static function easeNone(t:Number, b:Number, c:Number, d:Number) : Number { + return c * t / d + b; + }; + + /** + * A quick one-time setup command that lets you turn on useFrames mode + * as a default for all new tweens and adjust some related settings. + * (Note that useFrames mode is normally only used for specialty situations.) + * + * @param defaultToFramesMode Sets an internal default so all new LinearGo instances + * will be set to use framecounts for their delay and duration. + * Also sets GoItem.defaultPulseInterval to enterframe which is + * most normal for frame-based updates. + * @param useZeroBasedFrameIndex Normally currentFrame reads 1 on first update, like the Flash + * timeline starts at Frame 1. Set this option to use a zero-based + * index on all tweens instead. + * @see #useFrames + * @see #currentFrame + */ + public static function setupUseFramesMode( defaultToFramesMode: Boolean = true, + useZeroBasedFrameIndex: Boolean=false):void { + GoItem.defaultPulseInterval = GoEngine.ENTER_FRAME; + _useFramesMode = defaultToFramesMode; + if (useZeroBasedFrameIndex) { _framesBase = 0; } + } + + // -== Pulic Properties ==- + + /** + * Number of seconds after start() call that the LinearGo begins processing. + * <p>If not set manually, the class default defaultDelay is adopted.</p> + * @see #defaultDelay + */ + public function get delay():Number { + return _delay; + } + public function set delay(seconds:Number):void { + if (_state==STOPPED && seconds >= 0) { + _delay = seconds; + } + } + + /** + * Number of seconds the LinearGo takes to process. + * <p>If not set manually, the class default defaultDuration is adopted.</p> + * @see #defaultDuration + */ + public function get duration():Number { + return _duration; + } + public function set duration(seconds:Number):void { + if (_state==STOPPED && seconds >= 0) { + _duration = seconds; + } + } + + /** + * Any standard easing-equation function such as the ones found in + * the Flash package fl.motion.easing or the flex package mx.effects.easing. + * + * <p>If not set manually, the class default defaultEasing is adopted. An error + * is thrown if the function does not follow the typical format. For easings + * that accept more than four parameters use <code>extraEasingParams</code>. + * </p> + * + * @see #defaultEasing + * @see #extraEasingParams + */ + public function get easing():Function { + return _easing; + } + public function set easing(type:Function):void { + if (_state==STOPPED) { + try { + if (type(1,1,1,1) is Number) { + _easing = type; + return; + } + } catch (e:Error) {} + throw new EasingFormatError(); + } + } + + /** + * Additional parameters to pass to easing functions that accept more than four. + * @see #easing + */ + public function get extraEasingParams() : Array { + return _extraEaseParams; + } + public function set extraEasingParams(params:Array):void { + if (_state==STOPPED && params is Array && params.length>0) { + _extraEaseParams = params; + } + } + + /** + * A LinearGoRepeater instance that defines options for repeated + * or back-and-forth cycling animation. + * + * <p>You may pass a LinearGoRepeater instance to the constructor's + * repeater parameter to set all options at instantiation. The + * repeater's cycles property can be set to an integer, or + * to Repeater.INFINITE or 0 to repeat indefinitely, and checked using + * <code>linearGo.repeater.currentCycle</code>. LinearGoRepeater's + * <code>reverseOnCycle</code> flag is true by default, which + * causes animation to cycle back and forth. In that mode you can + * also specify a separate easing function (plus extraEasingParams) + * to use for the reverse animation cycle. For example, an easeOut + * easing with an easeIn easingOnCycle will produce a more + * natural-looking result. If <code>reverseOnCycle</code> is disabled, + * the animation will repeat its play forward each time.</p> + * + * <p>(The repeater property replaces the cycles, easeOnCycle and + * currentCycle parameters in earlier releases of LinearGo).</p> + * + * @see org.goasap.managers.LinearGoRepeater LinearGoRepeater + */ + public function get repeater(): LinearGoRepeater { + return _repeater; + } + + /** + * When useFrames mode is activated, duration and delay are treated + * as update-counts instead of time values. + * + * <p>(This mode is normally only used for specialty situations.)</p> + * + * <p>Using this feature with a pulseInterval of GoEngine.ENTER_FRAME + * will result in a frame-based update that mimics the behavior of the + * flash timeline. As with the timeline, frame-based tween durations can + * vary based on the host computer's processor load and other factors.</p> + * + * <p>The <code>setupUseFramesMode()</code> class method is a much easier + * way to use frames in your project, instead of setting this property + * on every tween individually.</p> + * + * @see #setupUseFramesMode() + */ + public function set useFrames(value:Boolean):void { + if (_state==STOPPED) + _useFrames = value; + } + public function get useFrames():Boolean { + return _useFrames; + } + + /** + * A number between 0 and 1 representing the current tween value. + * + * <p>Use this number as a multiplier to apply values to targets + * across time.<p> + * + * <p>Here's an example of what an overridden update method might contain:</p> + * <pre> + * super.update(currentTime); + * target[ propName ] = super.correctValue(startValue + change*_position); + * </pre> + * @see #timePosition + */ + public function get position():Number { + return _position; + } + + /** + * For time-based tweens, returns a time value which is negative during delay + * then spans the tween duration in positive values, ignoring repeat cycles. + * + * <p>In useFrames mode, this getter differs from <code>currentFrame</code> + * significantly. Instead of constantly increasing through all cycles as if + * tweens were back-to-back in a timeline layer, this method acts more like + * a single tween placed at frame 1, with a timeline playhead that scans back + * and forth or loops during cycles. So for a 10-frame tween with a 5-frame + * delay and 2 repeater cycles with reverseOnCycle set to true, this method + * will return values starting at -5, start the animation at 1, play to 10 + * then step backward to 1 again.</p> + * + * @see #position + * @see #currentFrame + * @see #duration + * @see #delay + * @see #setupUseFramesMode() + */ + public function get timePosition():Number { + if (_state==STOPPED) + return 0; + var mult:Number = Math.max(0, timeMultiplier); + if (_useFrames) { + if (_currentFrame>_framesBase) { + var cf:uint = _currentFrame-_framesBase; + if (_repeater.direction==-1) { + return ((_duration-1) - cf%_duration) + _framesBase; + } + return cf%_duration + _framesBase; + } + return _currentFrame; + } + return ((getTimer()-_startTime) / 1000 / mult); + } + + /** + * Returns the number of updates that have occured since start. + * + * <p>This update-count property does not necessarily correspond + * to the actual player framerate, just the instance's pulseInterval.</p> + * + * <p>This property is set up to mirror the flash timeline. Imagine a timeline + * layer with a delay being a set of blank frames followed by the tween, + * followed by subsequent cycles as additional tweens: this is the way + * the <code>currentFrame</code> property works. Its first value is 1 by + * default, which can be changed to 0 in <code>setupUseFramesMode()</code>. + * This differs significantly from <code>timePosition</code>, which places + * the start of a single instance of the tween at frame 1 and steps its + * values from negative during delay then cycling through the single tween.</p> + * + * + * @see #useFrames + * @see #setupUseFramesMode() + * @see #timePosition + */ + public function get currentFrame():uint { + return _currentFrame; + } + + // -== Protected Properties ==- + + /** @private */ + protected static var _useFramesMode : Boolean = false; + + /** @private */ + protected static var _framesBase : Number = 1; + + /** @private */ + protected var _delay : Number; + + /** @private */ + protected var _duration : Number; + + /** @private */ + protected var _tweenDuration : Number; + + /** @private */ + protected var _easing : Function; + + /** @private */ + protected var _easeParams : Array; + + /** @private */ + protected var _extraEaseParams : Array; + + /** @private */ + protected var _repeater : LinearGoRepeater; + + /** @private */ + protected var _currentEasing : Function; + + /** @private */ + protected var _useFrames : Boolean; + + /** @private */ + protected var _started : Boolean = false; + + /** @private */ + protected var _currentFrame : int; + + /** @private */ + protected var _position : Number; + + /** @private */ + protected var _change : Number; + + /** @private */ + protected var _startTime : Number; + + /** @private */ + protected var _endTime : Number; + + /** @private */ + protected var _pauseTime : Number; + + /** @private */ + protected var _callbacks : Object = new Object(); // In tests, creating this object up front is more efficient. + + // -== Public Methods ==- + + /** + * The inputs here are not a convention, subclasses should design + * their own constructors appropriate to usage. They are provided + * here primarily as a convenience for subclasses. However, do not + * omit calling super() from subclass constructors: LinearGo's + * constructor sets and validates class defaults and sets up the + * repeater instance. + */ + public function LinearGo( delay : Number=NaN, + duration : Number=NaN, + easing : Function=null, + extraEasingParams : Array=null, + repeater : LinearGoRepeater=null, + useRelative : Boolean=false, + useRounding : Boolean=false, + useFrames : Boolean=false, + pulseInterval : Number=NaN ) { + // validate & set class defaults first + if (isNaN(defaultDelay)) + defaultDelay = 0; + if (isNaN(defaultDuration)) + defaultDuration = 1; + try { this.easing = defaultEasing; } + catch (e1:EasingFormatError) { defaultEasing = easeOut; } + // set params + if (!isNaN(delay)) _delay = delay; + else _delay = defaultDelay; + if (!isNaN(duration)) _duration = duration; + else _duration = defaultDuration; + try { this.easing = easing; } + catch (e2:EasingFormatError) { + if (easing!=null) { throw e2; } // user passed invalid easing function + this.easing = defaultEasing; + } + if (extraEasingParams) _extraEaseParams = extraEasingParams; + if (useRelative) this.useRelative = true; + if (useRounding) this.useRounding = true; + _useFrames = (useFrames || _useFramesMode); + if (!isNaN(pulseInterval)) _pulse = pulseInterval; + if (repeater!=null) _repeater = repeater; // repeater setup makes super() call important for all subclasses. + else _repeater = new LinearGoRepeater(); + _repeater.setParent(this); + } + + /** + * Starts play for this LinearGo instance using GoEngine. + * + * <p>CONVENTION ALERT: If <code>useRelative</code> is true, calculate tween values + * relative to the target object's existing value as in the example below.</p> + * + * <p>Most typically you should also store the tween's start and change values + * for later use in <code>onUpdate</code>.</p> + * + * <pre> + * protected var _target : DisplayObject; + * protected var _width : Number; + * protected var _changeWidth : Number; + * + * public function start():Boolean + * { + * if (!_target || !_width || isNaN(_width)) + * return false; + * + * _startWidth = _target.width; + * + * if (useRelative) { + * _changeWidth = _width; + * } else { + * _changeWidth = (_width - _startWidth); + * } + * + * return (super.start()); + * } + * </pre> + * + * @return Successful addition of the item to GoEngine + * + * @see GoItem#useRelative + * @see #onUpdate() + */ + public function start() : Boolean { + stop(); // does nothing if already stopped. + if (GoEngine.addItem(this)==false) + return false; + reset(); + _state = (_delay > 0 ? PLAYING_DELAY : PLAYING); // has to be set here since delay is not included in PlayableBase. + // note: start event is dispatched on the first update cycle for tighter cross-item syncing. + return true; + } + + /** + * Ends play for this LinearGo instance and dispatches a GoEvent.STOP + * event if the tween is incomplete. This method does not typically + * require subclassing. + * + * @return Successful removal of the item from GoEngine + */ + public function stop() : Boolean { + if (_state==STOPPED || GoEngine.removeItem(this)==false) + return false; + _state = STOPPED; + var completed:Boolean = (_easeParams!=null && _position==_easeParams[1]+_change); + reset(); + if (!completed) // otherwise a COMPLETE event was dispatched. + dispatch( GoEvent.STOP ); + return true; + } + + /** + * Pauses play (including delay) for this LinearGo instance. + * This method does not typically require subclassing. + * + * @return Success + * @see #resume() + * @see org.goasap.GoEngine#setPaused GoEngine.setPaused() + */ + public function pause() : Boolean { + if (_state==STOPPED || _state==PAUSED) + return false; + _state = PAUSED; + _pauseTime = (_useFrames ? _currentFrame : getTimer()); // This causes update() to skip processing. + dispatch(GoEvent.PAUSE); + return true; + } + + /** + * Resumes previously paused play, including delay. + * This method does not typically require subclassing. + * + * @return Success + * @see #pause() + * @see org.goasap.GoEngine#setPaused GoEngine.setPaused() + */ + public function resume() : Boolean { + if (_state != PAUSED) + return false; + var currentTime:Number = (_useFrames ? _currentFrame : getTimer()); + setup(currentTime - (_pauseTime - _startTime)); + _pauseTime = NaN; + _state = (_startTime > currentTime ? PLAYING_DELAY : PLAYING); + dispatch(GoEvent.RESUME); + return true; + } + + /** + * Skips to a point in the tween's duration and plays, from any state. + * This method does not typically require subclassing. + * + * <p>If GoItem.timeMultiplier is set to a custom value, you should still pass a + * seconds value based on the tween's real duration setting.</p> + * + * @param time Seconds or frames to jump to across all cycles, where 0 (or 1 in useFramesMode) + * represents tween start, numbers greater than duration represent higher repeat cycles, + * and negative numbers represent a new delay to play before tween start. + * @return Success + * @see #timePosition + */ + public function skipTo(time : Number) : Boolean + { + if (_state==STOPPED) { + if (start()==false) + return false; + } + if (isNaN(time)) { time = 0; } + var mult:Number = Math.max(0, timeMultiplier) * (_useFrames ? 1 : 1000); + var startTime:Number; + var currentTime:Number; + if (time < _framesBase) { // Negative value: rewind and add a new delay. + _repeater.reset(); + if (_position>0) { skipTo(_framesBase); } // skips to start so new pause occurs in starting position + } + else { + time = _repeater.skipTo(_duration, time-_framesBase); // sets cycles and returns new position + } + if (_useFrames) { + startTime = _framesBase; + currentTime = _currentFrame = Math.round(time*mult); + } + else { + currentTime = getTimer(); + startTime = (currentTime - (time * mult)); // skipTo operation is performed by altering the tween's start & end times. + } + setup(startTime); + _state = (_startTime > currentTime ? PLAYING_DELAY : PLAYING); + update(currentTime); // sets _position + return true; + } + + /** + * An alternative to subscribing to events is to store callbacks. You can + * associate any number of callbacks with the primary GoEvent types START, + * UPDATE, COMPLETE, and STOP (only fired if the tween is stopped before it + * completes). + * + * <p> + * Note that there is little difference between using callbacks and events. + * Both are common techniques used in many various modern tweening APIs. Callbacks + * are slightly faster, but this won't normally be noticeable unless thousands of + * tweens are being run at once. + * </p> + * + * @param closure A reference to a callback function + * @param type Any GoEvent type constant, the default is COMPLETE. + * @see #removeCallback + * @see org.goasap.events.GoEvent GoEvent + */ + public function addCallback(closure : Function, type : String=GoEvent.COMPLETE):void { + if (!_callbacks[ type ]) + _callbacks[ type ] = new Array(); + var a:Array = (_callbacks[ type ] as Array); + if (a.indexOf(closure)==-1) + a.push(closure); + } + + /** + * Removes a method closure previously stored using addCallback. + * + * @param closure A reference to a function + * @param type A GoEvent constant, default is COMPLETE. + * @see #addCallback + * @see org.goasap.events.GoEvent GoEvent + */ + public function removeCallback(closure : Function, type : String=GoEvent.COMPLETE):void { + var a:Array = (_callbacks[ type ] as Array); + if (a) + while (a.indexOf(closure)>-1) + a.splice(a.indexOf(closure), 1); + } + + /** + * Performs tween calculations on GoEngine pulse. + * + * <p>Subclass <code>onUpdate</code> instead of this method. + * + * @param currentTime Clock time for the current block of updates. + * @see #onUpdate() + */ + override public function update(currentTime:Number) : void + { + if (_state==PAUSED) + return; + + _currentFrame ++; + if (_useFrames) + currentTime = _currentFrame; + + if (isNaN(_startTime)) // setup() must be called once prior to tween's 1st update. + setup(currentTime); // This is done here, not in start, for tighter syncing of items. + + if (_startTime > currentTime) + return; // still PLAYING_DELAY + + // (1.) Set _position and determine primary update type. + var type:String = GoEvent.UPDATE; + if (currentTime < _endTime) { // start, update... + if (!_started) + type = GoEvent.START; + _easeParams[0] = (currentTime - _startTime); + _position = _currentEasing.apply(null, _easeParams); // update position using easing function + } + else { // complete, cycle... + _position = _easeParams[1] + _change; // set absolute 1 or 0 position at end of cycle + type = (_repeater.hasNext() ? GoEvent.CYCLE : GoEvent.COMPLETE); + } + + // (2.) Run onUpdate() passing the primary update type, then + // (3.) dispatch up to three events in correct order. + onUpdate(type); + if (!_started) { + _state = PLAYING; + _started = true; + dispatch(GoEvent.START); + } + dispatch(GoEvent.UPDATE); + if (type==GoEvent.COMPLETE) { + stop(); + dispatch(GoEvent.COMPLETE); + } + else if (type==GoEvent.CYCLE) { + _repeater.next(); + dispatch(GoEvent.CYCLE); + _startTime = NaN; // causes setup() to be called again on next update to prep next cycle. + } + } + + // -== Protected Methods ==- + + /** + * Subclass this method (instead of the update method) for simplicity. + * + * <p>Use this method to manipulate targets based on the current _position + * setting, which is a 0-1 multiplier precalculated to the tween's position + * based on its easing style and the current time in the tween.</p> + * + * <p>CONVENTION ALERT: To implement the Go convention <code>useRounding</code>, + * always call GoItem's <code>correctValue()</code> method on each calculated + * tween value before you apply it to a target. This corrects NaN to 0 and + * rounds the value if <code>useRounding</code> is true.</p> + * + * Example: + * <pre> + * override protected function onUpdate(type:String):void + * { + * target[ propName ] = super.correctValue(startValue + change*_position); + * } + * </pre> + * + * @param type A constant from the class GoEvent: START, UPDATE, CYCLE, or COMPLETE. + * @see GoItem#correctValue() + * @see GoItem#useRounding + * @see #update() + */ + protected function onUpdate(type : String) : void + { + // Subclass this method and start to implement your tween class. + } + + /** + * @private + * Internal setup routine used by start() and other methods. + * + * @param time Tween start time based on getTimer + */ + protected function setup(startTime : Number) : void + { + _startTime = startTime; + var mult:Number = Math.max(0, timeMultiplier) * (_useFrames ? 1 : 1000); + _tweenDuration = (_useFrames ? Math.round(_duration * mult)-1 : (_duration * mult)); + _endTime = _startTime + _tweenDuration; + if (!_started) { + var d:Number = (_useFrames ? Math.round(_delay * mult) : (_delay * mult)); + _startTime += d; + _endTime += d; + } + // Set up a tween cycle: _currentEasing, _change, _position, and _easeParams. + // Be sure _repeater is updated before this call so the next cycle gets set up. + var useCycleEase:Boolean = _repeater.currentCycleHasEasing; + _currentEasing = (useCycleEase ? _repeater.easingOnCycle : _easing); + var extras:Array = (useCycleEase ? _repeater.extraEasingParams : _extraEaseParams); + _change = _repeater.direction; + _position = (_repeater.direction==-1 ? 1 : 0); + _easeParams = new Array(0, _position, _change, _tweenDuration); // stored to reduce runtime object-creation + if (extras) _easeParams = _easeParams.concat(extras); + } + + /** + * @private + * Internal, dispatches events and executes callbacks of any pre-verified type. + * + * @param type Verified in addCallback, not in this method. + * @see #org.goasap.events.GoEvent GoEvent + */ + protected function dispatch(type:String):void + { + var a:Array = (_callbacks[ type ] as Array); + if (a) + for each (var callback:Function in a) + callback(); + if (hasEventListener(type)) + dispatchEvent(new GoEvent( type )); + } + + /** + * @private + */ + protected function reset() : void { + _position = 0; + _change = 1; + _repeater.reset(); + _currentFrame = _framesBase-1; + _currentEasing = _easing; + _easeParams = null; + _started = false; + _pauseTime = NaN; + _startTime = NaN; + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/items/PhysicsGo.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/items/PhysicsGo.as new file mode 100644 index 0000000000000000000000000000000000000000..89ea2384e4b719921857c6274f9af5e64fd2f6f0 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/items/PhysicsGo.as @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.items { + + /** + * Yet to be written - Physics guru wanted! + * + * @author Moses Gunesch + */ + public class PhysicsGo extends GoItem { + + public function PhysicsGo() { + super(); + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/managers/LinearGoRepeater.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/managers/LinearGoRepeater.as new file mode 100644 index 0000000000000000000000000000000000000000..1b4f03428bdeccb82fa1b39e4f94cc428c44c441 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/managers/LinearGoRepeater.as @@ -0,0 +1,104 @@ +/** + * Copyright (c) 2008 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.managers { + + /** + * An iterator used by LinearGo instances to track repeat play. + * @see org.goasap.items.LinearGo LinearGo + */ + public class LinearGoRepeater extends Repeater { + + /** + * Whether tween direction should reverse every other cycle. + */ + public function get reverseOnCycle() : Boolean { + return _reverseOnCycle; + } + public function set reverseOnCycle(value : Boolean):void { + if (unlocked()) + _reverseOnCycle = value; + } + + /** + * Current play direction depending on reverseOnCycle and currentCycle. + * @return 1 for forward, -1 for reverse. + */ + public function get direction() : int { + if (_reverseOnCycle && _currentCycle%2==1) { + return -1; + } + return 1; + } + + /** + * Storage for optional secondary easing to use on reverse cycles. + */ + public function get easingOnCycle() : Function { + return _easingOnCycle; + } + public function set easingOnCycle(value : Function):void { + if (unlocked()) + _easingOnCycle = value; + } + + /** + * Additional parameters to use with easingOnCycle if the function accepts more than four. + */ + public function get extraEasingParams() : Array { + return _extraEasingParams; + } + public function set extraEasingParams(value : Array):void { + if (unlocked()) + _extraEasingParams = value; + } + + /** + * @private + * For use by LinearGo, simple way to see if easingOnCycle should be used in the current cycle. + */ + public function get currentCycleHasEasing() : Boolean { + return (_reverseOnCycle && _currentCycle%2==1 && _easingOnCycle!=null); + } + + /** @private */ + protected var _reverseOnCycle: Boolean = false; + + /** @private */ + protected var _easingOnCycle: Function; + + /** @private */ + protected var _extraEasingParams: Array; + + /** + * @param cycles Number of times to play the LinearGo tween. + * @param reverseOnCycle Whether tween direction should reverse every other cycle. + * @param easingOnCycle Storage for optional secondary easing to use on reverse cycles. + * @param extraEasingParams Additional parameters to use with easingOnCycle if the function accepts more than four. + */ + public function LinearGoRepeater(cycles: uint=1, reverseOnCycle:Boolean=true, easingOnCycle: Function=null, extraEasingParams: Array=null) { + super(cycles); + _reverseOnCycle = reverseOnCycle; + _easingOnCycle = easingOnCycle; + _extraEasingParams = extraEasingParams; + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/managers/OverlapMonitor.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/managers/OverlapMonitor.as new file mode 100644 index 0000000000000000000000000000000000000000..a3e7a15e4ea8cd4c41d28eee2b33f588c73c1454 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/managers/OverlapMonitor.as @@ -0,0 +1,128 @@ + +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.managers { + import flash.utils.Dictionary; + + import org.goasap.interfaces.IManageable; + import org.goasap.interfaces.IManager; + + /** + * Calls <code>releaseHandling()</code> on currently-active items when + * property-handling overlap is detected (like two tweens trying to set + * the same sprite's x property), as new items are added to GoEngine. + * + * <p>To activate this manager call the following line one time:</p> + * <pre>GoEngine.addManager( new OverlapMonitor() );</pre> + * + * {In the game of Go, a superko is a rule that prevents a potentially + * infinite competition - ko - over the same space.} + * + * @see org.goasap.interfaces.IManager IManager + * @see org.goasap.interfaces.IManageable IManageable + * @see org.goasap.GoEngine GoEngine + * + * @author Moses Gunesch + */ + public class OverlapMonitor implements IManager + { + /** + * A set of Dictionaries by target object. Targets are indexed + * because they are the primary point of overlap to check first. + */ + protected var handlers : Dictionary = new Dictionary(false); + + /** + * Tracks subdictionary lengths. + */ + protected var counts : Dictionary = new Dictionary(false); + + /** + * Sets an IManageable as reserving its target/property combinations. + * + * @param handler IManageable to reserve + */ + public function reserve(handler:IManageable):void + { + // ======================================================================================= + // Step-by-step: Items are 'reserved' or stored in a Dictionary. + // When a new item says it's handling the same target as a stored item, the stored item + // is asked whether the new item's properties conflict. If so, the old item is 'released' + // from its duties. (Tip: 'handlers' here are GoItems like tweens, not functions.) + // ======================================================================================= + + + var targs:Array = handler.getActiveTargets(); + var props:Array = handler.getActiveProperties(); + if (!targs || !props || targs.length==0 || props.length==0) + return; + + for each (var targ:Object in targs) + { + if (handlers[ targ ]==null) { + // (I switched to using sub-dictionaries w/ counters, since it may be a hair faster than Array. + // Strong keys are fine here since GoEngine stores and will release() all active items.) + handlers[ targ ] = new Dictionary(false); + handlers[ targ ][ handler ] = true; + counts[ targ ] = 1; + continue; + } + + var targ_handlers: Dictionary = (handlers[ targ ] as Dictionary); // as in, 'active tweens handling a same Sprite' + if (targ_handlers[ handler ]) continue; // safety (handler already reserved) + + // keep before isHandling() tests + targ_handlers[ handler ] = true; + counts[ targ ] ++; + + for (var other:Object in targ_handlers) { + if (other!=handler) + if ((other as IManageable).isHandling(props)) { // Ask each existing handler to report overlap. + (other as IManageable).releaseHandling(); // Items should stop themselves on this call. + // GoEngine will then call release() back on this class which will clear the item out. + } + } + } + } + + /** + * Releases an IManageable from being monitored. Does not call releaseHandling() on instances, + * since this method is called after an instance has already removed itself from the engine. + * + * @param handler The IManageable to remove from internal lists. + */ + public function release(handler:IManageable):void + { + var targs:Array = handler.getActiveTargets(); + for each (var targ:Object in targs) { + if (handlers[ targ ] && handlers[ targ ][ handler ]!=null) { + delete handlers[ targ ][ handler ]; + counts[ targ ] --; // don't alter this syntax. (Flex doesn't like --counts[targ]) + if ( counts[ targ ] == 0 ) { + delete handlers[ targ ]; + delete counts[ targ ]; + } + } + } + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/managers/Repeater.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/managers/Repeater.as new file mode 100644 index 0000000000000000000000000000000000000000..cb48f7427ea2afe3991e73374782c92b261e534c --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/managers/Repeater.as @@ -0,0 +1,164 @@ +/** + * Copyright (c) 2008 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.managers { + import org.goasap.PlayableBase; + + /** + * An iterator that can be used by playable items to track repeat play. + * + * This utility is used by SequenceBase to provide a looping option for + * Sequence and SequenceCA. When creating your own Go utilities you can + * make use of Repeater, which provides a next() iterator and a skipTo helper. + */ + public class Repeater { + + /** + * Makes code more human-readable, like <code>new Repeater(Repeater.INFINITE);</code> + */ + public static const INFINITE: uint = 0; + + /** + * Number of times the Repeater will iterate, which can be set to + * zero or Repeater.INFINITE for indefinite repeating. + */ + public function get cycles() : uint { + return _cycles; + } + public function set cycles(value : uint):void { + if (unlocked()) + _cycles = value; + } + + /** + * Current cycle starting at 0, which will continue to increase + * up to <code>cycles</code> or indefinitely if cycles is set to + * Repeater.INFINITE (zero). + */ + public function get currentCycle():uint { + return _currentCycle; + } + + /** + * True if cycles is not infinite and currentCycle has reached cycles. + */ + public function get done():Boolean { + return (_currentCycle==_cycles && _cycles!=INFINITE); + } + + /** @private */ + protected var _item : PlayableBase; + + /** @private */ + protected var _cycles: uint; + + /** @private */ + protected var _currentCycle : uint = 0; + + public function Repeater(cycles: uint=1) { + _cycles = cycles; + } + + /** + * @private + * For one-time internal use by parent playable item. + * When writing playable items that include a repeater, + * call this method once during construction or when + * the repeater is generated. This allows the repeater + * to check the parent item's state and reject calls + * to sensitive settings during your item's play. + * If you're subclassing Repeater, you can most simply + * query the method unlocked() to determine whether the + * parent item exists and is stopped. + */ + public function setParent(item:PlayableBase):void { + if (!_item) _item = item; + } + + /** + * @private + * For internal use by playable items. + * Iterates forward to final cycle, and returns false when done. + * You may also test this result in advance using hasNext(). + * @return True if still active, false when done. + */ + public function next(): Boolean { + if (_cycles==INFINITE) { + _currentCycle++; + return true; + } + + if (_cycles-_currentCycle>0) + _currentCycle++; + + if (_cycles==_currentCycle) + return false; + + return true; + } + + /** + * @private + * For internal use by playable items. + * @return False if cycles will be complete on next() call. + */ + public function hasNext(): Boolean { + return (_cycles==INFINITE || _cycles-_currentCycle>1); + } + + /** + * @private + * For internal use by playable items. + * Skips to a new currentCycle and aids playable items by calculating + * and returning the new play index. + * + * @param fullUnit The tween duration or sequence length + * @param amount The skipTo amount requested which will be normalized + * to zero if negative, and if cycles are not set to infinite, + * capped to a maximum value of cycles * fullUnit. + * @return The new play index + */ + public function skipTo(fullUnit:Number, amount:Number):Number { + if (isNaN(fullUnit) || isNaN(amount)) + return 0; // fail on bad inputs + amount = Math.max(0, amount); + if (cycles!=INFINITE) + amount = Math.min(amount, _cycles*fullUnit); + _currentCycle = Math.floor(amount / fullUnit); + return amount%fullUnit; + } + + /** + * @private + * For internal use by playable items. + * + * Resets current cycle to zero. + */ + public function reset(): void { + _currentCycle = 0; + } + + /** @private */ + protected function unlocked() : Boolean { + return (!_item || (_item && _item.state==PlayableBase.STOPPED)); + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/PlayableGroup.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/PlayableGroup.as new file mode 100644 index 0000000000000000000000000000000000000000..8cbf3bc6c9a66bda4a249f474f5c85d7b078e7a3 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/PlayableGroup.as @@ -0,0 +1,467 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.utils { + import flash.utils.Dictionary; + + import org.goasap.PlayableBase; + import org.goasap.events.GoEvent; + import org.goasap.interfaces.IPlayable; + import org.goasap.managers.Repeater; + + /** + * Dispatched when the group starts. + * @eventType org.goasap.events.START + */ + [Event(name="START", type="org.goasap.events.GoEvent")] + + /** + * Dispatched when the group is paused successfully. + * @eventType org.goasap.events.PAUSE + */ + [Event(name="PAUSE", type="org.goasap.events.GoEvent")] + + /** + * Dispatched when the group is resumed successfully. + * @eventType org.goasap.events.RESUME + */ + [Event(name="RESUME", type="org.goasap.events.GoEvent")] + + /** + * Dispatched at the end the group if <code>repeater.cycles</code> is set to + * a value other than one, just before the group starts its next play cycle. + * @eventType org.goasap.events.CYCLE + */ + [Event(name="CYCLE", type="org.goasap.events.GoEvent")] + + /** + * Dispatched if the group is manually stopped. + * @eventType org.goasap.events.STOP + */ + [Event(name="STOP", type="org.goasap.events.GoEvent")] + + /** + * Dispatched after all children have dispatched a STOP or COMPLETE event. + * @eventType org.goasap.events.COMPLETE + */ + [Event(name="COMPLETE", type="org.goasap.events.GoEvent")] + + + /** + * Batch-play a set of items and receive an event when all of them have finished. + * + * <p>PlayableGroup accepts any IPlayable for its children, which can include + * tweens, other groups, sequences and so forth. The group listens for both + * GoEvent.STOP and GoEvent.COMPLETE events from its children, either of which + * are counted toward group completion.</p> + * + * <p>The <code>repeater</code> property of PlayableGroup allows you to loop play + * any number of times, or indefinitely by setting its cycles to Repeater.INFINITE. + * GoEvent.CYCLE is dispatched on each loop and GoEvent.COMPLETE when finished. + * Other events dispatched include the GoEvent types START, STOP, PAUSE, and RESUME.</p> + * + * @author Moses Gunesch + */ + public class PlayableGroup extends PlayableBase implements IPlayable { + + // -== Public Properties ==- + + /** + * Get or set the children array. Only IPlayable items are stored. Note that + * unlike the methods <code>addChild</code> and <code>removeChild</code>, + * setting this property will stop any group play currently in progress. + */ + public function get children():Array { + var a:Array = []; + for (var item:Object in _children) + a.push(item); + return a; + } + public function set children(a:Array):void { + if (_listeners > 0) + stop(); + for each (var item:Object in a) + if (item is IPlayable) + addChild(item as IPlayable); + } + + /** + * The groups's Repeater instance, which may be used to make + * it loop and play more than one time. + * + * <p>The Repeater's cycles property can be set to an integer, or + * to Repeater.INFINITE or 0 to repeat indefinitely.</p> + * + * <pre> + * var group:PlayableGroup = new PlayableGroup(tween1, tween2, tween3); + * group.repeater.cycles = 2; + * group.start(); + * trace(group.repeater.currentCycle); // output: 0 + * </pre> + */ + public function get repeater(): Repeater { + return _repeater; + } + + /** + * Determines the number of children currently being monitored + * for completion by the group. + */ + public function get listenerCount() : uint { + return _listeners; + } + + // -== Protected Properties ==- + + /** @private */ + protected var _children: Dictionary = new Dictionary(); + + /** @private */ + protected var _listeners: uint = 0; + + /** @private */ + protected var _repeater: Repeater; + + // -== Public Methods ==- + + /** + * Constructor. + * + * @param items Any number of IPlayable items as separate arguments, + * or a single array of them. + */ + public function PlayableGroup(...items) { + super(); + if (items.length > 0) + this.children = ((items[ 0 ] is Array) ? items[ 0 ] : items); + _repeater = new Repeater(); + _repeater.setParent(this); + } + + /** + * Searches for a child with the specified playableID. + * + * @param playableID The item playableID to search for. + * @param deepSearch If child is not found in the group, this option runs a + * recursive search on any children that are PlayableGroup. + * @return The SequenceStep with the matching playableID. + */ + public function getChildByID(playableID:*, deepSearch:Boolean=true):IPlayable { + for (var item:Object in _children) + if ((item as IPlayable).playableID===playableID) + return (item as IPlayable); + if (deepSearch) { + for (item in _children) { + if (item is PlayableGroup) { + var match:IPlayable = ((item as PlayableGroup).getChildByID(playableID, true)); + if (match) { return (match as IPlayable); } + } + } + } + return null; + } + + /** + * Adds a single IPlayable to the children array (duplicates are rejected) and + * syncs up the group and child play-states based on various conditions. + * + * <p>If both the group and the item being added are STOPPED, the item is simply + * added to the children list.</p> + * + * <p>If both items are PAUSED or PLAYING (including PLAYING_DELAY for children), + * the child is actively added to the group during play and will be monitored for + * completion along with others.</p> + * + * <p>In other cases where the child's state mismatches the group's state, there + * are several behaviors available. Normally if the second parameter <code>adoptChildState</code> + * is left false, the child's mismatched state will be updated to match the group's + * state. This can result in it being stopped, paused, or started/resumed and monitored + * for completion along with other children. Passing true for <code>adoptChildState</code> + * results in updating the group's state to match the child's. This option could be used, for + * example, if you wanted to build a group of already-playing items without disrupting their + * play cycle with a start() call to the group.</p> + * + * @param item Any instance that implements IPlayable and uses PlayableBase's play-state constants. + * @param adoptChildState Makes this group change its play-state to match the state of the new child. + * @return Success. + */ + public function addChild(item:IPlayable, adoptChildState:Boolean=false): Boolean { + if (_children[ item ]) + return false; + if (item.state!=_state) { // Resolve an obvious mismatched play state... + // Normally states are both STOPPED, so the following ugliness is rarely used. + var primary:IPlayable = (adoptChildState ? item : this); + var primaryPlaying:Boolean = (primary.state==PLAYING || primary.state==PLAYING_DELAY); + var secondary:IPlayable = (adoptChildState ? this : item); + var secondaryPlaying:Boolean = (secondary.state==PLAYING || secondary.state==PLAYING_DELAY); + if ( !(primaryPlaying && secondaryPlaying) ) // Less obvious, but treat PLAYING_DELAY & PLAYING as "playing." + { + switch (primary.state) { + case STOPPED: + secondary.stop(); + break; + case PAUSED: // This case works either way. Both START & PAUSE events will result. + if (secondary.state==STOPPED) + secondary.start(); + secondary.pause(); + break; + case PLAYING: + case PLAYING_DELAY: + if (secondary.state==PAUSED) + secondary.resume(); + else if (secondary.state==STOPPED) { + if (adoptChildState) { + _state = PLAYING; // Group adopts child playing state + dispatchEvent(new GoEvent( GoEvent.START)); + } + else { + secondary.start(); + } + } + break; + } + } + } + // Saved until after possible play-state changes. Now we can base listening on this group's state. + _children[ item ] = false; + if (_state!=STOPPED) + listenTo(item); + return true; + } + + /** + * Removes a single IPlayable from the children array. + * + * <p>Note that if play is in progress when a child is added it does not + * interrupt play and the child is monitored for completion along with + * others.</p> + * + * @param item Any instance that implements IPlayable and uses PlayableBase's play-state constants. + * @return Success. + */ + public function removeChild(item:IPlayable): Boolean { + var v:* = _children[ item ]; + if (v===null) + return false; + if (v===true) + unListenTo( item ); + delete _children[ item ]; + return true; + } + + /** + * Test whether any child has a particular play state, based on + * the int constants in the PlayableBase class. + * + * <pre> + * // Example: resume a paused group + * if ( myGroup.anyChildHasState(PlayableBase.PAUSED) ) { + * myGroup.resume(); + * } + * </pre> + */ + public function anyChildHasState(state:String): Boolean { + for (var item:Object in _children) + if ((item as IPlayable).state==state) + return true; + return false; + } + + // -== IPlayable implementation ==- + + /** + * Calls start on all children. + * + * <p>If the group is active when this method is called, a <code>stop</code> call + * is automated which will result in a GoEVent.STOP event being dispatched.</p> + * + * @return Returns true if any child in the group starts successfully. + */ + public function start() : Boolean { + stop(); + var r:Boolean = false; + for (var item:Object in _children) { + var started:Boolean = (item as IPlayable).start(); + if (started) + listenTo(item as IPlayable); + r = (started || r); + } + if (!r) return false; // all starts failed + _state = PLAYING; + dispatchEvent(new GoEvent( GoEvent.START)); + _playRetainer[ this ] = 1; // Developers - Important! Look up _playRetainer. + return true; + } + + /** + * If the group is active, this method stops all child items and + * dispatches a GoEvent.STOP event. + * + * @return Returns true only if all children in the group stop successfully. + */ + public function stop() : Boolean { + if (_state == STOPPED) + return false; + _state = STOPPED; + _repeater.reset(); + delete _playRetainer[ this ]; // Developers - Important! Look up _playRetainer. + if (_listeners==0) { + dispatchEvent(new GoEvent( GoEvent.COMPLETE )); + return true; + } + var r:Boolean = true; + for (var item:Object in _children) { + unListenTo(item as IPlayable); + r = ((item as IPlayable).stop() && r); + } + dispatchEvent(new GoEvent( GoEvent.STOP )); + return r; + } + + /** + * Calls <code>pause</code> on all children. + * + * @return Returns true only if all playing children in the group paused successfully + * and at least one child was paused. + */ + public function pause() : Boolean { + if (_state!= PLAYING) + return false; + var r:Boolean = true; + var n:uint = 0; + for (var item:Object in _children) { + var success:Boolean = (item as IPlayable).pause(); + if (success) n++; + r = (r && success); + } + if (n>0) { + _state = PAUSED; // state should reflect that at least one item was paused, + // while return value may indicate that not all pause calls succeeded. + dispatchEvent(new GoEvent( GoEvent.PAUSE )); + } + return (n>0 && r); + } + + /** + * Calls <code>resume</code> on all children. + * + * @return Returns true only if all paused children in the group resumed successfully + * and at least one child was resumed. + */ + public function resume() : Boolean { + if (_state!= PAUSED) + return false; + var r:Boolean = true; + var n:uint = 0; + for (var item:Object in _children) { + var success:Boolean = (item as IPlayable).resume(); + if (success) n++; + r = (r && success); + } + if (n>0) { + _state = PLAYING; // state should reflect that at least one item was resumed, + // while return value may indicate that not all resume calls succeeded. + dispatchEvent(new GoEvent( GoEvent.RESUME )); + } + return (n>0 && r); + } + + /** + * Calls <code>skipTo</code> on all children. + * + * @return Returns true only if all children in the group skipTo the position successfully + * and at least one child was affected. + */ + public function skipTo(position : Number) : Boolean { + var r:Boolean = true; + var n:uint = 0; + position = _repeater.skipTo(_repeater.cycles, position); // TODO: TEST + for (var item:Object in _children) { + r = ((item as IPlayable).skipTo(position) && r); + listenTo(item as IPlayable); + n++; + } + _state = (r ? PLAYING : STOPPED); + return (n>0 && r); + } + + // -== Protected Methods ==- + + /** + * @private + * Internal handler for item completion. + * @param event GoEvent dispatched by child item. + */ + protected function onItemEnd(event:GoEvent) : void { + unListenTo(event.target as IPlayable); + if (_listeners==0) { + complete(); + } + } + + /** + * @private + * Internal handler for group completion. + */ + protected function complete() : void { + if (_repeater.next()) { + dispatchEvent(new GoEvent( GoEvent.CYCLE )); + for (var item:Object in _children) { + var started:Boolean = (item as IPlayable).start(); + if (started) + listenTo(item as IPlayable); + } + } + else { + stop(); + } + } + + /** + * @private + * Internal. Listen for item completion, keeping tight track of listeners. + * @param item Any instance that extends IPlayable (IPlayable itself should not be used directly). + */ + protected function listenTo(item:IPlayable) : void { + if (_children[ item ] === false) { + item.addEventListener(GoEvent.STOP, onItemEnd, false, 0, true); + item.addEventListener(GoEvent.COMPLETE, onItemEnd, false, 0, true); + _children[ item ] = true; + _listeners++; + } + } + + /** + * @private + * Internal. Stop listening for item completion. + * @param item Any instance that extends IPlayable (IPlayable itself should not be used directly). + * @return Number of completion listeners remaining. + */ + protected function unListenTo(item:IPlayable) : void { + if (_children[ item ] === true) { + item.removeEventListener(GoEvent.STOP, onItemEnd); + item.removeEventListener(GoEvent.COMPLETE, onItemEnd); + _children[ item ] = false; + _listeners--; + } + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/Sequence.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/Sequence.as new file mode 100644 index 0000000000000000000000000000000000000000..54d86f4de023539f7dc4b2b92eb02b1040553cc8 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/Sequence.as @@ -0,0 +1,187 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.utils { + import org.goasap.interfaces.IPlayable; + + /** + * Simple playable sequence, composed of groups of playable items. + * + * <p>A sequence can be built by passing any item that implements IPlayable + * and uses the standard set of PlayableBase play-state constants. + * Sequences are composed of SequenceStep instances, which can contain any + * number of child items such as LinearGo or PlayableGroup instances. + * Sequences dispatch SequenceEvent.ADVANCE each time a step completes and + * the play index advances to the next one, then GoEvent.COMPLETE when done.</p> + * + * <p>Other events dispatched include the GoEvent types START, STOP, PAUSE, RESUME, + * and CYCLE if the repeater.cycles property is set to a value other than one.</p> + * + * <p>All items in each step must dispatch COMPLETE or STOP before a Sequence + * will advance. This simple behavior can be limiting, especially with steps that + * are composed of groups of items. The Go utility package includes another + * sequencer called SequenceCA, which allows you to define different ways a sequence + * can advance: after a particular item in a step, a particular duration, after + * an event fires, etc.</p> + * + * @see SequenceBase + * @see SequenceCA + * @author Moses Gunesch + */ + public class Sequence extends SequenceBase { + + // -== Public Properties ==- + + // Also in super: + // length : uint [Read-only.] + // playIndex : int [Read-only.] + // steps : Array + // start() : Boolean + // stop() : Boolean + // pause() : Boolean + // resume() : Boolean + // skipTo(index:Number) : Boolean + + /** + * Returns the currently-playing SequenceStep. + * @return The currently-playing SequenceStep. + * @see #getStepAt() + * @see #getStepByID() + * @see #steps + * @see #lastStep + */ + public function get currentStep() : SequenceStep { + return (super._getCurrentStep()); + } + + /** + * Returns the final SequenceStep in the current sequence. + * @return The final SequenceStep in the current sequence. + * @see #getStepAt() + * @see #getStepByID() + * @see #steps + * @see #currentStep + */ + public function get lastStep() : SequenceStep { + return (super._getLastStep()); + } + + // -== Public Methods ==- + + /** + * Constructor. + * + * @param items Any number of IPlayable instances (e.g. LinearGo, PlayableGroup, + * SequenceStep) as separate arguments, or a single array of them. + */ + public function Sequence(...items) { + super((items[ 0 ] is Array) ? items[ 0 ] : items); + } + + /** + * Retrieves any SequenceStep from the steps array. + * @param index An array index starting at 0. + * @return The SequenceStep instance at this index. + * @see #getStepByID() + * @see #currentStep + * @see #lastStep + */ + public function getStepAt(index:int) : SequenceStep { + return (super._getStepAt(index) as SequenceStep); + } + + /** + * Locates a step with the specified playableID. To search within a step for a + * child by playableID, use the step instance's <code>getChildByID</code> method. + * + * @param playableID The step instance's playableID to search for. + * @return The SequenceStep with the matching playableID. + * @see #getStepAt() + */ + public function getStepByID(playableID:*) : SequenceStep { + return (super._getStepByID(playableID) as SequenceStep); + } + + /** + * Adds a single IPlayable instance (e.g. LinearGo, PlayableGroup, SequenceStep) + * to the end of the steps array, or optionally adds the instance into the last + * SequenceStep instead of adding it as a new step. + * + * <p>To remove a step use the <code>removeStepAt</code> method.</p> + * + * @param item The playable item to add to the sequence. Note + * that when new steps are added, any IPlayable + * instance of a type other than SequenceStep is + * automatically wrapped in a new SequenceStep. + * + * @param addToLastStep If true is passed the item is added to the last + * existing SequenceStep in the steps array. This + * option should be used with individual items that + * you want added as children to the SequenceStep. + * If there are no steps yet this option ignored and + * a new step is created. + * + * @return New length of the steps array. + */ + public function addStep(item:IPlayable, addToLastStep:Boolean=false): int { + return (super._addStep(item, addToLastStep, SequenceStep)); + } + + /** + * Adds a single IPlayable instance (e.g. LinearGo, PlayableGroup, + * SequenceStep) at a specific index in the steps array. Calling this method + * stops any sequence play currently in progress. + * + * @param item The playable item to splice into the sequence. + * + * @param index Position in the array starting at 0, or a negative + * index like Array.splice. + * + * @return New length of the steps array. + */ + public function addStepAt(item:IPlayable, index:int): int { + return (super._addStepAt(index, item, SequenceStep)); + } + + /** + * Removes and returns the SequenceStep at a specific index from the steps + * array. Calling this method stops any sequence play currently in progress. + * + * @param index Position in the array starting at 0, or a negative + * index like Array.splice. + * + * @return The SequenceStep instance removed from the steps array. + */ + public function removeStepAt(index:int): SequenceStep { + return (super._removeStepAt(index) as SequenceStep); + } + + // Also in super: + // length : uint [Read-only.] + // playIndex : int [Read-only.] + // steps : Array + // start() : Boolean + // stop() : Boolean + // pause() : Boolean + // resume() : Boolean + // skipTo(index:Number) : Boolean + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/SequenceBase.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/SequenceBase.as new file mode 100644 index 0000000000000000000000000000000000000000..edf3623d4259bd84b8a380cd7052bfdecf52a142 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/SequenceBase.as @@ -0,0 +1,473 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.utils { + import flash.events.Event; + import flash.utils.getQualifiedClassName; + + import org.goasap.PlayableBase; + import org.goasap.errors.InstanceNotAllowedError; + import org.goasap.events.GoEvent; + import org.goasap.events.SequenceEvent; + import org.goasap.interfaces.IPlayable; + import org.goasap.managers.Repeater; + + /** + * Dispatched when the sequence starts. + * @eventType org.goasap.events.START + */ + [Event(name="START", type="org.goasap.events.GoEvent")] + + /** + * Dispatched when the sequence advances to its next step. + * @eventType org.goasap.events.SequenceEvent.ADVANCE + */ + [Event(name="ADVANCE", type="org.goasap.events.SequenceEvent")] + + /** + * Dispatched when the sequence is paused successfully. + * @eventType org.goasap.events.PAUSE + */ + [Event(name="PAUSE", type="org.goasap.events.GoEvent")] + + /** + * Dispatched when the sequence is resumed successfully. + * @eventType org.goasap.events.RESUME + */ + [Event(name="RESUME", type="org.goasap.events.GoEvent")] + + /** + * Dispatched at the end the group if <code>repeater.cycles</code> is set to + * a value other than one, just before the sequence starts its next play cycle. + * @eventType org.goasap.events.CYCLE + */ + [Event(name="CYCLE", type="org.goasap.events.GoEvent")] + + /** + * Dispatched when the sequence is manually stopped, which may also occur + * if one of its step instances is manually stopped outside the sequence. + * @eventType org.goasap.events.STOP + */ + [Event(name="STOP", type="org.goasap.events.GoEvent")] + + /** + * Dispatched when the sequence successfully finishes. (In SequenceCA this event + * is not fired until all custom-advanced steps have dispatched STOP or COMPLETE.) + * @eventType org.goasap.events.COMPLETE + */ + [Event(name="COMPLETE", type="org.goasap.events.GoEvent")] + + /** + * This base class should not be used directly, use it to build sequencing classes. + * + * <p>When subclassing, follow the instructions in the comments of the protected + * methods to add a standard set of public getters and methods that work with the + * specific datatype of your SequenceStep subclass, if you create one. (This system + * is designed to work around the restrictiveness of overrides in AS3 which don't + * allow you to redefine datatypes.) See Sequence and SequenceCA for examples.</p> + * + * @see Sequence + * @see SequenceCA + * + * @author Moses Gunesch + */ + public class SequenceBase extends PlayableBase implements IPlayable { + + // -== Public Properties ==- + + /** + * The number of steps in the sequence. + */ + public function get length(): int { + return (_steps ? _steps.length : 0); + } + + /** + * The current play index of the sequence, starting a 0. + */ + public function get playIndex(): int { + return _index; + } + + /** + * Get or set the list of SequenceStep instances that defines the sequence. + * + * <p> + * When setting this property, each item must implement IPlayable that uses + * PlayableBase play-state constants and dispatches STOP or COMPLETE when finished. + * Each item is automatically wrapped in a SequenceStep if it is of any other IPlayable + * type, such as a GoItem or PlayableGroup. Setting this property stops any sequence + * play currently in progress. + * </p> + * @see #_getStepAt() + * @see #_getStepByID() + * @see #_getCurrentStep() + * @see #_getLastStep() + */ + public function get steps():Array { + return _steps; + } + public function set steps(a:Array):void { + if (_state!=STOPPED) + stop(); + + while (_steps.length > 0) + _removeStepAt(_steps.length-1); + + for each (var item:Object in a) + if (item is IPlayable) + _addStep(item as IPlayable); + } + + /** + * The sequence's Repeater instance, which may be used to make + * the sequence loop and play more than one time. + * + * <p>The Repeater's cycles property can be set to an integer, or + * to Repeater.INFINITE or 0 to repeat indefinitely.</p> + * + * <pre>var seq:Sequence = new Sequence(tween1, tween2, tween3); + * seq.repeater.cycles = 2; + * seq.start(); + * trace(seq.repeater.currentCycle); // output: 0 + * + * seq.skipTo(4); // moves to 2nd action in 2nd cycle + * trace(seq.repeater.currentCycle); // output: 1</pre> + * + * <p>(The repeater property replaces the repeatCount and currentCount + * parameters in earlier releases of SequenceBase).</p> + */ + public function get repeater(): Repeater { + return _repeater; + } + + + // -== Protected Properties ==- + + /** @private */ + protected var _index: int = 0; + + /** @private */ + protected var _steps: Array; + + /** @private */ + protected var _repeater: Repeater; + + + // -== Public Methods ==- + + /** + * Constructor. + * + * @param items Any number of IPlayable instances (e.g. LinearGo, PlayableGroup, + * SequenceStep) as separate arguments, or a single array of them. + */ + public function SequenceBase(...items) { + super(); + var className:String = getQualifiedClassName(this); + if (className.slice(className.lastIndexOf("::")+2) == "SequenceBase") { + throw new InstanceNotAllowedError("SequenceBase"); + } + _steps = new Array(); + if (items.length > 0) { + steps = ((items[ 0 ] is Array) ? items[ 0 ] : items); + } + _repeater = new Repeater(); + _repeater.setParent(this); + } + + // -== IPlayable implementation ==- + + /** + * Begins a sequence. + * + * <p>If the group is active when this method is called, a <code>stop</code> call + * is automated which will result in a GoEvent.STOP event being dispatched.</p> + * + * @return Returns true unless there are no steps in the sequence. + */ + public function start() : Boolean { + if (_steps.length==0) + return false; + stop(); + _state = PLAYING; + _getCurrentStep().start(); + dispatchEvent(new GoEvent( GoEvent.START )); + _playRetainer[ this ] = 1; // Developers - Important! Look up _playRetainer. + return true; + } + + /** + * Stops all activity and dispatches a GoEvent.STOP event. + * + * @return Returns true unless sequence was already stopped. + */ + public function stop() : Boolean { + if (_state==STOPPED || _steps.length==0) + return false; + _state = STOPPED; + var stepState:String = _getCurrentStep().state; // TODO: this won't see the _trailingSteps state in SequenceCA + _getCurrentStep().stop(); + if (_steps.length-_index > 1 || stepState!=STOPPED) + dispatchEvent(new GoEvent( GoEvent.STOP )); + else + dispatchEvent(new GoEvent( GoEvent.COMPLETE )); + _index = 0; + _repeater.reset(); + delete _playRetainer[ this ]; // Developers - Important! Look up _playRetainer. + return true; + } + + /** + * Pauses sequence play. + * + * @return Returns true unless sequence was unable to pause any children. + */ + public function pause() : Boolean { + var prevState:String = _state; + if (_state==STOPPED || _state==PAUSED) + return false; + _state = PAUSED; + if (_getCurrentStep().pause()==false) { + _state = prevState; + return false; + } + dispatchEvent(new GoEvent( GoEvent.PAUSE )); + return true; + } + + /** + * Resumes previously-paused sequence play. + * + * @return Returns true unless sequence was unable to resume any children. + */ + public function resume() : Boolean { + if (_state != PAUSED || _getCurrentStep().resume()==false) { + return false; + } + _state = PLAYING; + dispatchEvent(new GoEvent( GoEvent.RESUME)); + return true; + } + + /** + * Stops the current step and skips to another step by sequence index. + * + * @return Always returns true since the index is normalized to the sequence. + */ + public function skipTo(index : Number) : Boolean { + _state = PLAYING; + var prevIndex:int = _index; + _index = _repeater.skipTo(_steps.length-1, index); + if (_index==prevIndex) { + (_getCurrentStep() as IPlayable).skipTo(0); + } + else { + _steps[prevIndex].stop(); // _index is updated before this call so that onStepEvent ignores the item's STOP event. + _getCurrentStep().start(); + } + return true; + } + + // -== Add hooks for these methods to your subclass like Sequence & SequenceCA ==- + // These methods are broken out to allow subclasses to use exact typing for their SequenceStep class. + + /** + * Developers: Add a getter called <code>currentStep</code> to your subclass as in Sequence. + * + * @return Developers: return the correct SequenceStep type for your subclass in your corresponding public method. + */ + protected function _getCurrentStep() : * { + return (_steps.length==0 ? null : _steps[_index]); + } + + /** + * Developers: Add a getter called <code>lastStep</code> to your subclass as in Sequence. + * + * @return Developers: return the correct SequenceStep type for your subclass in your corresponding public method. + */ + protected function _getLastStep() : * { + return (_steps.length==0 ? null : _steps[ _steps.length-1 ]); + } + /** + * Developers: Add a method called <code>getStepAt</code> to your subclass as in Sequence. + * + * @param index An array index starting at 0. + * @return Developers: return the correct SequenceStep type for your subclass in your corresponding public method. + */ + protected function _getStepAt(index:int) : * { + if (index >= _steps.length) + return null; + return (_steps[index] as SequenceStep); + } + + /** + * Developers: Add a method called <code>getStepByID</code> to your subclass as in Sequence. + * + * @param playableID The step instance's playableID to search for. + * @return Developers: return the correct SequenceStep type for your subclass in your corresponding public method. + */ + protected function _getStepByID(playableID:*) : * { + for each (var step:SequenceStep in _steps) + if (step.playableID===playableID) + return step; + return null; + } + + /** + * Developers: Add a method called <code>addStep</code> to your subclass as in Sequence. + * + * <p>Drop the third parameter in your subclass' addStep method. Use it to be sure + * the correct type of wrapper is created, as in SequenceCA.</p> + * + * @param item The playable item to add to the sequence. + * + * @param addToLastStep If true is passed the item is added to the last + * existing SequenceStep in the steps array. This + * option should be used with individual items that + * you want added as children to the SequenceStep. + * If there are no steps yet this option ignored and + * a new step is created. + * + * @param stepTypeAsClass Type for SequenceSteps. (Do not include this parameter in subclass addStep method.) + * + * @return New length of the steps array. + */ + protected function _addStep(item:IPlayable, addToLastStep:Boolean=false, stepTypeAsClass:*=null): int { + if (item is SequenceStep && !addToLastStep) { + return _addStepAt(_steps.length, item); + } + if (!stepTypeAsClass) + stepTypeAsClass = SequenceStep; + var step:SequenceStep = (addToLastStep && _steps.length > 0 + ? (_steps.pop() as SequenceStep) + : new stepTypeAsClass() as SequenceStep); + step.addChild(item); + return _addStepAt(_steps.length, step, stepTypeAsClass); // adds listeners + } + + /** + * Developers: Add a method called <code>addStep</code> to your subclass as in Sequence. + * + * <p>Drop the third parameter in your subclass' addStep method. Use it to be sure + * the correct type of wrapper is created, as in SequenceCA.</p> + * + + * @param index Position in the array starting at 0, or a negative + * index like Array.splice. + * + * @param item The playable item to splice into the sequence. + * + * @param stepTypeAsClass Type for SequenceSteps. (Do not include this parameter in subclass addStep method.) + * + * @return New length of the steps array. + */ + protected function _addStepAt(index:int, item:IPlayable, stepTypeAsClass:*=null): int { + if (_state!=STOPPED) + stop(); + if (!stepTypeAsClass) + stepTypeAsClass = SequenceStep; + var step:SequenceStep = (item is SequenceStep + ? item as SequenceStep + : new stepTypeAsClass(item) as SequenceStep); + step.addEventListener(SequenceEvent.ADVANCE, onStepEvent, false, 0, true); + step.addEventListener(GoEvent.STOP, onStepEvent, false, 0, true); + _steps.splice(index, 0, step); + return _steps.length; + } + + /** + * Developers: Add a method called <code>addStep</code> to your subclass as in Sequence. + * + * @param index Position in the array starting at 0, or a negative + * index like Array.splice. + * + * @return Developers: return the correct SequenceStep type for your subclass in your corresponding public method. + */ + protected function _removeStepAt(index:int) : * { + if (_state!=STOPPED) + stop(); + var step:SequenceStep = _steps.splice(index, 1) as SequenceStep; + step.removeEventListener(SequenceEvent.ADVANCE, onStepEvent); + step.removeEventListener(GoEvent.STOP, onStepEvent); + return step; + } + + // -== Protected Methods ==- + + /** + * @private + * Internal handler for step advance. + * + * @param event SequenceEvent dispatched by child item. + */ + protected function onStepEvent(event : Event) : void { + // A stop() call to the sequence results in step dispatching STOP, which would recurse here. + if (_state==STOPPED || event.target!=_steps[_index]) + return; + + // Only occurs if the SequenceItem is manually stopped outside of this manager. + if (event.type==GoEvent.STOP) { + stop(); + return; + } + + // Normal step advance + if (event.type==SequenceEvent.ADVANCE) { + if (_steps.length-_index == 1) { + complete(); + } + else { + advance(); + } + } + } + + /** + * @private + * Internal handler for group completion. + */ + protected function advance() : void { + if (_steps.length-_index > 1) { + _index ++; // this changes currentStep value in following code + _getCurrentStep().start(); + } + dispatchEvent(new SequenceEvent( SequenceEvent.ADVANCE )); + } + + /** + * @private + * Internal handler for group completion. + */ + protected function complete() : void { + // order-sensitive + if (_repeater.next()) { + dispatchEvent(new GoEvent( GoEvent.CYCLE )); + _index = 0; + _getCurrentStep().start(); + } + else { + _index = _steps.length - 1; + stop(); + } + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/SequenceCA.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/SequenceCA.as new file mode 100644 index 0000000000000000000000000000000000000000..cccfadcce48ec9789d9327491da7dbfda34ed342 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/SequenceCA.as @@ -0,0 +1,343 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.utils { + import flash.events.Event; + + import org.goasap.events.GoEvent; + import org.goasap.events.SequenceEvent; + import org.goasap.interfaces.IPlayable; + + /** + * Sequence with "Custom Advance" options, in which steps can specify when they should advance. + * + * <p>This class works like Sequence but uses the special class SequenceStepCA for its steps. + * SequenceStepCA has a property called <code>advance</code>. When steps advance before animation + * finishes, the trailing steps are tracked so that the SequenceCA doesn't dispatch its COMPLETE + * event until all activity has completed.</p> + * + * <p>Any step's advance property can be set to an instance of OnDurationComplete, OnPlayableComplete, + * OnEventComplete or OnConditionTrue. Each of those classes defines its own parameters and rules for + * when the advance occurs. For example, using OnPlayableComplete a sequence can advance after one + * particular item in the step finishes, without needing to wait for all the other ones in that group + * to complete.</p> + * + * <p>Additionally, you can create your own custom advance types by subclassing the SequenceAdvance + * base class.</p> + * + * @see SequenceStepCA + * @see org.goasap.utils.customadvance.OnConditionTrue OnConditionTrue + * @see org.goasap.utils.customadvance.OnDurationComplete OnDurationComplete + * @see org.goasap.utils.customadvance.OnEventComplete OnEventComplete + * @see org.goasap.utils.customadvance.OnPlayableComplete OnPlayableComplete + * @see org.goasap.utils.customadvance.SequenceAdvance SequenceAdvance + * @see Sequence + * @see SequenceBase + * + * @author Moses Gunesch + */ + public class SequenceCA extends SequenceBase { + + // -== Public Properties ==- + + // Also in super: + // length : uint [Read-only.] + // playIndex : int [Read-only.] + // steps : Array + // start() : Boolean + // stop() : Boolean + // pause() : Boolean + // resume() : Boolean + // skipTo(index:Number) : Boolean + + /** + * Returns the currently-playing SequenceStepCA. + * @return The currently-playing SequenceStepCA. + * @see #getStepAt() + * @see #getStepByID() + * @see #steps + * @see #lastStep + */ + public function get currentStep() : SequenceStepCA { + return (super._getCurrentStep()); + } + + /** + * Returns the final SequenceStepCA in the current sequence. + * @return The final SequenceStepCA in the current sequence. + * @see #getStepAt() + * @see #getStepByID() + * @see #steps + * @see #currentStep + */ + public function get lastStep() : SequenceStepCA { + return (super._getLastStep()); + } + + // -== Protected Properties ==- + + /** + * @private + */ + protected var _trailingSteps : SequenceStep; + + // -== Public Methods ==- + + /** + * Constructor. + * + * @param items Any number of IPlayable instances (e.g. LinearGo, PlayableGroup, + * SequenceStepCA) as separate arguments, or a single array of them. + */ + public function SequenceCA(...items) { + super((items[ 0 ] is Array) ? items[ 0 ] : items); + } + + /** + * Retrieves any SequenceStepCA from the steps array. + * @param index An array index starting at 0. + * @return The SequenceStepCA instance at this index. + * @see #getStepByID() + */ + public function getStepAt(index:int) : SequenceStepCA { + return (super._getStepAt(index) as SequenceStepCA); + } + + /** + * Locates a step with the specified playableID. To search within a step for a + * child by playableID, use the step instance's <code>getChildByID</code> method. + * + * @param playableID The step instance's playableID to search for. + * @return The SequenceStepCA with the matching playableID. + */ + public function getStepByID(playableID:*) : SequenceStepCA { + return (super._getStepByID(playableID) as SequenceStepCA); + } + + /** + * Adds a single IPlayable instance (e.g. LinearGo, PlayableGroup, SequenceStepCA) + * to the end of the steps array, or optionally adds the instance into the last + * SequenceStepCA instead of adding it as a new step. + * + * <p>To remove a step use the <code>removeStepAt</code> method.</p> + * + * @param item The playable item to add to the sequence. Note + * that when new steps are added, any IPlayable + * instance of a type other than SequenceStepCA is + * automatically wrapped in a new SequenceStepCA. + * + * @param addToLastStep If true is passed the item is added to the last + * existing SequenceStepCA in the steps array. This + * option should be used with individual items that + * you want added as children to the SequenceStepCA. + * If there are no steps yet this option ignored and + * a new step is created. + * + * @return New length of the steps array. + */ + public function addStep(item:IPlayable, addToLastStep:Boolean=false): int { + return (super._addStep(item, addToLastStep, SequenceStepCA)); + } + + /** + * Adds a single IPlayable instance (e.g. LinearGo, PlayableGroup, SequenceStepCA) + * at a specific index in the steps array. Calling this method stops any sequence + * play currently in progress. + * + * @param item The playable item to splice into the sequence. + * + * @param index Position in the array starting at 0, or a negative + * index like Array.splice. + * + * @return New length of the steps array. + */ + public function addStepAt(item:IPlayable, index:int): int { + return (super._addStepAt(index, item, SequenceStepCA)); + } + + /** + * Removes and returns the SequenceStepCA at a specific index from the steps + * array. Calling this method stops any sequence play currently in progress. + * + * @param index Position in the array starting at 0, or a negative + * index like Array.splice. + * + * @return The SequenceStepCA instance removed from the steps array. + */ + public function removeStepAt(index:int): SequenceStepCA { + return (super._removeStepAt(index) as SequenceStepCA); + } + + // -== IPlayable implementation ==- + + /** + * Begins a sequence. + * + * <p>If the group is active when this method is called, a <code>stop</code> call + * is automated which will result in a GoEvent.STOP event being dispatched.</p> + * + * @return Returns true unless there are no steps in the sequence. + */ + override public function start() : Boolean { + return super.start(); + } + + /** + * Stops all activity and dispatches a GoEvent.STOP event. + * + * @return Returns true unless sequence was already stopped. + */ + override public function stop() : Boolean { + if (super.stop()==false) + return false; + initTrailingSteps(false); + return true; + } + + /** + * Pauses sequence play. + * + * @return Returns true unless sequence was unable to pause any children. + */ + override public function pause() : Boolean { + var success:Boolean = super.pause(); + if (_trailingSteps!=null) { + _trailingSteps.pause(); + if (_trailingSteps.state==PAUSED) { + _state = PAUSED; + success = true; + } + } + return success; + } + + /** + * Resumes previously-paused sequence play. + * + * @return Returns true unless sequence was unable to resume any children. + */ + override public function resume() : Boolean { + var success:Boolean = super.resume(); + if (_trailingSteps!=null) { + _trailingSteps.resume(); + if (_trailingSteps.state==PLAYING) { + _state = PLAYING; + success = true; + } + } + return success; + } + + /** + * Stops current activity and skips to another step by sequence index. + * + * @return Always returns true since the index is normalized to the sequence. + */ + override public function skipTo(index : Number) : Boolean { + initTrailingSteps(false); + return super.skipTo(index); + } + + // -== Protected Methods ==- + + /** + * @private + * Internal handler for item completion. + * @param event SequenceEvent dispatched by child item. + */ + override protected function onStepEvent(event : Event) : void { + // A stop() call to the sequence results in step dispatching STOP, which would recurse here. + if (_state==STOPPED) + return; + // trailing item + if (_trailingSteps!=null && event.target==_trailingSteps && event.type==SequenceEvent.ADVANCE) { + initTrailingSteps(false); + if (_steps.length-_index==1) { + if (lastStep.state==STOPPED) { + // A completed sequence was waiting for trailing steps to finish. + // Otherwise, trailing items have finished before sequence ended so no action should be taken. + complete(); + } + else { + // Special case where advance already fired but trailing steps have all completed: use COMPLETE + lastStep.addEventListener(GoEvent.COMPLETE, onStepEvent); + } + } + return; + } + + // Finishes special case in trailing item block. Also, returns out if we're waiting + if (lastStep.hasEventListener(GoEvent.COMPLETE)) { + if (event.type==GoEvent.COMPLETE) { + initTrailingSteps(false); // _trailingSteps is null, this is to remove the COMPLETE listener. + complete(); + } + return; + } + + super.onStepEvent(event); + } + + /** + * @private + * Internal handler for step advance. + */ + override protected function advance() : void { + if (currentStep.listenerCount > 0) { + initTrailingSteps(true); + var isFirstItem:Boolean = (_trailingSteps.children.length==0); + _trailingSteps.addChild(currentStep, isFirstItem); // 2nd param is adoptChildState flag: avoids a start call on the group. + } + super.advance(); + } + + /** + * @private + * Internal handler for group completion. + */ + override protected function complete() : void { + if (_trailingSteps==null) { + super.complete(); + } + } + + /** + * @private + * Internal setup for tracking items that are continuing to run after a custom advance. + * @param active Whether to create or destroy the trailing-steps group. + */ + protected function initTrailingSteps(active:Boolean):void { + if (_trailingSteps==null && active) { + _trailingSteps = new SequenceStep(); + _trailingSteps.playableID += "(_trailingSteps for sequence:"+playableID+")"; + _trailingSteps.addEventListener(SequenceEvent.ADVANCE, onStepEvent); + } + else if (!active) { + lastStep.removeEventListener(GoEvent.COMPLETE, onStepEvent); // Remove special case set in onStepEvent. + if (_trailingSteps!=null) { + _trailingSteps.removeEventListener(SequenceEvent.ADVANCE, onStepEvent); + _trailingSteps.stop(); + _trailingSteps = null; + } + } + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/SequenceStep.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/SequenceStep.as new file mode 100644 index 0000000000000000000000000000000000000000..c277dd053909376c76453bd6bd7ff12755aec65a --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/SequenceStep.as @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.utils { + import org.goasap.events.SequenceEvent; + + /** + * A PlayableGroup wrapper for playable items in a sequence step. Dispatches + * SequenceEvent.ADVANCE when all items have dispatched either STOP or COMPLETE. + * + * @see Sequence + * @see SequenceCA + * @see SequenceStepCA + * + * @author Moses Gunesch + */ + public class SequenceStep extends PlayableGroup { + + /** + * Constructor. See PlayableGroup + * @see PlayableGroup + */ + public function SequenceStep(...items) : void { + super((items[ 0 ] is Array) ? items[ 0 ] : items); + } + + /** + * @private + * Internal handler for group completion, overridden to dispatch ADVANCE + */ + override protected function complete() : void { + super.complete(); + if (super._listeners==0) { + dispatchEvent(new SequenceEvent(SequenceEvent.ADVANCE)); + } + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/SequenceStepCA.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/SequenceStepCA.as new file mode 100644 index 0000000000000000000000000000000000000000..138fd02d8d1dc0e34709262e227f6e4050d1cb6d --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/SequenceStepCA.as @@ -0,0 +1,250 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.utils { + import org.goasap.events.SequenceEvent; + import org.goasap.interfaces.IPlayable; + import org.goasap.utils.customadvance.OnPlayableComplete; + import org.goasap.utils.customadvance.SequenceAdvance; + + /** + * Step class used with SequenceCA that adds custom sequence-advance options + * so steps can determine when they advance, such as after a duration or after + * one item in the step completes. + * + * <p>The property <code>advance</code> can be set to an instance of any subclass + * of SequenceEvent, so that the ADVANCE event is sent when something specific + * occurs other than group completion. (This feature adds a great deal of flexibility + * to sequences by enabling them to overlap their actions, instead of being forced + * to wait for all child activity in an action to finish before proceeding.)</p> + * + * <p>Various advance types can be found in the <i>util.customadvance</i> package, and + * you are welcome to add your own by extending the base class SequenceAdvance.</p> + * + * <ul> + * <li>OnPlayableComplete: ADVANCE occurs after a specific child completes.</li> + * <li>OnDurationComplete: ADVANCE occurs when a number of seconds has passed.</li> + * <li>OnEventComplete: ADVANCE occurs when any event-type is fired from any + * dispatcher object, for example a LoaderInfo's COMPLETE event. You can optionally + * set a custom handler to filter the event and return true when ready to advance.</li> + * <li>OnConditionTrue: ADVANCE occurs when a callback, executed on a loop, returns + * true.</li> + * </ul> + * <p>Note that if no custom advance type is set, the ADVANCE event is dispatched + * just before the group's regular COMPLETE event. If a custom advance type is set, + * the group will maintain the state PLAYING until it completes, regardless + * of whether ADVANCE is dispatched during play. It will also maintain that state + * after it completes until ADVANCE is dispatched, if that occurs after all children + * are done playing. (Be careful, custom advance types continue running indefinitely + * if their conditions are never met, so track them closely.)</p> + * + * @see SequenceCA + * @see org.goasap.utils.customadvance.OnConditionTrue OnConditionTrue + * @see org.goasap.utils.customadvance.OnDurationComplete OnDurationComplete + * @see org.goasap.utils.customadvance.OnEventComplete OnEventComplete + * @see org.goasap.utils.customadvance.OnPlayableComplete OnPlayableComplete + * @see org.goasap.utils.customadvance.SequenceAdvance SequenceAdvance + * + * @author Moses Gunesch + */ + public class SequenceStepCA extends SequenceStep { + + // -== Public Properties ==- + + /** + * The advance property determines a custom advance behavior for the step + * and must be set prior to <code>start</code>. + * + * <p>The advance should be an instance of any subclass of the base class + * SequenceAdvance (SequenceAdvance cannot be used directly) and must + * dispatch SequenceEvent.ADVANCE.</p> + * + * @see org.goasap.utils.customadvance.OnConditionTrue OnConditionTrue + * @see org.goasap.utils.customadvance.OnDurationComplete OnDurationComplete + * @see org.goasap.utils.customadvance.OnEventComplete OnEventComplete + * @see org.goasap.utils.customadvance.OnPlayableComplete OnPlayableComplete + * @see org.goasap.utils.customadvance.SequenceAdvance SequenceAdvance + */ + public function get advance() : SequenceAdvance { + if (!_advance) { + _advance = new OnPlayableComplete(this); + } + return _advance; + } + public function set advance(advance:SequenceAdvance) : void { + if (super._state!=STOPPED || advance==_advance) + return; + if (_advance) + _advance.removeEventListener(SequenceEvent.ADVANCE, dispatchAdvance); + _advance = advance; + } + + /** + * Verifies that this SequenceStep has not advanced yet. + */ + public function get willAdvance() : Boolean { + return !_hasAdvanced; + } + + override public function addChild(item:IPlayable, adoptChildState:Boolean=false): Boolean { + if (adoptChildState && (item.state==PLAYING || item.state==PLAYING_DELAY)) { + _state = PLAYING; + _isSelf = true; + _hasAdvanced = false; + _advance = new OnPlayableComplete(this); + return super.addChild(item, false); + } + return super.addChild(item, adoptChildState); + } + + // -== Protected Properties ==- + + /** + * @private + */ + protected var _advance : SequenceAdvance; + /** + * @private + */ + protected var _isSelf : Boolean = true; // this default is used in special case, super.addChild(x, true). + /** + * @private + */ + protected var _hasAdvanced : Boolean = false; + + // -== Public Methods ==- + + /** + * Constructor. See PlayableGroup + * @see PlayableGroup + */ + public function SequenceStepCA(...items) : void { + super((items[ 0 ] is Array) ? items[ 0 ] : items); + } + + /** + * See PlayableGroup + * @see PlayableGroup#start + */ + override public function start() : Boolean { + if (super.start()==false) + return false; + _isSelf = false; + _hasAdvanced = false; + if (advance is OnPlayableComplete) // use getter here to force creation of default instance + _isSelf = ((_advance as OnPlayableComplete).item==this); + if (!_isSelf) { // Otherwise, the _advance instance is a dummy, completion is handled internally in this class. + _advance.addEventListener(SequenceEvent.ADVANCE, dispatchAdvance); + _advance.start(); + } + return true; + } + + /** + * See PlayableGroup + * @see PlayableGroup#stop + */ + override public function stop() : Boolean { + if (super.stop()==false) { + return false; + } + if (!_hasAdvanced && !_isSelf) { + _advance.removeEventListener(SequenceEvent.ADVANCE, dispatchAdvance); + _advance.stop(); + } + _hasAdvanced = false; + return true; + } + + /** + * See PlayableGroup + * @see PlayableGroup#pause + */ + override public function pause() : Boolean { + var r:Boolean = super.pause(); + if (!_isSelf && !_hasAdvanced) { + if (_advance.pause()==true) { + _state = PAUSED; + r = true; + } + } + return r; + } + + /** + * See PlayableGroup + * @see PlayableGroup#resume + */ + override public function resume() : Boolean { + var r:Boolean = super.resume(); + if (!_isSelf && !_hasAdvanced) { + if (_advance.resume()==true) { + _state = PLAYING; + r = true; + } + } + return r; + } + + /** + * See PlayableGroup + * @see PlayableGroup#skipTo + */ + override public function skipTo(position : Number) : Boolean { + if (super.skipTo(position)==false) + return false; + advance.skipTo(position); + return true; + } + + /** + * @private + * Internal relay for SequenceEvent.ADVANCE dispatch. + */ + protected function dispatchAdvance(e:SequenceEvent) : void { + if (_state==STOPPED) + return; + if (!_hasAdvanced && e.type==SequenceEvent.ADVANCE) { + _hasAdvanced = true; + if (super._listeners==0) // Complete the group, if it was not ready at complete(). + stop(); + dispatchEvent(new SequenceEvent(SequenceEvent.ADVANCE)); // order-sensitive: leave below stop(). + _advance.removeEventListener(SequenceEvent.ADVANCE, dispatchAdvance); + } + } + + // -== Protected Methods ==- + + /** + * @private + * Internal handler for group completion, overridden to allow item to continue + * playing until advance has been dispatched, if still waiting. + */ + override protected function complete() : void { + if (_isSelf && super._listeners==0) { // _isSelf event is handled internally, _advance instance is a dummy. + dispatchAdvance(new SequenceEvent(SequenceEvent.ADVANCE)); + } + else if (_hasAdvanced) { // Do not stop if advance is still active. + stop(); + } + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/customadvance/OnConditionTrue.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/customadvance/OnConditionTrue.as new file mode 100644 index 0000000000000000000000000000000000000000..7aebd89cd303e4d1826ed3f63feca928059426e0 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/customadvance/OnConditionTrue.as @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.utils.customadvance { + import org.goasap.GoEngine; + import org.goasap.interfaces.IUpdatable; + import org.goasap.items.GoItem; + + /** + * A custom advance type that triggers when a callback returns true. + * + * @author Moses Gunesch + */ + public class OnConditionTrue extends SequenceAdvance implements IUpdatable { + + // -== Public Properties ==- + + /** + * The pulse on which to call the callback function. Defaults to + * GoItem.defaultPulseInterval if not specified. + */ + public function get pulseInterval() : int { + if (isNaN(_pulse)) + _pulse = GoItem.defaultPulseInterval; + return _pulse; + } + + // -== Protected Properties ==- + + /** + * @private + */ + protected var _function : Function; + /** + * @private + */ + protected var _pulse : Number; + + // -== Public Methods ==- + + /** + * @param callbackThatReturnsBoolean Any function that returns a Boolean value + * @param pulseInterval The pulse on which to call the callback function, which defaults to + * GoItem.defaultPulseInterval if not specified. + */ + public function OnConditionTrue(callbackThatReturnsBoolean: Function, pulseInterval:Number=NaN) : void { + super(); + _function = callbackThatReturnsBoolean; + _pulse = pulseInterval; + } + + override public function start() : Boolean { + GoEngine.addItem(this); + _state = PLAYING; + return true; + } + + override public function stop() : Boolean { + GoEngine.removeItem(this); + _state = STOPPED; + return true; + } + + override public function pause() : Boolean { + if (_state==STOPPED || _state==PAUSED) + return false; + _state = PAUSED; + GoEngine.removeItem(this); + return true; + } + + override public function resume() : Boolean { + if (_state != PAUSED) + return false; + GoEngine.addItem(this); + return true; + } + + public function update(currentTime : Number) : void { + if (_function()===true) + super.dispatchAdvance(); + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/customadvance/OnDurationComplete.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/customadvance/OnDurationComplete.as new file mode 100644 index 0000000000000000000000000000000000000000..d40006ba8141a7e4ecbe0213f5777ea345cefa91 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/customadvance/OnDurationComplete.as @@ -0,0 +1,141 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.utils.customadvance { + import flash.utils.getTimer; + + import org.goasap.GoEngine; + import org.goasap.interfaces.IUpdatable; + import org.goasap.items.GoItem; + + /** + * A custom advance type that triggers after a specific duration has completed. + * + * @author Moses Gunesch + */ + public class OnDurationComplete extends SequenceAdvance implements IUpdatable { + + // -== Public Properties ==- + + /** + * The duration after which advance should occur. + */ + public function get duration() : Number { + return _duration; + } + + /** + * The pulse used to monitor the duration. Defaults to GoItem.defaultPulseInterval + * if not specified. + * + * <p>(Note that this system is more accurate than flash.utilss.Timer, especially for + * pause/resume.)</p> + */ + public function get pulseInterval() : int { + if (isNaN(_pulse)) + _pulse = GoItem.defaultPulseInterval; + return _pulse; + } + + // -== Protected Properties ==- + + /** + * @private + */ + protected var _duration : Number; + /** + * @private + */ + protected var _tweenDuration : Number; + /** + * @private + */ + protected var _pulse : Number; + /** + * @private + */ + protected var _pauseTime : Number; + /** + * @private + */ + protected var _startTime : int; + + // -== Public Methods ==- + + /** + * @param seconds The duration after which advance should occur. + * @param pulseInterval The pulse used to monitor the duration. Defaults to + * GoItem.defaultPulseInterval if not specified. + */ + public function OnDurationComplete(seconds:Number, pulseInterval:Number=NaN) { + super(); + _duration = (isNaN(seconds) ? 0 : Math.max(seconds, 0)); + _pulse = pulseInterval; + } + + override public function start() : Boolean { + _startTime = getTimer(); + _tweenDuration = (_duration * 1000 * Math.max(0, GoItem.timeMultiplier)); + _pauseTime = NaN; + GoEngine.addItem(this); + _state = PLAYING; + return true; + } + + override public function stop() : Boolean { + GoEngine.removeItem(this); + _state = STOPPED; + return true; + } + + override public function pause() : Boolean { + if (_state==STOPPED || _state==PAUSED) + return false; + _state = PAUSED; + _pauseTime = getTimer(); + GoEngine.removeItem(this); + return true; + } + + override public function resume() : Boolean { + if (_state != PAUSED) + return false; + _state = PLAYING; + _startTime = (getTimer() - (_pauseTime - _startTime)); + GoEngine.addItem(this); + return true; + } + + override public function skipTo(seconds:Number) : Boolean { // untested, logic is copied from LinearGo.skipTo. + if (_state==STOPPED) + GoEngine.addItem(this); + _pauseTime = NaN; + _startTime = (getTimer() - (Math.min(seconds, _duration) * 1000 * Math.max(0, GoItem.timeMultiplier))); + return true; + } + + public function update(currentTime : Number) : void { + if (currentTime >= _startTime + _tweenDuration) { + super.dispatchAdvance(); + } + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/customadvance/OnEventComplete.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/customadvance/OnEventComplete.as new file mode 100644 index 0000000000000000000000000000000000000000..c4d2eaa6edf25379adc007cf8abfd497eb937972 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/customadvance/OnEventComplete.as @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.utils.customadvance { + import flash.events.Event; + import flash.events.IEventDispatcher; + + /** + * A custom advance type that triggers when any event is dispatched by any IEventDispatcher host. + * + * <p>If the event requires filtering or custom handling, you can optionally set up a custom handler + * that accepts the event object as an input and returns true if all conditions are met for advancing + * the sequence.</p> + * + * @author Moses Gunesch + */ + public class OnEventComplete extends SequenceAdvance { + + // -== Protected Properties ==- + + /** + * @private + */ + protected var _host : IEventDispatcher; + /** + * @private + */ + protected var _type : String; + /** + * @private + */ + protected var _customHandler : Function; + + // -== Public Methods ==- + + /** + * @param dispatcher Any object that dispatches the event. + * @param type The event type to listen for + * @param customHanderThatReturnsBoolean Optionally you may specify a custom event handler which should + * accept an event input and return true once all conditions are met. + */ + public function OnEventComplete(dispatcher:IEventDispatcher, type:String, customHanderThatReturnsBoolean:Function=null) : void { + super(); + _host = dispatcher; + _type = type; + _customHandler = customHanderThatReturnsBoolean; + } + + override public function start() : Boolean { + _host.addEventListener(_type, dispatchAdvance); + _state = PLAYING; + return true; + } + + override public function stop() : Boolean { + _host.removeEventListener(_type, dispatchAdvance); + _state = STOPPED; + return true; + } + + // -== Protected Methods ==- + + /** + * @private + */ + override protected function dispatchAdvance(event:Event=null) : void { + if (_customHandler!=null) { + try { + if (_customHandler(event)===true) + super.dispatchAdvance(); + } + catch (e:Error) { + // Could run a trace here instead. + throw e; + } + return; + } + super.dispatchAdvance(); + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/customadvance/OnPlayableComplete.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/customadvance/OnPlayableComplete.as new file mode 100644 index 0000000000000000000000000000000000000000..42b6ab11680e12992c572e0442fe16eca46430f9 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/customadvance/OnPlayableComplete.as @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.utils.customadvance { + import org.goasap.events.GoEvent; + import org.goasap.interfaces.IPlayable; + + /** + * A custom advance type that triggers when any playable item (presumably one item + * in the step) dispatches STOP or COMPLETE. + * + * @author Moses Gunesch + */ + public class OnPlayableComplete extends SequenceAdvance { + + // -== Public Properties ==- + + public function set item(item : IPlayable) : void { + if (_state==STOPPED) + _item = item; + } + public function get item() : IPlayable { + return _item; + } + + // -== Public Methods ==- + + /** + * @private + */ + protected var _item : IPlayable; + + /** + * @param item Any playable item that dispatches STOP or COMPLETE, + * normally a child item in the step using this custom advance. + */ + public function OnPlayableComplete(item : IPlayable = null) : void { + super(); + _item = item; + } + + override public function start() : Boolean { + if (_item==null) + return false; + _item.addEventListener(GoEvent.STOP, super.dispatchAdvance); + _item.addEventListener(GoEvent.COMPLETE, super.dispatchAdvance); + _state = PLAYING; + return true; + } + + override public function stop() : Boolean { + _item.removeEventListener(GoEvent.STOP, super.dispatchAdvance); + _item.removeEventListener(GoEvent.COMPLETE, super.dispatchAdvance); + _state = STOPPED; + return true; + } + } +} diff --git a/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/customadvance/SequenceAdvance.as b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/customadvance/SequenceAdvance.as new file mode 100644 index 0000000000000000000000000000000000000000..bdbe1e808d610d6beae773113d307b0bd20afd55 --- /dev/null +++ b/typo3/contrib/flowplayer/lib/goasp/src_go/org/goasap/utils/customadvance/SequenceAdvance.as @@ -0,0 +1,87 @@ +/** + * Copyright (c) 2007 Moses Gunesch + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.goasap.utils.customadvance { + import flash.events.Event; + + import org.goasap.PlayableBase; + import org.goasap.events.SequenceEvent; + import org.goasap.interfaces.IPlayable; + + /** + * Subclasses should call the <code>dispatchAdvance</code> method when + * the sequence should advance to its next step. It is mandatory that + * custom advance types dispatch this event one time, although each class + * may define its own conditions for when this event occurs. + * + * @eventType org.goasap.events.SequenceEvent.ADVANCE + */ + [Event(name="ADVANCE", type="org.goasap.events.SequenceEvent")] + + /** + * Base class for other custom advance types, does nothing on its own. + * + * @see OnConditionTrue + * @see OnDurationComplete + * @see OnEventComplete + * @see OnPlayableComplete + * + * @author Moses Gunesch + */ + public class SequenceAdvance extends PlayableBase implements IPlayable { + + public function SequenceAdvance():void { + super(); + } + + // -== Protected Methods ==- + + /** + * @private + * Call this method from subclasses to trigger advance, only once per play cycle. + * @param event Allows method to be used as an event handler. + */ + protected function dispatchAdvance(event:Event=null) : void { + stop(); + dispatchEvent(new SequenceEvent(SequenceEvent.ADVANCE)); + } + + public function start() : Boolean { + return false; + } + + public function stop() : Boolean { + return false; + } + + public function pause() : Boolean { + return false; + } + + public function resume() : Boolean { + return false; + } + + public function skipTo(position : Number) : Boolean { + return false; + } + } +} diff --git a/typo3/contrib/flowplayer/lib/licensekey/licensekey.swc b/typo3/contrib/flowplayer/lib/licensekey/licensekey.swc new file mode 100644 index 0000000000000000000000000000000000000000..7b931a7ebaae509040179d30a70ce1201009c4ed Binary files /dev/null and b/typo3/contrib/flowplayer/lib/licensekey/licensekey.swc differ diff --git a/typo3/contrib/flowplayer/lib/thunderbolt/ThunderBoltAS3_Flash.swc b/typo3/contrib/flowplayer/lib/thunderbolt/ThunderBoltAS3_Flash.swc new file mode 100644 index 0000000000000000000000000000000000000000..da229626243e83ccc02b13cf9f21ebf034715e03 Binary files /dev/null and b/typo3/contrib/flowplayer/lib/thunderbolt/ThunderBoltAS3_Flash.swc differ diff --git a/typo3/contrib/flowplayer/manifest.xml b/typo3/contrib/flowplayer/manifest.xml new file mode 100644 index 0000000000000000000000000000000000000000..a5b5253788feafd33e71e5d94d4dcd673dfa0f70 --- /dev/null +++ b/typo3/contrib/flowplayer/manifest.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<componentPackage> + <component id="Flowplayer" class="org.flowplayer.view.Flowplayer"/> + <component id="PropertyBinder" class="org.flowplayer.util.PropertyBinder" /> + <component id="Arrange" class="org.flowplayer.util.Arrange" /> + <component id="Assert" class="org.flowplayer.util.Assert" /> + <component id="PluginEvent" class="org.flowplayer.model.PluginEvent" /> + <component id="TextUtil" class="org.flowplayer.util.TextUtil" /> + <component id="AbstractSprite" class="org.flowplayer.view.AbstractSprite" /> + <component id="StyleableSprite" class="org.flowplayer.view.StyleableSprite" /> + <component id="AutomationEngine" class="org.flowplayer.view.AnimationEngine" /> + <component id="NetStreamControllingStreamProvider" class="org.flowplayer.controller.NetStreamControllingStreamProvider" /> + <component id="Plugin" class="org.flowplayer.model.Plugin" /> + <component id="PluginModel" class="org.flowplayer.model.PluginModel" /> + <component id="DisplayPluginModel" class="org.flowplayer.model.DisplayPluginModel" /> + <component id="ProviderPlugin" class="org.flowplayer.model.ProviderModel" /> + <component id="GraphicsUtil" class="org.flowplayer.util.GraphicsUtil" /> + <component id="URLUtil" class="org.flowplayer.util.URLUtil" /> + <component id="Animation" class="org.flowplayer.view.AnimationEngine" /> + <component id="Log" class="org.flowplayer.util.Log" /> + <component id="JSON" class="com.adobe.serialization.json.JSON" /> + <!--<component id="Log" class="org.flowplayer.view.FlowplayerComponent" />--> +</componentPackage> + diff --git a/typo3/contrib/flowplayer/src/actionscript-builtin/BuiltInConfig.as b/typo3/contrib/flowplayer/src/actionscript-builtin/BuiltInConfig.as new file mode 100644 index 0000000000000000000000000000000000000000..dfd1ea612f029e0d404d1bb31e7ec56cf5a1679f --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript-builtin/BuiltInConfig.as @@ -0,0 +1,35 @@ +package { +//import org.flowplayer.rtmp.RTMPStreamProvider; +//import org.flowplayer.controls.Controls; +// import org.flowplayer.shareembed.ShareEmbed; +// import org.flowplayer.pseudostreaming.PseudoStreaming; + +public class BuiltInConfig { +// private var pseudo:org.flowplayer.rtmp.RTMPStreamProvider; +// private var controls:org.flowplayer.controls.Controls; +// private var share:org.flowplayer.shareembed.ShareEmbed; +// private var pseudo:org.flowplayer.pseudostreaming.PseudoStreamProvider; + +// [Embed(source="../assets/play.png")] +// public var PlayButton:Class; +// +// [Embed(source="../assets/play.png")] +// public var Logo:Class; + + public static const config:Object = { +// "plugins": { +// "psuedo": { +// "url": 'org.flowplayer.psuedostreaming.PseudoStreamProvider' +// } +// "rtmp": { +// "url": 'org.flowplayer.rtmp.RTMPStreamProvider' +// }, +// "controls": { +// "url": 'org.flowplayer.controls.Controls' +// } +// viral: { +// url: 'org.flowplayer.shareembed.ShareEmbed' +// } + } + }; +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/config/VersionInfo.as b/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/config/VersionInfo.as new file mode 100644 index 0000000000000000000000000000000000000000..c5d10482766f8f21aa9af1276eee8db311339e85 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/config/VersionInfo.as @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.config { + + /** + * @author api + */ + public class VersionInfo { + private static const VERSION_NUMBER:String = CONFIG::version1 + "." + CONFIG::version2 + "." + CONFIG::version3; + + private static const VERSION_INFO:String = (CONFIG::commercialVersion ? "Flowplayer commercial version " : + "Flowplayer free version " ) + VERSION_NUMBER + (CONFIG::versionStatus ? "-" + CONFIG::versionStatus : ""); + + public static function get version():Array { + return [new int(CONFIG::version1), new int(CONFIG::version2), new int(CONFIG::version3), CONFIG::commercialVersion ? 'commercial' : 'free', CONFIG::versionStatus]; + } + + public static function versionInfo():String { + return VERSION_INFO; + } + + public static function get commercial():Boolean { + return CONFIG::commercialVersion; + } + + public static function get controlsVersion():String { + return CONFIG::controlsVersion; + } + + public static function get audioVersion():String { + return CONFIG::audioVersion; + } + } + +} diff --git a/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/view/ContextMenuBuilder.as b/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/view/ContextMenuBuilder.as new file mode 100644 index 0000000000000000000000000000000000000000..37ab5250d870a2fc3a2f5530b7ca8f4b24acdb7c --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/view/ContextMenuBuilder.as @@ -0,0 +1,129 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import org.flowplayer.util.Log; + + import flash.events.ContextMenuEvent; + import flash.external.ExternalInterface; + import flash.net.URLRequest; + import flash.net.navigateToURL; + import flash.ui.ContextMenu; + import flash.ui.ContextMenuItem; + + import org.flowplayer.config.VersionInfo; + + /** + * @author api + */ + public class ContextMenuBuilder { + private var log:Log = new Log(this); + private var _menuItems:Array; + private var _playerId:String; + + public function ContextMenuBuilder(playerId:String, menuItems:Array) { + _playerId = playerId; + _menuItems = menuItems; + } + + public function build():ContextMenu { + CONFIG::freeVersion { + return buildMenu(createMenu()); + } + + CONFIG::commercialVersion { + return buildCustomMenu(createMenu(), _menuItems); + } + } + + CONFIG::commercialVersion + private function buildCustomMenu(menu:ContextMenu, menuItems:Array):ContextMenu { + if (! menuItems) return menu; + var separatorBeforeNextItem:Boolean = false; + var itemNum:int = 0; + for (var i:Number = 0; i < menuItems.length; i++) { + var item:Object = menuItems[i]; + if (item is String && item == "-") { + separatorBeforeNextItem = true; + itemNum++; + } else if (item is String) { + addCustomMenuItem(menu, item as String, itemNum++, null, separatorBeforeNextItem); + separatorBeforeNextItem = false; + } else { + for (var label:String in item) { + log.debug("creating menu item for " + label + ", callback " + menuItems[label]); + addCustomMenuItem(menu, label, itemNum++, item[label], separatorBeforeNextItem); + } + separatorBeforeNextItem = false; + } + } + return menu; + } + + CONFIG::commercialVersion + private function addCustomMenuItem(menu:ContextMenu, label:String, itemIndex:int, callback:String, separatorBeforeNextItem:Boolean):void { + if (! callback || callback == "null") { + addItem(menu, new ContextMenuItem(label, separatorBeforeNextItem, false)); + } else { + log.debug("creating item with callback"); + addItem(menu, new ContextMenuItem(label, separatorBeforeNextItem, true), createCallback(itemIndex)); + } + } + + CONFIG::commercialVersion + private function createCallback(itemIndex:int):Function { + return function(event:ContextMenuEvent):void { + log.debug("in event handler, playerId " + _playerId); + ExternalInterface.call( + "flowplayer.fireEvent", + _playerId || ExternalInterface.objectID, "onContextMenu", itemIndex); + }; + } + + CONFIG::freeVersion + private function buildMenu(menu:ContextMenu):ContextMenu { + + addItem(menu, new ContextMenuItem("About " +VersionInfo.versionInfo()+ "...", false, true), function(event:ContextMenuEvent):void { + navigateToURL(new URLRequest("http://flowplayer.org"), "_self"); + }); + // 1-3 Required by the GPL license + // 1 copyright notice + addItem(menu, new ContextMenuItem("Copyright © 2008-2011 Flowplayer Oy", true, false)); + // 2 NO WARRANTY + addItem(menu, new ContextMenuItem("Flowplayer comes without any warranty", false, false)); + // 3 Link to license + addItem(menu, new ContextMenuItem("GNU GENERAL PUBLIC LICENSE...", false, true), function(event:ContextMenuEvent):void { + navigateToURL(new URLRequest("http://flowplayer.org/license_gpl.html"), "_self"); + }); + return menu; + } + + private function createMenu():ContextMenu { + var menu:ContextMenu = new ContextMenu(); + menu.hideBuiltInItems(); + return menu; + } + private function addItem(menu:ContextMenu, item:ContextMenuItem, selectHandler:Function = null):void { + menu.customItems.push(item); + if (selectHandler != null) { + item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, selectHandler); + } + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/view/LabelPlayButton.as b/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/view/LabelPlayButton.as new file mode 100644 index 0000000000000000000000000000000000000000..b6946b314416505c44d57346c0323df040a6d9b9 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/view/LabelPlayButton.as @@ -0,0 +1,107 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import flash.display.Sprite; + import flash.filters.GlowFilter; + import flash.text.TextField; + import flash.text.TextFieldAutoSize; + import flash.text.TextFormat; + + import org.flowplayer.LabelHolderLeft; + import org.flowplayer.util.Arrange; + import org.flowplayer.view.AbstractSprite; + + /** + * @author api + */ + internal class LabelPlayButton extends AbstractSprite { + + private var _label:TextField; + private var _labelHolder:Sprite; + private var _labelHolderLeft:Sprite; + private var _labelHolderRight:Sprite; + private var _player:Flowplayer; + private var _resizeToTextWidth:Boolean; + + public function LabelPlayButton(player:Flowplayer, label:String, adjustToTextWidth:Boolean = true) { + _player = player; + _resizeToTextWidth = adjustToTextWidth; + createChildren(label); + } + + public function setLabel(value:String, changeWidth:Boolean = true):void { + log.debug("setLabel, changeWidth " + changeWidth); + if (_label.text == value) return; + _resizeToTextWidth = changeWidth; + _label.text = value; + onResize(); + } + + private function createChildren(label:String):void { + _labelHolderLeft = new LabelHolderLeft(); + addChild(_labelHolderLeft); + _labelHolder = new LabelHolder(); + addChild(_labelHolder); + + _labelHolderRight = new LabelHolderRight(); + addChild(_labelHolderRight); + + _label = _player.createTextField(); + _label.textColor = 0xffffff; + _label.selectable = false; + _label.autoSize = TextFieldAutoSize.RIGHT; + _label.multiline = false; + _label.text = label; + _label.width = _label.textWidth; + + var labelGlow:GlowFilter = new GlowFilter(0xFFFFFF, .30, 4, 4, 3, 3); + var labelFilters:Array = [labelGlow]; + _label.filters = labelFilters; + + addChild(_label); + } + + override protected function onResize():void { + log.debug("arranging label"); + _labelHolderRight.height = height; + _labelHolderRight.scaleX = _labelHolderRight.scaleY; + + _labelHolderLeft.height = height; + _labelHolderLeft.scaleX = _labelHolderLeft.scaleY; + + var format:TextFormat = _label.defaultTextFormat; + format.size = _labelHolder.height/3; + _label.setTextFormat(format); + + _labelHolder.width = int(_resizeToTextWidth ? _label.textWidth+10 : (width - _labelHolderRight.width - _labelHolderLeft.width)); + _labelHolder.height = height; + + Arrange.center(_labelHolder, width, height); + _labelHolderLeft.x = _labelHolder.x - _labelHolderLeft.width; + _labelHolderRight.x = _labelHolder.x + _labelHolder.width; + + Arrange.center(_labelHolderLeft, 0, height); + Arrange.center(_labelHolderRight, 0, height); + Arrange.center(_label, 0, height); + + _label.x = _labelHolder.x + _labelHolder.width / 2 - _label.width / 2; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/view/LicenseKey.as b/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/view/LicenseKey.as new file mode 100644 index 0000000000000000000000000000000000000000..b6e59b08717f45124d8257713e8b34e345a7c199 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/view/LicenseKey.as @@ -0,0 +1,46 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import org.flowplayer.util.Log; + + + CONFIG::commercialVersion { + import org.flowplayer.FlowplayerLicenseKey; + } + + CONFIG::commercialVersion + public class LicenseKey { + private static var log:Log = new Log("org.flowplayer.view::LicenseKey"); + + public static function validate(swfUrl:String, version:Array, configuredKeys:Object, externalInterfaceAvailable:Boolean):Boolean { + trace("using validator " + FlowplayerLicenseKey.id); + return FlowplayerLicenseKey.validate(swfUrl, version, configuredKeys, externalInterfaceAvailable); + } + } + + CONFIG::freeVersion + public class LicenseKey { + + public static function validate(swfUrl:String, version:Array, configuredKeys:Object, externalInterfaceAvailable:Boolean):Boolean { + return true; + } + } + +} diff --git a/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/view/LogoView.as b/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/view/LogoView.as new file mode 100644 index 0000000000000000000000000000000000000000..81e03952c566672372f0927c603c5d279935533a --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/view/LogoView.as @@ -0,0 +1,336 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import flash.text.TextField; + + import org.flowplayer.KeyUtil; + import org.flowplayer.controller.ResourceLoader; + import org.flowplayer.model.Plugin; + import org.flowplayer.model.PluginModel; + import org.flowplayer.util.PropertyBinder; + import org.flowplayer.util.URLUtil; + import org.flowplayer.controller.ResourceLoaderImpl; + import org.flowplayer.model.DisplayProperties; + import org.flowplayer.model.Logo; + import org.flowplayer.model.PlayerEvent; + import org.flowplayer.util.Arrange; + import org.flowplayer.view.AbstractSprite; + + import flash.display.DisplayObject; + import flash.display.StageDisplayState; + import flash.events.Event; + import flash.events.FullScreenEvent; + import flash.events.MouseEvent; + import flash.events.TimerEvent; + import flash.geom.Rectangle; + import flash.net.URLRequest; + import flash.net.navigateToURL; + import flash.utils.Timer; + + import org.flowplayer.view.BuiltInAssetHelper; + import org.flowplayer.view.Flowplayer; + + /** + * @author api + */ + public class LogoView extends AbstractSprite { + + private var _model:Logo; + private var _player:Flowplayer; + private var _image:DisplayObject; + private var _panel:Panel; + private var _copyrightNotice:TextField; + private var _preHideAlpha:Number = -1; + private var _hideTimer:Timer; + + public function LogoView(panel:Panel, player:Flowplayer) { + _panel = panel; + _player = player; + } + + public function set model(model:Logo):void { + setModel(model); + log.debug("fullscreenOnly " + model.fullscreenOnly); + setEventListeners(); + + CONFIG::commercialVersion { + if (BuiltInAssetHelper.hasLogo) { + log.debug("Using built in logo image"); + initializeLogoImage(BuiltInAssetHelper.createLogo()); + } else if (_model.url) { + load(_model.url, _model.fullscreenOnly); + } + } + + CONFIG::freeVersion { + _copyrightNotice = LogoUtil.createCopyrightNotice(10); + addChild(_copyrightNotice); + _model.width = "6.5%"; + _model.height = "6.5%"; + initializeLogoImage(BuiltInAssetHelper.createLogo() || new FlowplayerLogo()); + } + + log.debug("LogoView() model dimensions " + _model.dimensions); + } + + override protected function onResize():void { + if (_image) { + log.debug("onResize, " + _model.dimensions); + if (_model.dimensions.width.hasValue() && _model.dimensions.height.hasValue()) { + log.debug("onResize(), scaling image according to model"); + if (_image.height - copyrightNoticeheight() > _image.width) { + _image.height = height - copyrightNoticeheight(); + _image.scaleX = _image.scaleY; + } else { + _image.width = width; + _image.scaleY = _image.scaleX; + } + } +// Arrange.center(_image, width, height); + _image.x = width - _image.width; + _image.y = 0; + log.debug("image: " + Arrange.describeBounds(_image)); + + CONFIG::freeVersion { + _copyrightNotice.y = _image.height; + _copyrightNotice.visible = _copyrightNotice.textWidth < width; + _copyrightNotice.width = width; + } + } + } + + CONFIG::freeVersion + private function copyrightNoticeheight():Number { + return _copyrightNotice.height; + } + + CONFIG::commercialVersion + private function copyrightNoticeheight():Number { + return 0; + } + +// override public function get width():Number { +// return managedWidth; +// } +// +// override public function get height():Number { +// return managedHeight; +// } + + CONFIG::commercialVersion { + [External] + public function configure(props:Object):void { + _model = Logo(_player.pluginRegistry.getPlugin(_model.name)); + new PropertyBinder(_model).copyProperties(props); + + if (_model.url) { + load(_model.url, _model.fullscreenOnly); + } else if (_image) { + removeChild(_image); + } + + if (_model.linkUrl) { + setLinkEventListener(); + } else { + removeLinkEventListener(); + } + _player.pluginRegistry.update(_model); + } + } + + CONFIG::commercialVersion { + private function load(url:String, fullscreenOnly:Boolean):void { + log.debug("load(), " + url); + _model.url = url; + _model.fullscreenOnly = fullscreenOnly; + //var playerBaseUrl:String = URLUtil.playerBaseUrl(_panel.loaderInfo); + var playerBaseUrl:String = URLUtil.playerBaseUrl; + if (! verifyLogoUrl(_model.url, playerBaseUrl)) return; + + if (_image && _image.parent == this) { + removeChild(_image); + } + + log.debug("loading image from " + url); + var loader:ResourceLoader = new ResourceLoaderImpl(playerBaseUrl, _player); + loader.load(url, onImageLoaded); + } + } + + CONFIG::commercialVersion + private function verifyLogoUrl(configuredUrl:String, playerBaseUrl:String):Boolean { + if (! URLUtil.isCompleteURLWithProtocol(configuredUrl)) return true; + if (URLUtil.localDomain(playerBaseUrl)) return true; + + var playerDomain:String = KeyUtil.parseDomain(playerBaseUrl, true); + if (playerDomain == "flowplayer.org") return true; + + if (KeyUtil.parseDomain(configuredUrl, true) != playerDomain) { + log.error("cannot load logo from domain " + KeyUtil.parseDomain(configuredUrl, true)); + return false; + } + return true; + } + + CONFIG::commercialVersion + private function onImageLoaded(loader:ResourceLoader):void { + log.debug("image loaded " + loader.getContent()); + initializeLogoImage(loader.getContent() as DisplayObject); + } + + private function initializeLogoImage(image:DisplayObject):void { + log.debug("initializeLogoImage(), setting logo alpha to " + _model.alpha); + _image = image; + +// CONFIG::commercialVersion { +// _model.width = image.width; +// _model.height = image.height; +// } + + addChild(_image); + log.debug("createLogoImage() logo shown in fullscreen only " + _model.fullscreenOnly); + if (! _model.fullscreenOnly) { + show(); + } else { + hide(0); + } + update(); + onResize(); + } + + private function setEventListeners():void { + _panel.stage.addEventListener(FullScreenEvent.FULL_SCREEN, onFullscreen); + setLinkEventListener(); + } + + private function setLinkEventListener():void { + if (_model.linkUrl) { + addEventListener(MouseEvent.CLICK, onClick); + buttonMode = true; + } + } + + private function removeLinkEventListener():void { + removeEventListener(MouseEvent.CLICK, onClick); + buttonMode = false; + } + + + private function onClick(event:MouseEvent):void { + navigateToURL(new URLRequest(_model.linkUrl), _model.linkWindow); + } + + private function onFullscreen(event:FullScreenEvent):void { + if (event.fullScreen) { + if ((_hideTimer && _hideTimer.running) || _model.displayTime > 0) { + // hide timer is running or the hide time already passed + return; + } + show(); + } else { + if (_model.fullscreenOnly) { + hide(0); + } + } + } + + private function show():void { + if (_preHideAlpha != -1) { + this.alpha = _preHideAlpha; + _model.alpha = _preHideAlpha; + } + _model.visible = true; + this.visible = true; + CONFIG::freeVersion { + _model.zIndex = 100; + } + if (! this.parent) { + log.debug("showing " + _model.dimensions + ", " + _model.position); +// _player.animationEngine.fadeIn(this); + _panel.addView(this, null, _model); + + if (_model.displayTime > 0) { + log.debug("show() creating hide timer"); + _hideTimer = new Timer(_model.displayTime * 1000, 1); + _hideTimer.addEventListener(TimerEvent.TIMER_COMPLETE, + + function(event:TimerEvent):void { + log.debug("display time complete"); + hide(_model.fadeSpeed); + _hideTimer.stop(); + }); + _hideTimer.start(); + } + } +// else { +// update(); +// } + } + + private function update():void { + if (! this.parent) return; + log.debug("update() " + _model.dimensions + ", " + _model.position); + _panel.update(this, _model); + _panel.draw(this); + + if (_player.pluginRegistry.getPlugin(_model.name)) { + _player.pluginRegistry.updateDisplayProperties(_model); + } + } + + private function hide(fadeSpeed:int = 0):void { + log.debug("hide(), hiding logo"); + _preHideAlpha = _model.alpha; + if (fadeSpeed > 0) { + _player.animationEngine.fadeOut(this, fadeSpeed); + } else { + removeFromPanel(); + } + } + + private function removeFromPanel():void { + log.debug("removeFromPanel() " + this.parent); + if (this.parent) { + log.debug("removing logo from panel"); + _panel.removeChild(this); + } + } + + CONFIG::freeVersion + public function setModel(model:Logo):void { + log.debug("setModel() ignoring configured logo settings"); + // in the free version we ignore the supplied logo configuration + _model = new Logo(this, "logo"); + _model.fullscreenOnly = model.fullscreenOnly; + _model.height = "9%"; + _model.width = "9%"; + _model.top = "20"; + _model.right = "20"; + _model.opacity = 0.3; + _model.linkUrl = "http://flowplayer.org"; + log.debug("initial model dimensions " + _model.dimensions); + } + + CONFIG::commercialVersion + public function setModel(model:Logo):void { + log.debug("setModel() using configured logo settings"); + _model = model; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/view/PlayButtonOverlayView.as b/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/view/PlayButtonOverlayView.as new file mode 100644 index 0000000000000000000000000000000000000000..22c8b7e096a61bc0efe9396bb84b515fcabad6d8 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript-commercial/org/flowplayer/view/PlayButtonOverlayView.as @@ -0,0 +1,444 @@ + +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import flash.display.DisplayObject; + import flash.events.MouseEvent; + import flash.events.TimerEvent; + import flash.utils.getDefinitionByName; + + import org.flowplayer.controller.ResourceLoader; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipEvent; + import org.flowplayer.model.ClipEventSupport; + import org.flowplayer.model.DisplayPluginModel; + import org.flowplayer.model.DisplayProperties; + import org.flowplayer.model.PlayButtonOverlay; + import org.flowplayer.model.Playlist; + import org.flowplayer.model.Plugin; + import org.flowplayer.model.PluginEventType; + import org.flowplayer.model.PluginModel; + import org.flowplayer.model.State; + import org.flowplayer.util.Arrange; + import org.flowplayer.view.BuiltInAssetHelper; + import org.flowplayer.view.BuiltInAssetHelper; + + public class PlayButtonOverlayView extends AbstractSprite implements Plugin { + + private var _button:DisplayObject; + private var _pluginRegistry:PluginRegistry; + + private var _player:Flowplayer; + private var _showButtonInitially:Boolean; + private var _tween:Animation; + private var _resizeToTextWidth:Boolean; + private var _screen:Screen; + private var _playlist:Playlist; + private var _origAlpha:Number; + private var _play:PlayButtonOverlay; + private var _rotation:RotatingAnimation; + + public function PlayButtonOverlayView(resizeToTextWidth:Boolean, play:PlayButtonOverlay, pluginRegistry:PluginRegistry) { + _resizeToTextWidth = resizeToTextWidth; + _pluginRegistry = pluginRegistry; + _pluginRegistry.registerDisplayPlugin(play, this); + _play = play; + createChildren(); + buttonMode = true; + + startBuffering(); + + addEventListener(MouseEvent.MOUSE_OVER, onMouseOver); + addEventListener(MouseEvent.MOUSE_OUT, onMouseOut); + } + + public function set playlist(playlist:Playlist):void { + _playlist = playlist; + addListeners(playlist); + } + + + [External] + public function set label(label:String):void { + _play.label = label; + switchLabel(label); + _pluginRegistry.update(_play); + } + + private function switchLabel(label:String):void { + if (! _player) return; + log.debug("switchLabel() label '" + label + "'"); + if (label && (! _button || ! (_button is LabelPlayButton))) { + log.debug("switching to label button "); + switchButton(new LabelPlayButton(_player, label)); + } + if (! label && (! _button || (_button is LabelPlayButton))) { + log.debug("switching to standard non-label button "); + switchButton(new PlayOverlay()); + } + if (label) { + LabelPlayButton(_button).setLabel(label, _resizeToTextWidth); + } + onResize(); + } + + [External] + public function set replayLabel(label:String):void { + if (! _player) return; + log.debug("set replayLabel '" + label + "'"); + _play.replayLabel = label; + _pluginRegistry.update(_play); + } + + CONFIG::commercialVersion { + [External] + public function set image(url:String):void { + log.debug("set image() will show? " + (_button.parent == this)); + _play.url = url; + loadImage(url, null, _button.parent == this); + _pluginRegistry.update(_play); + } + } + + override public function set alpha(value:Number):void { + log.debug("setting alpha to " + value + " tween " + _tween); + super.alpha = value; + if (_button) { + _button.alpha = value; + } + _rotation.alpha = value; + } + + private function switchButton(newButton:DisplayObject):void { + removeChildIfAdded(_button); + _button = newButton; + if (_button is AbstractSprite) { + AbstractSprite(_button).setSize(width - 15, height - 15); + } + } + + private function onMouseOut(event:MouseEvent = null):void { + if (!_button) return; + _button.alpha = Math.max(0, model.alpha - 0.3); + } + + private function onMouseOver(event:MouseEvent):void { + if (!_button) return; + _button.alpha = model.alpha; + } + + public function onLoad(player:Flowplayer):void { + log.debug("onLoad"); + // we need the player to be as the ErrorHandler before loading the image file + _player = player; + + if (_play.label && _showButtonInitially) { + showButton(null, _play.label); + } + + CONFIG::commercialVersion { + if (useLoadedImage()) { + loadImage(_play.url, function():void { + _play.dispatch(PluginEventType.LOAD); + }, _showButtonInitially); + } else { + log.debug("dispatching complete"); + _play.dispatch(PluginEventType.LOAD); + } + } + CONFIG::freeVersion { + log.debug("dispatching complete"); + _play.dispatch(PluginEventType.LOAD); + } + } + + CONFIG::commercialVersion + private function useLoadedImage():Boolean { + return Boolean(_play.url && ! _play.label && ! BuiltInAssetHelper.hasPlayButton); + } + + private function addListeners(eventSupport:ClipEventSupport):void { + //eventSupport.onConnect(showButton); // bug #38 + eventSupport.onConnect(startBuffering); + + // onBegin is here because onBeforeBegin is not dispatched when playing after a timed out and invalid netConnection + eventSupport.onStart(hideButton); + + eventSupport.onBeforeBegin(hideButton); + eventSupport.onBeforeBegin(startBuffering); + + eventSupport.onResume(hide); + + // onPause: call stopBuffering first and then showButton (stopBuffering hides the button) + eventSupport.onPause(stopBuffering); + eventSupport.onPause(showButton); + + eventSupport.onStop(stopBuffering); + eventSupport.onStop(showButton, isParentClip); + + // onBeforeFinish: call stopBuffering first and then showButton (stopBuffering hides the button) + eventSupport.onBeforeFinish(stopBuffering); + eventSupport.onBeforeFinish(showReplayButton, isParentClipOrPostroll); + + // showing the buffer animation on buffer empty causes trouble with live streams and also on other cases +// eventSupport.onBufferEmpty(startBuffering); + + eventSupport.onBufferFull(stopBuffering); + + eventSupport.onBeforeSeek(startBuffering); + eventSupport.onSeek(stopBuffering); + + eventSupport.onBufferStop(stopBuffering); + eventSupport.onBufferStop(showButton); + } + + private function isParentClip(clip:Clip):Boolean { + return ! clip.isInStream; + } + + private function isParentClipOrPostroll(clip:Clip):Boolean { + return clip.isPostroll || ! clip.isInStream; + } + + private function rotate(event:TimerEvent):void { + _rotation.rotation += 10; + } + + private function createChildren():void { + _rotation = new RotatingAnimation(); + //addChild(_rotation); // bug #38 + + if (! _play.label) { + createInternalButton(); + } + } + + private function createInternalButton():void { + _button = BuiltInAssetHelper.createPlayButton() || new PlayOverlay(); + addButton(); + onResize(); + } + + private function getClass(name:String):Class { + return getDefinitionByName(name) as Class; + } + + private function addButton():void { + log.debug("addButton"); + if (model.visible) { + addChild(_button); + } + } + + CONFIG::commercialVersion + private function loadImage(url:String, callback:Function = null, show:Boolean = false):void { + log.debug("loading a custom button image from url " + url + ", will show? " + show); + _player.createLoader().load(url, function(loader:ResourceLoader):void { + initializeButtonImage(loader.getContent() as DisplayObject, show); + if (callback != null) { + callback(); + } + }); + } + + CONFIG::commercialVersion + private function initializeButtonImage(image:DisplayObject, show:Boolean):void { + switchButton(image); + _button.alpha = model.alpha; + log.debug("loaded image " + _play.url); + if (show) { + log.debug("showing button"); + showButton(); + } + onResize(); + } + + protected override function onResize():void { + log.debug("onResise " + width); + if (! _button) return; + onMouseOut(); + if (_button is LabelPlayButton) { + AbstractSprite(_button).setSize(width - 15, height - 15); + } else { + _button.height = height; + _button.scaleX = _button.scaleY; + } + _rotation.setSize(width, height); + + Arrange.center(_button, width, height); + log.debug("arranged to y " + _button.y + ", this height " + height + ", screen height " + (_screen ? _screen.height : 0)); + } + + private function hide(event:ClipEvent = null):void { + log.debug("hide()"); + if (! this.parent) return; + if (_player) { + log.debug("fading out with speed " + _play.fadeSpeed + " current alpha is " + alpha); +// _screen.hidePlay(); + _origAlpha = model.alpha; + _tween = _player.animationEngine.fadeOut(_button, _play.fadeSpeed, onFadeOut, false); + } else { + onFadeOut(); + } + } + + private function onFadeOut():void { + restoreOriginalAlpha(); + if (_tween && _tween.canceled) { + _tween = null; + return; + } + _tween = null; + log.debug("removing button"); + + removeChildIfAdded(_button); +// _screen.hidePlay(); + } + + private function show():void { + if (_tween) { + restoreOriginalAlpha(); + log.debug("canceling fadeOut tween"); + _tween.cancel(); + } + + if (_screen && this.parent == _screen) { + _screen.arrangePlay(); + return; + } + + if (_screen) { + log.debug("calling screen.showPlay"); + _screen.showPlay(); + } + } + + private function restoreOriginalAlpha():void { + alpha = _origAlpha; + var play:DisplayProperties = model; + play.alpha = _origAlpha; + _pluginRegistry.updateDisplayProperties(play); + } + + public function showButton(event:ClipEvent = null, label:String = null):void { + log.debug("showButton(), label " + label); + + // we only support labels if a custom button is not defined + CONFIG::commercialVersion { + if (! _play.url) { + switchLabel(label || _play.label); + } + } + CONFIG::freeVersion { + switchLabel(label || _play.label); + } + + if (! _button) return; + if (_rotation.parent == this) return; + + if (event == null) { + // not called based on event --> update display props + + var props:DisplayProperties = model; + props.display = "block"; + _pluginRegistry.updateDisplayProperties(props); + } + + addButton(); + show(); + onResize(); + } + + public function showReplayButton(event:ClipEvent = null):void { + + log.info("showReplayButton, playlist has more clips " + _playlist.hasNext(false)); + if (event.isDefaultPrevented() && _playlist.hasNext(false)) { + // default prevented, will stop after current clip. Show replay button. + log.debug("showing replay button"); + showButton(null, _play.replayLabel); + return; + } + if (_playlist.hasNext(false) && _playlist.nextClip.autoPlay) { + return; + } + showButton(event, _playlist.hasNext(false) ? null : _play.replayLabel); + } + + public function hideButton(event:ClipEvent = null):void { + log.debug("hideButton() " + _button); + removeChildIfAdded(_button); + } + + public function startBuffering(event:ClipEvent = null):void { + log.debug("startBuffering()" + event); + if (event && event.isDefaultPrevented()) return; + if (!_play.buffering) return; + +// if (_button && _button.parent == this) { +// // already showing button, don't show buffering +// return; +// } + addChild(_rotation); + + // bug #62 + if ( _tween && _player && _player.state == State.PLAYING ) { + removeChildIfAdded(_button); + } + + show(); + _rotation.start(); + } + + public function stopBuffering(event:ClipEvent = null):void { + log.debug("stopBuffering()"); + _rotation.stop(); + removeChildIfAdded(_rotation); + if (! _tween && _player.state == State.BUFFERING || _player.state == State.BUFFERING) { + removeChildIfAdded(_button); + } + } + + private function removeChildIfAdded(child:DisplayObject):void { + if (! child) return; + if (child.parent != this) return; + log.debug("removing child " + child); + removeChild(child); + } + + public function onConfig(configProps:PluginModel):void { + } + + public function getDefaultConfig():Object { + return null; + } + + public function setScreen(screen:Screen, showInitially:Boolean = false):void { + _screen = screen; + _showButtonInitially = showInitially; + if (showInitially) { + showButton(); + } + startBuffering(); + } + + private function get model():DisplayPluginModel { + return DisplayPluginModel(_pluginRegistry.getPlugin("play")); + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/mx/core/BitmapAsset.as b/typo3/contrib/flowplayer/src/actionscript/mx/core/BitmapAsset.as new file mode 100644 index 0000000000000000000000000000000000000000..054e8907aad905a214f0ff727a0305f8baeca1f7 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/mx/core/BitmapAsset.as @@ -0,0 +1,9 @@ +package mx.core +{ + import flash.display.Bitmap; + + /** + * Fake BitmapAsset to avoid including the flex framework.swc + */ + public class BitmapAsset extends Bitmap {} +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/Config.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/Config.as new file mode 100644 index 0000000000000000000000000000000000000000..14bfc2a91001115cb96659160262d0d69c5dc47d --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/Config.as @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.config { + import flash.utils.ByteArray; + + import org.flowplayer.config.PluginBuilder; + import org.flowplayer.controller.NetStreamControllingStreamProvider; + import org.flowplayer.flow_internal; + import org.flowplayer.model.Canvas; + import org.flowplayer.model.Clip; + import org.flowplayer.model.DisplayProperties; + import org.flowplayer.model.Loadable; + import org.flowplayer.model.Logo; + import org.flowplayer.model.PlayButtonOverlay; + import org.flowplayer.model.Playlist; + import org.flowplayer.model.PluginModel; + import org.flowplayer.model.ProviderModel; + import org.flowplayer.util.Assert; + import org.flowplayer.util.LogConfiguration; + import org.flowplayer.util.PropertyBinder; + + import flash.display.DisplayObject; + + use namespace flow_internal; + + /** + * @author anssi + */ + public class Config { + + private var playList:Playlist; + private var _configObject:Object; + private var _pluginBuilder:PluginBuilder; + private var _playlistBuilder:PlaylistBuilder; + public var logFilter:String; + private var _playerSwfUrl:String; + private var _controlsVersion:String; + private var _audioVersion:String; + private var _loadables:Array; + private var _canvas:Canvas; + + public function Config(config:Object, builtInConfig:Object, playerSwfUrl:String, controlsVersion:String, audioVersion:String) { + Assert.notNull(config, "No configuration provided."); + this._configObject = createConfigObject(config, builtInConfig); + _playerSwfUrl = playerSwfUrl; + _playlistBuilder = new PlaylistBuilder(playerId, this._configObject.playlist, this._configObject.clip); + _controlsVersion = controlsVersion; + _audioVersion = audioVersion; + } + + private function createConfigObject(configured:Object, builtInConfig:Object):Object { + var buffer:ByteArray = new ByteArray(); + buffer.writeObject(builtInConfig); + buffer.position = 0; + var result:Object = buffer.readObject(); + + return copyProps(result, configured); + } + + private function copyProps(target:Object, source:Object, propName:String = null):Object { + if (source is Number || source is String || source is Boolean) { + target = source; + return target; + } + + if (source is Array) { + if (target.hasOwnProperty(propName)) { + for (var i:int = 0; i < source.length; i++) { + (target[propName] as Array).push(source[i]); + } + } + return target; + } + + for (var key:String in source) { + if (target.hasOwnProperty(key)) { + target[key] = copyProps(target[key], source[key], key); + } else { + target[key] = source[key]; + } + } + return target; + } + + flow_internal function set playlistDocument(docObj:String):void { + _playlistBuilder.playlistFeed = docObj; + } + + public function get playerId():String { + return this._configObject.playerId; + } + + public function createClip(clipObj:Object):Clip { + return _playlistBuilder.createClip(clipObj); + } + + public function createCuepoints(cueObjects:Array, callbackId:String, timeMultiplier:Number):Array { + return _playlistBuilder.createCuepointGroup(cueObjects, callbackId, timeMultiplier); + } + + public function createClips(playlist:Object = null):Array { + return _playlistBuilder.createClips(playlist); + } + + public function getPlaylist():Playlist { + if (_configObject.playlist is String && ! _playlistBuilder.playlistFeed) { + throw new Error("playlist queried but the playlist feed file has not been received yet"); + } + if (! playList) { + playList = _playlistBuilder.createPlaylist(); + } + return playList; + } + + public function getLoadables():Array { + if (!_loadables) { + _loadables = viewObjectBuilder.createLoadables(getPlaylist()); + } + return _loadables; + } + + private function getLoadable(name:String):Loadable { + var loadables:Array = getLoadables(); + for (var i:Number = 0; i < loadables.length; i++) { + var loadable:Loadable = loadables[i]; + if (loadable.name == name) { + return loadable; + } + } + return null; + } + + private function get viewObjectBuilder():PluginBuilder { + if (_pluginBuilder == null) { + _pluginBuilder = new PluginBuilder(_playerSwfUrl, _controlsVersion, _audioVersion, this, _configObject.plugins, _configObject); + } + return _pluginBuilder; + } + + public function getScreenProperties():DisplayProperties { + return viewObjectBuilder.getScreen(getObject("screen")); + } + + public function getPlayButtonOverlay():PlayButtonOverlay { + var play:PlayButtonOverlay = viewObjectBuilder.getDisplayProperties(getObject("play"), "play", PlayButtonOverlay) as PlayButtonOverlay; + if (play) { + play.buffering = useBufferingAnimation; + } + return play; + } + + public function getLogo(view:DisplayObject):Logo { + return new PropertyBinder(new Logo(view, "logo"), null).copyProperties(getObject("logo"), true) as Logo; + } + + public function getObject(name:String):Object { + return _configObject[name]; + } + + public function getLogConfiguration():LogConfiguration { + if (! _configObject.log) return new LogConfiguration(); + return new PropertyBinder(new LogConfiguration(), null).copyProperties(_configObject.log) as LogConfiguration; + } + + public function get licenseKey():Object { + return _configObject.key || _configObject.keys; + } + + public function get canvas():Canvas { + if (! _canvas) { + var style:Object = getObject("canvas"); + if (! style) { + style = new Object(); + } + setProperty("backgroundGradient", style, [ 0.3, 0 ]); + setProperty("border", style, "0px"); + setProperty("backgroundColor", style, "transparent"); + setProperty("borderRadius", style, "0"); + + var result:Canvas = new Canvas(); + result.style = style; + + _canvas = new PropertyBinder(result, "style").copyProperties(style) as Canvas; + } + return _canvas; + } + + private function setProperty(prop:String, style:Object, value:Object):void { + if (! style[prop]) { + style[prop] = value; + } + } + + public function get contextMenu():Array { + return getObject("contextMenu") as Array; + } + + public function getPlugin(disp:DisplayObject, name:String, config:Object):PluginModel { + return viewObjectBuilder.getPlugin(disp, name, config); + } + + public function get showErrors():Boolean { + if (! _configObject.hasOwnProperty("showErrors")) return true; + return _configObject["showErrors"]; + } + + public function get useBufferingAnimation():Boolean { + if (! _configObject.hasOwnProperty("buffering")) return true; + return _configObject["buffering"]; + } + + public function createHttpProvider(name:String):ProviderModel { + var provider:NetStreamControllingStreamProvider = new NetStreamControllingStreamProvider(); + + var model:ProviderModel = new ProviderModel(provider, name); + provider.model = model; + +// var conf:Loadable = config.http; +// if (conf) { +// new PropertyBinder(model).copyProperties(conf.config); +// } + return model; + } + + public function get streamCallbacks():Array { + return _configObject["streamCallbacks"]; + } + + public function get connectionCallbacks():Array { + return _configObject["connectionCallbacks"]; + } + + public function get playlistFeed():String { + return _configObject.playlist is String ? _configObject.playlist : null; + } + + public function get playerSwfUrl():String { + return _playerSwfUrl; + } + + public function get configObject():Object { + return _configObject; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/ConfigParser.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/ConfigParser.as new file mode 100644 index 0000000000000000000000000000000000000000..fb1ccbaab245a048419deed3eb889df1ecd05d89 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/ConfigParser.as @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.config { + import org.flowplayer.controller.ResourceLoader; +import org.flowplayer.flow_internal; + import org.flowplayer.util.Log; + + import com.adobe.serialization.json.JSON; + + use namespace flow_internal; + + /** + * @author anssi + */ + public class ConfigParser { + private static var log:Log = new Log(ConfigParser); + + flow_internal static function parse(config:String):Object { + return JSON.decode(config); + } + + flow_internal static function parseConfig(config:Object, builtInConfig:Object, playerSwfUrl:String, controlsVersion:String, audioVersion:String):Config { + if (!config) return new Config({}, builtInConfig, playerSwfUrl, controlsVersion, audioVersion); + var configObj:Object = config is String ? JSON.decode(config as String) : config; + return new Config(configObj, builtInConfig, playerSwfUrl, controlsVersion, audioVersion); + } + + flow_internal static function loadConfig(fileName:String, builtInConfig:Object, listener:Function, loader:ResourceLoader, playerSwfName:String, controlsVersion:String, audioVersion:String):void { + loader.load(fileName, function(loader:ResourceLoader):void { + trace(loader.getContent()); + listener(parseConfig(loader.getContent(), builtInConfig, playerSwfName, controlsVersion, audioVersion)) + }, true); + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/ExternalInterfaceHelper.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/ExternalInterfaceHelper.as new file mode 100644 index 0000000000000000000000000000000000000000..a2b7123b8633025c8f95b4d0a2396adec55fe505 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/ExternalInterfaceHelper.as @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.config { + import flash.external.ExternalInterface; + import flash.utils.describeType; + import flash.utils.getDefinitionByName; + import flash.utils.getQualifiedClassName; + + import org.flowplayer.model.Callable; + import org.flowplayer.model.PluginMethod; + import org.flowplayer.util.Log; + + /** + * @author api + */ + public class ExternalInterfaceHelper { + + private static var log:Log = new Log("org.flowplayer.config::ExternalInterfaceHelper"); + + public static function initializeInterface(callable:Callable, plugin:Object):void { + if (!ExternalInterface.available) return; + var xml:XML = describeType(plugin); + + var exposed:XMLList = xml.*.(hasOwnProperty("metadata") && metadata.@name=="External"); + log.info("Number of exposed methods and accessors: " + exposed.length()); + for each (var exposedNode:XML in exposed) { + log.debug("processing exposed method or accessor " + exposedNode); + addMethods(callable, exposedNode, plugin); + } + } + + private static function addMethods(callable:Callable, exposedNode:XML, plugin:Object):void { + var methodName:String = exposedNode.@name; + var convert:Boolean = exposedNode.metadata.arg.@key == "convert" ? exposedNode.metadata.arg.@value == "true" : false; + + log.debug("------------" + methodName + ", has return value " + (exposedNode.@returnType != "void") +", convertResult " + convert); + if (exposedNode.name() == "method") { + callable.addMethod(PluginMethod.method(methodName, methodName, (exposedNode.@returnType != "void"), convert)); + + } else if (exposedNode.name() == "accessor") { + var methodNameUppercased:String = methodName.charAt(0).toUpperCase() + methodName.substring(1); + if (exposedNode.@access == "readwrite") { + callable.addMethod(PluginMethod.getter("get" + methodNameUppercased, methodName, convert)); + callable.addMethod(PluginMethod.setter("set" + methodNameUppercased, methodName)); + + } else if (exposedNode.@access == "readonly") { + callable.addMethod(PluginMethod.getter("get" + methodNameUppercased, methodName, convert)); + + } else { + callable.addMethod(PluginMethod.setter("set" + methodNameUppercased, methodName)); + } + } + } + + public static function addCallback(methodName:String, func:Function):void { + try { + ExternalInterface.addCallback(methodName, func); + } catch (error:Error) { + log.error("Unable to register callback for " + error); + } + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/PlaylistBuilder.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/PlaylistBuilder.as new file mode 100644 index 0000000000000000000000000000000000000000..ecb6825bdac35315234e4cd3c0ccc1c1e058915a --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/PlaylistBuilder.as @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.config { + import org.flowplayer.flow_internal; + import org.flowplayer.model.Clip; + import org.flowplayer.model.Cuepoint; + import org.flowplayer.model.NullClip; + import org.flowplayer.model.Playlist; + import org.flowplayer.util.Log; + import org.flowplayer.util.PropertyBinder; + import org.flowplayer.util.URLUtil; + + use namespace flow_internal; + + /** + * @author anssi + */ + internal class PlaylistBuilder { + private static const NESTED_PLAYLIST:String = "playlist"; + private var log:Log = new Log(this); + private var _clipObjects:Array; + private var _commonClipObject:Object; + private var _commonClip:Clip; + private var _playerId:String; + private var _playlistFeed:String; + + + /** + * Creates a new PlayListBuilder + * @param playerId + * @param playlist + * @param commonClip + */ + public function PlaylistBuilder(playerId:String, playlist:Object, commonClip:Object) { + _playerId = playerId; + _commonClipObject = commonClip; + if (playlist is Array) { + _clipObjects = playlist as Array; + } + } + + /** + * Sets a playlist feed to be used to create the playlist. + * @param feed + * @return + */ + public function set playlistFeed(feed:String):void { + _playlistFeed = feed; + } + + + public function createPlaylist():Playlist { + if (_commonClipObject) { + _commonClip = createClip(_commonClipObject); + } + var playList:Playlist = new Playlist(_commonClip); + + if (_playlistFeed) { + parse(_playlistFeed, playList, _commonClipObject); + } else if (_clipObjects && _clipObjects.length > 0) { + playList.setClips(createClips(_clipObjects)); + } else if (_commonClip) { + playList.addClip(createClip(_commonClipObject)); + } + + return playList; + } + + public function createClips(clipObjects:Object):Array { + + if (clipObjects is String) { + return new RSSPlaylistParser().parse(clipObjects as String, null, _commonClipObject); + } + + var clips:Array = new Array(); + for (var i : Number = 0; i < (clipObjects as Array).length; i++) { + var clipObj:Object = (clipObjects as Array)[i]; + if (clipObj is String) { + clipObj = { url: clipObj }; + } + clips.push(createClip(clipObj)); + } + return clips; + } + + public function createClip(clipObj:Object, isChild:Boolean = false):Clip { + log.debug("createClip, from ", clipObj); + if (! clipObj) return null; + if (clipObj is String) { + clipObj = { url: clipObj }; + } + setDefaults(clipObj); + var url:String = clipObj.url; + var baseUrl:String = clipObj.baseUrl; + var fileName:String = url; + if (URLUtil.isCompleteURLWithProtocol(url)) { + var lastSlashIndex:Number = url.lastIndexOf("/"); + baseUrl = url.substring(0, lastSlashIndex); + fileName = url.substring(lastSlashIndex + 1); + } + var clip:Clip = Clip.create(clipObj, fileName, baseUrl); + new PropertyBinder(clip, "customProperties").copyProperties(clipObj) as Clip; + if (isChild || clipObj.hasOwnProperty("position")) { + return clip; + } + + if (clipObj.hasOwnProperty(NESTED_PLAYLIST)) { + addChildClips(clip, clipObj[NESTED_PLAYLIST]); + } else if (_commonClipObject && _commonClipObject.hasOwnProperty(NESTED_PLAYLIST)) { + addChildClips(clip, _commonClipObject[NESTED_PLAYLIST]); + } + return clip; + } + + private function addChildClips(clip:Clip, children:Array):void { + for (var i:int = 0; i < children.length; i++) { + var child:Object = children[i]; + if (! child.hasOwnProperty("position")) { + if (i == 0) { + child["position"] = 0; + } + else if (i == children.length -1) { + child["position"] = -1; + } + else { + throw new Error("position not defined in a nested clip"); + } + } + clip.addChild(createClip(child, true)); + } + } + + public function createCuepointGroup(cuepoints:Array, callbackId:String, timeMultiplier:Number):Array { + log.debug("createCuepointGroup(), creating " + cuepoints.length + " cuepoints"); + var cues:Array = new Array(); + for (var i:Number = 0; i < cuepoints.length; i++) { + var cueObj:Object = cuepoints[i]; + var cue:Object = createCuepoint(cueObj, callbackId, timeMultiplier); + cues.push(cue); + } + return cues; + } + + private function setDefaults(clipObj:Object):void { + if (clipObj == _commonClipObject) return; + + for (var prop:String in _commonClipObject) { + if (! clipObj.hasOwnProperty(prop) && prop != NESTED_PLAYLIST) { + clipObj[prop] = _commonClipObject[prop]; + } + } + } + + private function createCuepoint(cueObj:Object, callbackId:String, timeMultiplier:Number):Object { + log.debug("createCuepoint(), creating cuepoint from: ", cueObj); + if (cueObj is Number) return new Cuepoint(roundTime(cueObj as int, timeMultiplier), callbackId); + if (! cueObj.hasOwnProperty("time")) throw new Error("Cuepoint does not have time: " + cueObj); + var cue:Object = Cuepoint.createDynamic(roundTime(cueObj.time, timeMultiplier), callbackId); + var parameters:Object = {}; + for (var prop:String in cueObj) { + if (prop == "parameters") { + + for (var paramName:String in cueObj[prop]) { + parameters[paramName] = cueObj[prop][paramName]; + } + cue["parameters"] = parameters; + } else if (prop != "time") { + cue[prop] = cueObj[prop]; + log.debug("added prop " + prop, cueObj[prop]); + } + +// log.debug("added cynamic property " + prop + ", to value " + cue[prop]); + } + return cue; + } + + private function roundTime(time:int, timeMultiplier:Number):int { + return Math.round(time * timeMultiplier / 100) * 100; + } + + private function parse(document:String, playlist:Playlist, commonClipObj:Object):void { + var playlist:Playlist = playlist; + if (document.indexOf("[") == 0) { + var clips:Object = ConfigParser.parse(document); + playlist.setClips(createClips(clips)); + } else { + new RSSPlaylistParser().parse(document, playlist, commonClipObj); + } + } + + public function get playlistFeed():String { + return _playlistFeed; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/PluginBuilder.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/PluginBuilder.as new file mode 100644 index 0000000000000000000000000000000000000000..fc424ec4bcc39127d99d8fd9ed2cfc0433ea5c82 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/PluginBuilder.as @@ -0,0 +1,277 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.config { + import org.flowplayer.flow_internal; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipType; + import org.flowplayer.model.Playlist; + + import flash.display.DisplayObject; + + import org.flowplayer.model.DisplayPluginModel; + import org.flowplayer.model.DisplayPluginModelImpl; + import org.flowplayer.model.DisplayProperties; + import org.flowplayer.model.DisplayPropertiesImpl; + import org.flowplayer.model.Loadable; + import org.flowplayer.model.Plugin; + import org.flowplayer.model.PluginModel; + import org.flowplayer.util.Log; + import org.flowplayer.util.PropertyBinder; + + + use namespace flow_internal; + + internal class PluginBuilder { + + private var log:Log = new Log(this); + private var _pluginObjects:Object; + private var _skinObjects:Object; + private var _config:Config; + private var _playerURL:String; + private var _controlsVersion:String; + private var _audioVersion:String; + private var _loadables:Array; + + public function PluginBuilder(playerSwfName:String, controlsVersion:String, audioVersion:String, config:Config, pluginObjects:Object, skinObjects:Object) { + _playerURL = playerSwfName; + _config = config; + _pluginObjects = pluginObjects || new Object(); + _skinObjects = skinObjects || new Object(); + _controlsVersion = controlsVersion; + _audioVersion = audioVersion; + _loadables = []; + updatePrototypedLoadableUrls(); + log.debug("pluginObject ", _pluginObjects); + } + + + public function createLoadables(playlist:Playlist):Array { + for (var name:String in _pluginObjects) { + if (! isObjectDisabled(name, _pluginObjects) && (_pluginObjects[name].hasOwnProperty("url") || name == "controls" || name == "audio")) { + log.debug("creating loadable for '" + name + "', " + _pluginObjects[name]); + _loadables.push(newLoadable(_pluginObjects, name)); + } + } + + log.debug("initializing default loadables: controls and audio if needed"); + var builtIn:Boolean = isBuiltIn("controls"); + log.debug("controls is builtin? " + builtIn); + if (! builtIn) { + initLoadable("controls", _controlsVersion); + } + if (hasAudioClipsWithoutProvider(playlist) && ! isBuiltIn("audio")) { + initLoadable("audio", _audioVersion); + } + createInStreamProviders(playlist, _loadables); + return _loadables; + } + + private function hasAudioClipsWithoutProvider(playlist:Playlist):Boolean { + var clips:Array = playlist.clips; + for (var i:int; i < clips.length; i++) { + var clip:Clip = clips[i] as Clip; + + if (ClipType.AUDIO == clip.type) { + return ! clip.clipObject || ! clip.clipObject.hasOwnProperty("provider"); + } + } + return false; + } + + private function isBuiltIn(name:String):Boolean { + return _pluginObjects[name] && _pluginObjects[name].hasOwnProperty("url") && String(_pluginObjects[name]["url"]).toLocaleLowerCase().indexOf(".swf") < 0; + } + + private function updatePrototypedLoadableUrls():void { + for (var name:String in _pluginObjects) { + var plugin:Object = _pluginObjects[name]; + if (plugin && plugin.hasOwnProperty("prototype")) { + var prototype:Object = _pluginObjects[plugin["prototype"]]; + if (! prototype) { + throw new Error("Prototype " + plugin["prototype"] + " not available"); + } + log.debug("found a prototype reference '" + plugin["prototype"] + "', resolved to class name " + prototype.url); + plugin.url = prototype.url; + } + } + } + + private function newLoadable(fromObjects:Object, name:String, nameInConf:String = null, url:String = null):Loadable { + var loadable:Loadable = new PropertyBinder(new Loadable(name, _config), "config").copyProperties(fromObjects[nameInConf || name]) as Loadable; + if (url) { + loadable.url = url; + } + return loadable; + } + + private function createInStreamProviders(playlist:Playlist, loadables:Array):void { + var children:Array = playlist.childClips; + for (var i:int = 0; i < children.length; i++) { + var clip:Clip = children[i]; + if (clip.configuredProviderName != "http") { + var loadable:Loadable = findLoadable(clip.configuredProviderName); + if (loadable && ! findLoadable(clip.provider)) { + loadable = newLoadable(_pluginObjects, clip.provider, clip.configuredProviderName); + loadables.push(loadable); + } + } + } + } + + private function isObjectDisabled(name:String, confObjects:Object):Boolean { + if (! confObjects.hasOwnProperty(name)) return false; + var pluginObj:Object = confObjects[name]; + return pluginObj == null; + } + + private function initLoadable(name:String, version:String):Loadable { + log.debug("createLoadable() '" + name + "' version " + version); + if (isObjectDisabled(name, _pluginObjects)) { + log.debug(name + " is disabled"); + return null; + } + var loadable:Loadable = findLoadable(name); + + if (! loadable) { + loadable = new Loadable(name, _config); + _loadables.push(loadable); + } else { + log.debug(name + " was found in configuration, will not automatically add it into loadables"); + } + + if (! loadable.url) { + loadable.url = getLoadableUrl(name, version); + } + log.debug("createLoadable(), created loadable with url " + loadable.url) + return loadable; + } + + private function findLoadable(name:String):Loadable { + for (var i:Number = 0; i < _loadables.length; i++) { + var plugin:Loadable = _loadables[i]; + if (plugin.name == name) { + return plugin; + } + } + return null; + } + + private function getLoadableUrl(name:String, version:String):String { + var playerVersion:String = getPlayerVersion(); + log.debug("player version detected from SWF name is " + playerVersion); + if (playerVersion) { + return "flowplayer." + name + "-" + version + ".swf"; + } else { + return "flowplayer." + name + ".swf"; + } + } + + private function getPlayerVersion():String { + var version:String = getVersionFromSwfName("flowplayer"); + if (version) return version; + + version = getVersionFromSwfName("flowplayer.commercial"); + if (version) return version; + + return getVersionFromSwfName("flowplayer.unlimited"); + } + + private function getVersionFromSwfName(swfName:String):String { + log.debug("getVersionFromSwfName() " + playerSwfName); + if (playerSwfName.indexOf(swfName) < 0) return null; + if (playerSwfName.indexOf(".swf") < (swfName + "-").length) return null; + return playerSwfName.substring(playerSwfName.indexOf("-") + 1, playerSwfName.indexOf(".swf")); + } + + private function get playerSwfName():String { + var lastSlash:Number = _playerURL.lastIndexOf("/"); + return _playerURL.substring(lastSlash + 1, _playerURL.indexOf(".swf") + 4); + } + + + public function getDisplayProperties(conf:Object, name:String, DisplayPropertiesClass:Class = null):DisplayProperties { + if (isObjectDisabled(name, _skinObjects)) { + log.debug(name + " is disabled"); + return null; + } + var props:DisplayProperties = DisplayPropertiesClass ? new DisplayPropertiesClass() as DisplayProperties : new DisplayPropertiesImpl(); + if (conf) { + new PropertyBinder(props, null).copyProperties(conf); + } + props.name = name; + return props; + } + + public function getScreen(screenObj:Object):DisplayProperties { + log.warn("getScreen " + screenObj); + var screen:DisplayProperties = new DisplayPropertiesImpl(null, "screen", false); + new PropertyBinder(screen, null).copyProperties(getScreenDefaults()); + if (screenObj) { + log.info("setting screen properties specified in configuration"); + new PropertyBinder(screen, null).copyProperties(screenObj); + } + screen.zIndex = 0; + return screen; + } + + private function getScreenDefaults():Object { + var screen:Object = new Object(); + screen.left = "50%"; + screen.bottom = "50%"; + screen.width = "100%"; + screen.height = "100%"; + screen.name = "screen"; + screen.zIndex = 0; + return screen; + } + + public function getPlugin(disp:DisplayObject, name:String, config:Object):PluginModel { + var plugin:DisplayPluginModel = new PropertyBinder(new DisplayPluginModelImpl(disp, name, false), "config").copyProperties(config, true) as DisplayPluginModel; + log.debug(name + " position specified in config " + plugin.position); + + // add defaults settings from the plugin instance (will not override those set in config) + if (disp is Plugin) { + log.debug(name + " implements Plugin, querying defaultConfig"); + var defaults:Object = Plugin(disp).getDefaultConfig(); + if (defaults) { + fixPositionSettings(plugin, defaults); + if (! (config && config.hasOwnProperty("opacity")) && defaults.hasOwnProperty("opacity")) { + plugin.opacity = defaults["opacity"]; + } + plugin = new PropertyBinder(plugin, "config").copyProperties(defaults, false) as DisplayPluginModel; + log.debug(name + " position after applying defaults " + plugin.position + ", zIndex " + plugin.zIndex); + } + } + return plugin; + } + + private function fixPositionSettings(props:DisplayProperties, defaults:Object):void { + clearOpposite("bottom", "top", props, defaults); + clearOpposite("left", "right", props, defaults); + } + + private function clearOpposite(prop1:String, prop2:String, props:DisplayProperties, defaults:Object):void { + if (props.position[prop1].hasValue() && defaults.hasOwnProperty(prop2)) { + delete defaults[prop2]; + } else if (props.position[prop2].hasValue() && defaults.hasOwnProperty(prop1)) { + delete defaults[prop1]; + } + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/RSSPlaylistParser.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/RSSPlaylistParser.as new file mode 100644 index 0000000000000000000000000000000000000000..3a3df1b126187295bffa5aa00a3fb1de853ac4f6 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/config/RSSPlaylistParser.as @@ -0,0 +1,226 @@ +package org.flowplayer.config { + + import com.adobe.utils.XMLUtil; + + import org.flowplayer.flow_internal; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipType; + import org.flowplayer.model.Playlist; + import org.flowplayer.util.Log; + import org.flowplayer.util.PropertyBinder; + + + use namespace flow_internal; + + + + internal class RSSPlaylistParser { + private static const UNSUPPORTED_TYPE:int = 10; + private var log:Log = new Log(this); + private var ns:Namespace = new Namespace(""); + private var ym:Namespace = new Namespace("http://search.yahoo.com/mrss/"); + private var fp:Namespace = new Namespace("http://flowplayer.org/fprss/"); + + + public function createClips(rawRSS:String, playlist:Playlist, commonClipObject:Object):Array { + return parse(rawRSS, playlist, commonClipObject); + } + + public function parse(rawRSS:String, playlist:Playlist, commonClipObject:Object):Array { + var result:Array = []; + if(! XMLUtil.isValidXML(rawRSS)) { + throw new Error("Feed does not contain valid XML."); + } + + default xml namespace = ns; + + var rss:XML = new XML(rawRSS); + + if (rss.name() == "rss" && Number(rss.@version) <= 2) + { + + for each (var item:XML in rss.channel.item) { + + + try { + var clip:Clip = parseClip(item, commonClipObject); + } catch (e:Error) { + if (e.errorID == UNSUPPORTED_TYPE) { + log.info("unsupported media type, ignoring this item"); + } else { + throw e; + } + } + + if (clip) { + log.info("created clip " + clip); + result.push(clip); + if (playlist) { + playlist.addClip(clip, -1 , true); + } + } + + } + } + + return result; + } + + private function parseClip(item:XML, commonClipObject:Object):Clip { + var clip:Clip = new Clip(); + new PropertyBinder(clip, "customProperties").copyProperties(commonClipObject) as Clip; + + if (!clip.getCustomProperty("bitrates")) clip.setCustomProperty("bitrates", []); + if (item.link) clip.linkUrl = item.link; + + //parse a group media:content items inside a media:group tag + if (item.ym::group.ym::content.length() > 0) { + parseMediaGroup(item.ym::group, clip); + } + + //parse a single media:content item + if (item.ym::content.length() > 0) { + parseMediaItem(XML(item.ym::content), clip); + addBitrateItems(XML(item.ym::content), clip); + } + + //add flowplayer clip properties + if (item.fp::clip.attributes().length() > 0) { + parseClipProperties(item.fp::clip, clip); + } + + //add custom clip properties from rss elements + for each (var childItem:XML in item.children()) { + addClipCustomProperty(clip, childItem, parseCustomProperty(childItem)); + } + + log.debug("created clip " + clip); + return clip; + } + + private function setClipType(clip:Clip, typeVal:String):void { + var type:ClipType = ClipType.fromMimeType(typeVal); + if (! type) { + throw new Error("unsupported media type '" + typeVal + "'", UNSUPPORTED_TYPE); + } + clip.type = type; + } + + private function parseClipProperties(elem:XMLList, clip:Clip):void { + var binder:PropertyBinder = new PropertyBinder(clip, "customProperties"); + for each (var attr:XML in elem.attributes()) { + log.debug("parseClipProperties(), initializing clip property '" + attr.name() + "' to value " + attr.toString()); + binder.copyProperty(attr.name().toString(), attr.toString(), true); + } + } + + private function addClipCustomProperty(clip:Clip, elem:XML, value:Object):void { + log.debug("getting property name for " + elem.localName() + " value is ", value); + var name:String = getCustomPropName(elem); + var existing:Object = clip.getCustomProperty(name); + if (existing) { + log.debug("found existing " + existing); + var values:Array = existing is Array ? existing as Array : [existing]; + values.push(value); + clip.customProperties[name] = values; + } else { + clip.setCustomProperty(name, value); + } + log.debug("clip custom property " + name + " now has value ", clip.customProperties[name]); + + } + + private function getCustomPropName(elem:XML):String { + if (! elem.namespace()) return elem.localName().toString(); + if (! elem.namespace().prefix) return elem.localName().toString(); + return "'" + elem.namespace().prefix + ":" + elem.localName().toString() + "'"; +// return elem.namespace().prefix + elem.localName().charAt(0).toUpperCase() + elem.localName().substring(1);; + } + + private function parseCustomProperty(elem:XML):Object { + if (elem.children().length() == 0 && elem.attributes().length() == 0) { + return elem.toString(); + } + if (elem.children().length() == 1 && XML(elem.children()[0]).nodeKind() == "text" && elem.attributes().length() == 0) { + log.debug("has one text child only, retrieving it's contents"); + return elem.text().toString(); + } + var result:Object = new Object(); + for each (var attr:XML in elem.attributes()) { + result[attr.localName().toString()] = attr.toString(); + } + + for each (var child:XML in elem.children()) { + result[child.localName() ? child.localName().toString() : "text"] = parseCustomProperty(child); + } + return result; + } + + private function parseMediaGroup(group:XMLList, clip:Clip):Boolean { + + var clipAdded:Boolean = false; + + //obtain the first default item + var defaultItem:XMLList = group.ym::content.(hasOwnProperty('@isDefault') && @isDefault == 'true'); + + if (defaultItem[0]) { + log.debug("parseMedia(): found default media item"); + if (parseMediaItem(defaultItem[0], clip)) { + log.debug("parseMedia(): using the default media item"); + clipAdded = true; + } + } else { + //there are no default items obtain the first content that is streamable + for each (var itm:XML in group.ym::content) { + if (parseMediaItem(itm, clip)) { + trace("adding item"); + clipAdded = true; + break; + } + } + } + + //add bitrate items + for each (var item:XML in group.ym::content) { + addBitrateItems(item, clip); + } + + if (clipAdded) return true; + + log.info("could not find valid media type"); + throw new Error("Could not find a supported media type", UNSUPPORTED_TYPE); + return false; + } + + private function parseMediaItem(elem:XML, clip:Clip):Boolean { + + clip.url = elem.@url.toString(); + if(int(elem.@duration.toString()) > 0) { + clip.duration = int(elem.@duration.toString()); + } + + if(elem.@type) { + try { + setClipType(clip, elem.@type.toString()); + log.info("found valid type " + elem.@type.toString()); + return true; + } catch (e:Error) { + if (e.errorID == UNSUPPORTED_TYPE) { + log.info("skipping unsupported media type " + elem.@type.toString()); + } else { + throw e; + } + } + } + return false; + } + + private function addBitrateItems(elem:XML, clip:Clip):void { + if (elem.@bitrate && elem.@width) + { + // need to explicitely cast attributes for external events, #47 + clip.customProperties["bitrates"].push({url: new String(elem.@url), bitrate: new Number(elem.@bitrate), width: new Number(elem.@width), height: new Number(elem.@height)}); + } + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/AbstractDurationTrackingController.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/AbstractDurationTrackingController.as new file mode 100644 index 0000000000000000000000000000000000000000..9e2597e5d7ff5386c0a79d4434d4bde521f42d60 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/AbstractDurationTrackingController.as @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import org.flowplayer.controller.MediaController; + import org.flowplayer.controller.PlayTimeTracker; + import org.flowplayer.flow_internal; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipEvent; + import org.flowplayer.model.ClipEventType; + import org.flowplayer.model.Playlist; + import org.flowplayer.model.State; + import org.flowplayer.model.Status; + import org.flowplayer.util.Log; + + import flash.events.TimerEvent; + + use namespace flow_internal; + /** + * @author anssi + */ + internal class AbstractDurationTrackingController implements MediaController { + + protected var log:Log = new Log(this); + protected var durationTracker:PlayTimeTracker; + private var _volumeController:VolumeController; + private var _playlist:Playlist; + + public function AbstractDurationTrackingController(volumeController:VolumeController, playlist:Playlist) { + _volumeController = volumeController; + _playlist = playlist; + } + + public final function onEvent(event:ClipEventType, params:Array = null):void { + if (event == ClipEventType.BEGIN) { + load(new ClipEvent(event), clip, params ? params[0] : false); + } else if (event == ClipEventType.PAUSE) { + pause(new ClipEvent(event)); + } else if (event == ClipEventType.RESUME) { + resume(new ClipEvent(event)); + } else if (event == ClipEventType.STOP) { + stop(new ClipEvent(event), params[0], params[1]); + } else if (event == ClipEventType.SEEK) { + seekTo(new ClipEvent(event), params[0]); + } else if (event == ClipEventType.SWITCH) { + doSwitchStream(new ClipEvent(event), clip, params[0]); + } + } + + public final function stopBuffering():void { + doStopBuffering(); + } + + protected final function dispatchPlayEvent(event:ClipEvent):void { + if (! event) return; + log.debug("dispatching " + event + " on clip " + clip); + clip.dispatchEvent(event); + } + + public final function getStatus(state:State):Status { +// if (! clip) return new Status(state, clip, 0, 0, 0, 0, _volumeController.muted, _volumeController.volume, false); + return new Status(state, clip, time, bufferStart, bufferEnd, fileSize, _volumeController.muted, _volumeController.volume, allowRandomSeek); + } + + private function createDurationTracker(clip:Clip):void { + if (durationTracker) { + durationTracker.stop(); + } + durationTracker = new PlayTimeTracker(clip, this); + durationTracker.addEventListener(TimerEvent.TIMER_COMPLETE, durationReached); + durationTracker.start(); + } + + public function get time():Number { + if (!durationTracker) return 0; + var time:Number = durationTracker.time; + return Math.min(time, clip.duration); + } + + protected function get bufferStart():Number { + return 0; + } + + protected function get bufferEnd():Number { + return 0; + } + + protected function get fileSize():Number { + return 0; + } + + protected function get allowRandomSeek():Boolean { + return false; + } + + private final function durationReached(event:TimerEvent):void { + log.info("durationReached()"); + if (durationTracker) { + durationTracker.removeEventListener(TimerEvent.TIMER_COMPLETE, durationReached); + } + onDurationReached(); + if (clip.duration > 0) { + log.debug("dispatching FINISH from durationTracking, clip is " + clip); + clip.dispatchBeforeEvent(new ClipEvent(ClipEventType.FINISH)); + } + } + + protected function onDurationReached():void { + } + + private function load(event:ClipEvent, clip:Clip, pauseAfterStart:Boolean = false):void { + clip.onPause(onPause); + clip.onBufferFull(onBufferFull); + log.debug("calling doLoad"); + doLoad(event, clip, pauseAfterStart); + } + + private function onBufferFull(event:ClipEvent):void { + log.debug("buffer is full, creating and starting duration tracker"); + createDurationTracker(clip); + } + + private function onPause(event:ClipEvent):void { + if (! durationTracker) return; + durationTracker.stop(); + } + + private function pause(event:ClipEvent):void { + if (! durationTracker) return; + durationTracker.stop(); + doPause(event); + } + + private function resume(event:ClipEvent):void { + if (durationTracker) { + if (durationTracker.durationReached) { + log.debug("resume(): duration has been reached"); + return; + } + durationTracker.start(); + } + doResume(event); + } + + private function stop(event:ClipEvent, closeStream:Boolean, silent:Boolean = false):void { + log.debug("stop " + durationTracker); + if (durationTracker) { + durationTracker.stop(); + durationTracker.time = 0; + } + doStop(silent ? null : event, closeStream); + } + + private function seekTo(event:ClipEvent, seconds:Number):void { + if (! durationTracker) createDurationTracker(clip); + doSeekTo(event, seconds); + durationTracker.time = seconds; + } + + protected function get clip():Clip { + return _playlist.current; + } + + protected function get playlist():Playlist { + return _playlist; + } + + // FOLLOWING METHODS SHOULD BE OVERRIDDEN IN SUBCLASSES: + // The mimimum ilmemetation dispatches the event passed in the first parameter. + + protected function doLoad(event:ClipEvent, clip:Clip, pauseAfterStart:Boolean = false):void { + } + + protected function doPause(event:ClipEvent):void { + } + + protected function doResume(event:ClipEvent):void { + } + + protected function doStop(event:ClipEvent, closeStream:Boolean):void { + } + + protected function doSeekTo(event:ClipEvent, seconds:Number):void { + } + + protected function doStopBuffering():void { + } + + protected function doSwitchStream(param:ClipEvent, clip:Clip, netStreamPlayOptions:Object = null):void { + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/BufferingState.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/BufferingState.as new file mode 100644 index 0000000000000000000000000000000000000000..83f4c605cd2ad08ef9ef55dc14d4089471f16ff6 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/BufferingState.as @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import flash.utils.Dictionary; + + import org.flowplayer.controller.PlayListController; + import org.flowplayer.flow_internal; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipEvent; + import org.flowplayer.model.ClipEventSupport; + import org.flowplayer.model.ClipEventType; + import org.flowplayer.model.Playlist; + import org.flowplayer.model.State; + import org.flowplayer.model.Status; + + use namespace flow_internal; + + /** + * @author api + */ + internal class BufferingState extends PlayState { + + private var _nextStateAfterBufferFull:PlayState; + + public function BufferingState(stateCode:State, playList:Playlist, playListController:PlayListController, providers:Dictionary) { + super(stateCode, playList, playListController, providers); + } + + internal override function play():void { + log.debug("play()"); + stop(); + bufferingState.nextStateAfterBufferFull = playingState; + if (canOnEvent(ClipEventType.BEGIN, [false])) { + playList.current.played = true; + changeState(bufferingState); + onEvent(ClipEventType.BEGIN, [false]); + } + } + + internal override function stopBuffering():void { + log.debug("stopBuffering() called"); + stop(); + getMediaController().stopBuffering(); + } + + internal override function pause():void { + if (canOnEvent(ClipEventType.PAUSE)) { + changeState(pausedState); + onEvent(ClipEventType.PAUSE); + } + } + + internal override function seekTo(seconds:Number):void { + if (canOnEvent(ClipEventType.SEEK, [seconds])) + onEvent(ClipEventType.SEEK, [seconds]); + } + + override protected function setEventListeners(eventSupport:ClipEventSupport, add:Boolean = true):void { + if (add) { + eventSupport.onBufferFull(moveState); + eventSupport.onPause(moveState); + eventSupport.onError(onError); + } else { + eventSupport.unbind(moveState); + eventSupport.unbind(onError); + } + } + + private function onError(event:ClipEvent):void { + getMediaController().onEvent(ClipEventType.STOP); + } + + private function moveState(event:ClipEvent):void { + log.debug("moving to state " + _nextStateAfterBufferFull); + playListController.setPlayState(_nextStateAfterBufferFull); + } + + public function set nextStateAfterBufferFull(nextState:PlayState):void { + this._nextStateAfterBufferFull = nextState; + } + + internal override function get status():Status { + return getMediaController().getStatus(state); + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ClipImageLoader.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ClipImageLoader.as new file mode 100644 index 0000000000000000000000000000000000000000..1791f7aae43dda0135a5c445d83200b84ba2483c --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ClipImageLoader.as @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import org.flowplayer.model.Clip; + /** + * @author api + */ + internal class ClipImageLoader implements ResourceLoader { + + private var _clip:Clip; + private var _loader:ResourceLoader; + + public function ClipImageLoader(loader:ResourceLoader, clip:Clip) { + _loader = loader; + _clip = clip; + } + + public function addTextResourceUrl(url:String):void { + _loader.addTextResourceUrl(url); + } + + public function addBinaryResourceUrl(url:String):void { + _loader.addBinaryResourceUrl(url); + } + + public function load(url:String = null, completeListener:Function = null, ignored:Boolean = false):void { + _loader.load(url, completeListener, false); + } + + public function set completeListener(listener:Function):void { + _loader.completeListener = listener; + } + + public function loadClip(clip:Clip, onLoadComplete:Function):void { + _clip = clip; + var imageLoader:ClipImageLoader = this; + load(clip.completeUrl, function(loader:ResourceLoader):void { onLoadComplete(imageLoader); }); + } + + public function getContent(url:String = null):Object { + return _loader.getContent(_clip.completeUrl); + } + + public function clear():void { + _loader.clear(); + } + + public function get loadComplete():Boolean { + return _loader.loadComplete; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ClipURLResolver.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ClipURLResolver.as new file mode 100644 index 0000000000000000000000000000000000000000..4733307fe68449f8ba88da009d4c5196a517bdef --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ClipURLResolver.as @@ -0,0 +1,53 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import flash.events.NetStatusEvent; +import flash.net.NetConnection; + + import org.flowplayer.model.Clip; + + /** + * @author api + */ + public interface ClipURLResolver { + + /** + * Sets a listener that gets called if the resolve process fails. + */ + function set onFailure(listener:Function):void; + + /** + * Resolve the URL for the specified clip. + * @param provider + * @param clip the clip to resolve + * @param successListener a listener function that gets notified when the URL has been resolved + * @see #onSuccess + */ + function resolve(provider:StreamProvider, clip:Clip, successListener:Function):void; + + /** + * Called when a netStatusEvent is received. + * @param event + * @return if false, the streamProvider will ignore this event and will not send any events for it + */ + function handeNetStatusEvent(event:NetStatusEvent):Boolean; + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ClipURLResolverHelper.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ClipURLResolverHelper.as new file mode 100644 index 0000000000000000000000000000000000000000..7ec0e1de028953b4d3e2bee4b4bc83a6473bbdad --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ClipURLResolverHelper.as @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipError; + + import org.flowplayer.util.Log; + import org.flowplayer.view.Flowplayer; + + /** + * An helper class that does the whole resolving job + */ + public class ClipURLResolverHelper { + + private var _defaultClipUrlResolver:ClipURLResolver; + private var _clipUrlResolver:ClipURLResolver; + private var _streamProvider:StreamProvider; + private var _player:Flowplayer; + + protected var log:Log = new Log(this); + + public function ClipURLResolverHelper(player:Flowplayer, streamProvider:StreamProvider, defaultURLResolver:ClipURLResolver = null) { + _player = player; + _streamProvider = streamProvider; + _defaultClipUrlResolver = _defaultClipUrlResolver ? _defaultClipUrlResolver : getDefaultClipURLResolver(); + } + + /** + * Resolves the url for the specified clip. + */ + public function resolveClipUrl(clip:Clip, successListener:Function):void { + getClipURLResolver(clip).resolve(_streamProvider, clip, successListener); + } + + /** + * Gets the default clip url resolver to be used if the ProviderModel + * supplied to this provider does not specify a connection provider. + */ + protected function getDefaultClipURLResolver():ClipURLResolver { + return new DefaultClipURLResolver(); + } + + public function getClipURLResolver(clip:Clip):ClipURLResolver { + log.debug("get clipURLResolver, clip.urlResolver = " + clip.urlResolvers + ", _clipUrlResolver = " + _defaultClipUrlResolver); + if (! clip || (clip.urlResolvers && clip.urlResolvers[0] == null)) { + clip.urlResolverObjects = [_defaultClipUrlResolver]; + return _defaultClipUrlResolver; + } + + // defined in clip? + if (clip.urlResolvers) { + _clipUrlResolver = CompositeClipUrlResolver.createResolver(clip.urlResolvers, _player.pluginRegistry); + } else { + // get all resolvers from repository + var configured:Array = _player.pluginRegistry.getUrlResolvers(); + if (configured && configured.length > 0) { + log.debug("using configured URL resolvers", configured); + _clipUrlResolver = CompositeClipUrlResolver.createResolver(configured, _player.pluginRegistry); + } + } + + if (! _clipUrlResolver) { + _clipUrlResolver = _defaultClipUrlResolver; + } + + _clipUrlResolver.onFailure = function(message:String = null):void { + log.error("clip URL resolving failed: " + message); + clip.dispatchError(ClipError.STREAM_LOAD_FAILED, "failed to resolve clip url" + (message ? ": " + message : "")); + }; + + clip.urlResolverObjects = _clipUrlResolver is CompositeClipUrlResolver ? CompositeClipUrlResolver(_clipUrlResolver).resolvers : [_clipUrlResolver]; + return _clipUrlResolver; + } + + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/CompositeClipUrlResolver.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/CompositeClipUrlResolver.as new file mode 100644 index 0000000000000000000000000000000000000000..6b41d632aca0b58fb4298707d52bc4b2d2b342df --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/CompositeClipUrlResolver.as @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ +package org.flowplayer.controller { + import flash.events.NetStatusEvent; +import org.flowplayer.model.Clip; + import org.flowplayer.model.PluginModel; + import org.flowplayer.util.Log; +import org.flowplayer.view.PluginRegistry; + + public class CompositeClipUrlResolver implements ClipURLResolver { + private static var log:Log = new Log("org.flowplayer.controller::CompositeClipUrlResolver"); + private var _resolvers:Array; + private var _current:int = 0; + private var _successListener:Function; + private var _clip:Clip; + private var _provider:StreamProvider; + + public function CompositeClipUrlResolver(resolvers:Array) { + _resolvers = resolvers; + } + + public static function createResolver(names:Array, pluginRegistry:PluginRegistry):ClipURLResolver { + if (! names || names.length == 0) { + throw new Error("resolver name not supplied"); + } +// if (names.length == 1) return getResolver(names[0], pluginRegistry); + + log.debug("creating composite resolver with " + names.length + " resolvers"); + var resolvers:Array = new Array(); + for (var i:int = 0; i < names.length; i++) { + log.debug("initializing resolver " + names[i]); + resolvers.push(getResolver(names[i], pluginRegistry)); + } + return new CompositeClipUrlResolver(resolvers); + } + + private static function getResolver(name:String, pluginRegistry:PluginRegistry):ClipURLResolver { + var resolver:ClipURLResolver = PluginModel(pluginRegistry.getPlugin(name)).pluginObject as ClipURLResolver; + if (! resolver) { + throw new Error("clipURLResolver '" + name + "' not loaded"); + } + return resolver; + } + + public function resolve(provider:StreamProvider, clip:Clip, successListener:Function):void { + if (clip.getResolvedUrl()) { + log.debug("clip URL has been already resolved to '" + clip.url + "', calling successListener"); + successListener(clip) + return; + } + log.debug("resolve(): resolving with " + _resolvers.length + " resolvers"); + _provider = provider; + _clip = clip; + _successListener = successListener; + _current = 0; + resolveNext(); + } + + private function resolveNext():void { + if (_current == _resolvers.length) { + log.debug("all resolvers done, calling the successListener"); + _successListener(_clip); + return; + } + var resolver:ClipURLResolver = _resolvers[_current++]; + log.debug("resolving with " + resolver); + resolver.resolve(_provider, _clip, function(clip:Clip):void { + log.debug("resolver "+ resolver +" done, url is now " + clip.url); + resolveNext(); + }); + } + + public function set onFailure(listener:Function):void { + for (var i:int = 0; i < _resolvers.length; i++) { + ClipURLResolver(_resolvers[i]).onFailure = listener; + } + } + + public function handeNetStatusEvent(event:NetStatusEvent):Boolean { + return true; + } + + public function get resolvers():Array { + return _resolvers; + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ConnectionCallbacks.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ConnectionCallbacks.as new file mode 100644 index 0000000000000000000000000000000000000000..20570beaad2f77a9bf2e17b4e94fc3c17e26ab7f --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ConnectionCallbacks.as @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + /** + * @author api + */ + public interface ConnectionCallbacks { +// +// function onBWCheck(... rest):void; +// +// function onBWDone(... rest):void; + + function onFCSubscribe(infoObject:Object):void; + + function registerCallback(name:String):void; + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ConnectionProvider.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ConnectionProvider.as new file mode 100644 index 0000000000000000000000000000000000000000..7ed7dc4338a0de29079ff009d62b9110bfa5ba22 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ConnectionProvider.as @@ -0,0 +1,56 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import flash.events.NetStatusEvent; + import org.flowplayer.model.Clip; + + /** + * @author api + */ + public interface ConnectionProvider { + + function set connectionClient(client:Object):void; + + /** + * Sets a listener that gets called if the connection fails. + * The function must have a parameter of type NetStatusEvent. + */ + function set onFailure(listener:Function):void; + + /** + * Connects to the specified URL. + * @param provider + * @param clip + * @param successListener + * @param objectEncoding to be used in NetConnection.objectEncoding + * @param rest + * @return + */ + function connect(provider:StreamProvider, clip:Clip, successListener:Function, objectEncoding: uint, connectionArgs:Array):void; + + /** + * Called when a netStatusEvent is received. + * @param event + * @return if false, the streamProvider will ignore this event and will not send any events for it + */ + function handeNetStatusEvent(event:NetStatusEvent):Boolean; + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/DefaultClipURLResolver.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/DefaultClipURLResolver.as new file mode 100644 index 0000000000000000000000000000000000000000..9f59df1cd85bd53845c9918279b48a9268edec78 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/DefaultClipURLResolver.as @@ -0,0 +1,51 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import flash.events.NetStatusEvent; +import flash.net.NetConnection; + + import org.flowplayer.controller.ClipURLResolver; + import org.flowplayer.model.Clip; + + /** + * @author api + */ + public class DefaultClipURLResolver implements ClipURLResolver { + + private var _clip:Clip; + private var _failureListener:Function; + + public function resolve(provider:StreamProvider, clip:Clip, successListener:Function):void { + _clip = clip; + if (successListener != null) { + successListener(clip); + } + } + + + public function set onFailure(listener:Function):void { + _failureListener = listener; + } + + public function handeNetStatusEvent(event:NetStatusEvent):Boolean { + return true; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/DefaultRTMPConnectionProvider.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/DefaultRTMPConnectionProvider.as new file mode 100644 index 0000000000000000000000000000000000000000..d134a3fa69b4e035c3c345221d29638acaab47b4 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/DefaultRTMPConnectionProvider.as @@ -0,0 +1,136 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import flash.events.NetStatusEvent; + import flash.utils.setTimeout; + + import org.flowplayer.controller.ConnectionProvider; + import org.flowplayer.model.Clip; + import org.flowplayer.util.Log; + + import flash.events.NetStatusEvent; + import flash.net.NetConnection; + + /** + * @author api + */ + public class DefaultRTMPConnectionProvider implements ConnectionProvider { + protected var log:Log = new Log(this); + private var _connection:NetConnection; + private var _successListener:Function; + private var _failureListener:Function; + private var _connectionClient:Object; + private var _provider:NetStreamControllingStreamProvider; + private var _connectionArgs:Array; + private var _clip:Clip; + + private function doConnect(connectionArgs:Array, connectionUrl:String):void { + if (connectionArgs.length > 0) { + _connection.connect.apply(_connection, [connectionUrl].concat(connectionArgs)); + } else { + _connection.connect(connectionUrl); + } + } + + public function connect(provider:StreamProvider, clip:Clip, successListener:Function, objectEndocing:uint, connectionArgs:Array):void { + _provider = provider as NetStreamControllingStreamProvider; + _successListener = successListener; + _connection = new NetConnection(); + _connection.proxyType = "best"; + _connection.objectEncoding = objectEndocing; + _connectionArgs = connectionArgs; + _clip = clip; + + if (_connectionClient) { + _connection.client = _connectionClient; + } + _connection.addEventListener(NetStatusEvent.NET_STATUS, _onConnectionStatus); + + var connectionUrl:String = getNetConnectionUrl(clip); + log.debug("netConnectionUrl is " + connectionUrl); + doConnect(connectionArgs, connectionUrl); + } + + protected function getNetConnectionUrl(clip:Clip):String { + return null; + } + + private function _onConnectionStatus(event:NetStatusEvent):void { + onConnectionStatus(event); + if (event.info.code == "NetConnection.Connect.Success" && _successListener != null) { + _successListener(_connection); + + } else if (event.info.code == "NetConnection.Connect.Rejected") { + if(event.info.ex.code == 302) { + var redirectUrl:String = event.info.ex.redirect; + log.debug("doing a redirect to " + redirectUrl); + _clip.setCustomProperty("netConnectionUrl", redirectUrl); + setTimeout(connect, 100, _provider, _clip, _successListener, _connection.objectEncoding, _connectionArgs); + } + + } else if (["NetConnection.Connect.Failed", "NetConnection.Connect.AppShutdown", "NetConnection.Connect.InvalidApp"].indexOf(event.info.code) >= 0) { + + if (_failureListener != null) { + _failureListener(); + } + } + } + + /** + * Called when NetStatusEvent.NET_STATUS is received for the NetConnection. This + * gets called before the successListener() gets called. + * @param event + * @return + */ + protected function onConnectionStatus(event:NetStatusEvent):void { + } + + public function set connectionClient(client:Object):void { + if (_connection) { + _connection.client = client; + } + _connectionClient = client; + } + + public function set onFailure(listener:Function):void { + _failureListener = listener; + } + + protected function get connection():NetConnection { + return _connection; + } + + public function handeNetStatusEvent(event:NetStatusEvent):Boolean { + return true; + } + + protected function get provider():NetStreamControllingStreamProvider { + return _provider; + } + + protected function get failureListener():Function { + return _failureListener; + } + + protected function get successListener():Function { + return _successListener; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/EndedState.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/EndedState.as new file mode 100644 index 0000000000000000000000000000000000000000..408b407be0998e8b18a49e10ae3800d8b934cea4 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/EndedState.as @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import flash.utils.Dictionary; + + import org.flowplayer.controller.PlayListController; + import org.flowplayer.controller.PlayState; + import org.flowplayer.model.Playlist; + import org.flowplayer.model.State; + + /** + * @author api + */ + internal class EndedState extends PlayState { + public function EndedState(stateCode:State, playList:Playlist, playListController:PlayListController, providers:Dictionary) { + super(stateCode, playList, playListController, providers); + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ImageController.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ImageController.as new file mode 100644 index 0000000000000000000000000000000000000000..f75973b144aff207bb9258909adc9f5ec6877a76 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ImageController.as @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import org.flowplayer.model.Playlist; + import flash.display.Loader; + import flash.display.DisplayObject; + import flash.events.Event; + import flash.events.EventDispatcher; + + import org.flowplayer.controller.AbstractDurationTrackingController; + import org.flowplayer.controller.MediaController; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipEvent; + import org.flowplayer.model.ClipEventType; + import org.flowplayer.util.Log; + + import org.flowplayer.view.ImageHolder; + + /** + * @author api + */ + internal class ImageController extends AbstractDurationTrackingController implements MediaController { + + private var _loader:ClipImageLoader; +// private var _durationlessClipPaused:Boolean; + + public function ImageController(loader:ResourceLoader, volumeController:VolumeController, playlist:Playlist) { + super(volumeController, playlist); + _loader = new ClipImageLoader(loader, null); + } + + override protected function get allowRandomSeek():Boolean { + return true; + } + + override protected function doLoad(event:ClipEvent, clip:Clip, pauseAfterStart:Boolean = false):void { +// _durationlessClipPaused = false; + + // reset the duration tracker, #45 + if (durationTracker) { + durationTracker.stop(); + durationTracker.time = 0; + } + + log.info("Starting to load " + clip); + _loader.loadClip(clip, onLoadComplete); + dispatchPlayEvent(event); + } + + override protected function doPause(event:ClipEvent):void { + dispatchPlayEvent(event); + } + + override protected function doResume(event:ClipEvent):void { + dispatchPlayEvent(event); + } + + override protected function doStop(event:ClipEvent, closeStream:Boolean):void { + dispatchPlayEvent(event); + } + + override protected function doSeekTo(event:ClipEvent, seconds:Number):void { + if (event) { + dispatchPlayEvent(new ClipEvent(ClipEventType.SEEK, seconds)); + } + } + + private function onLoadComplete(loader:ClipImageLoader):void { + if ( loader.getContent() is Loader && ImageHolder.hasOffscreenContent(loader.getContent() as Loader )) + { + var holder:ImageHolder = new ImageHolder(loader.getContent() as Loader); + clip.originalHeight = holder.originalHeight; + clip.originalWidth = holder.originalWidth; + clip.setContent(holder); + } + else // no need to wrap it + { + clip.setContent(loader.getContent() as DisplayObject); + clip.originalHeight = loader.getContent().height; + clip.originalWidth = loader.getContent().width; + } + log.info("image loaded " + clip + ", content " + loader.getContent() + ", width " + clip.originalWidth + ", height " + clip.originalHeight + ", duration "+ clip.duration); + clip.dispatch(ClipEventType.START); + clip.dispatch(ClipEventType.METADATA); + clip.dispatch(ClipEventType.BUFFER_FULL); + + if (clip.duration == 0) { + + clip.onResume(function(event:ClipEvent):void { + clip.dispatchBeforeEvent(new ClipEvent(ClipEventType.FINISH)); + }); + + clip.dispatchEvent(new ClipEvent(ClipEventType.RESUME)); + } + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/InStreamTracker.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/InStreamTracker.as new file mode 100644 index 0000000000000000000000000000000000000000..7cabf2ee291803ec4f7a5ab0f41005e835e05acf --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/InStreamTracker.as @@ -0,0 +1,92 @@ +/* + * Copyright 2009 Flowplayer Oy + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import flash.events.TimerEvent; + import flash.utils.Timer; + + import org.flowplayer.model.Clip; + import org.flowplayer.util.Log; + import org.flowplayer.flow_internal; + + use namespace flow_internal; + + public class InStreamTracker { + private var _controller:PlayListController; + private var _timer:Timer; + private var log:Log = new Log(this); + private var _prevStartTime:Number = 0; + + public function InStreamTracker(controller:PlayListController) { + _controller = controller; + } + + public function start(doReset:Boolean = false):void { + log.debug("start()"); + if (! clip.hasChildren) { + throw new Error("this clip does not have child clips"); + } + + if (doReset) { + reset(); + } + + var children:Array = clip.playlist; + for (var i:int = 0; i < children.length; i++) { + var clip:Clip = children[i] as Clip; + log.debug("start(): child clip at " + clip.position + ": " + clip); + } + + if (! _timer) { + _timer = new Timer(200); + _timer.addEventListener(TimerEvent.TIMER, onTimer); + } + _timer.start(); + } + + public function stop():void { + log.debug("stop()"); + if (_timer && _timer.running) { + _timer.stop(); + } + } + + private function onTimer(event:TimerEvent):void { + var time:Number = _controller.status.time; + log.debug("time " + Math.round(time)); + var child:Clip = clip.getMidroll(time); + if (child && time - _prevStartTime > 2) { + stop(); + log.info("found child clip with start time " + time + ": " + child); + _controller.playInstream(child); + _prevStartTime = child.position; + } + } + + private function get clip():Clip { + return _controller.playlist.current; + } + + public function reset():void { + log.debug("reset()"); + _prevStartTime = 0; + } + } + +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/LocalSOVolumeStorage.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/LocalSOVolumeStorage.as new file mode 100644 index 0000000000000000000000000000000000000000..0b65235e2ade6644887abdf31aaa8d96f4a21c2f --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/LocalSOVolumeStorage.as @@ -0,0 +1,83 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import org.flowplayer.util.Log; + import org.flowplayer.controller.VolumeStorage; + + import flash.net.SharedObject; + + /** + * @author api + */ + internal class LocalSOVolumeStorage implements VolumeStorage { + private var _storedVolume:SharedObject; + private var log:Log = new Log(this); + + public function LocalSOVolumeStorage(storedVolume:SharedObject) { + log.debug("in constructor"); + _storedVolume = storedVolume; + } + + public static function create():VolumeStorage { + try { + return new LocalSOVolumeStorage(SharedObject.getLocal("org.flowplayer")); + } catch (e:Error) { + return new NullVolumeStorage(); + } + return null; + } + + public function persist():void { + log.debug("persisting volume " + _storedVolume.data.volume); + try { + _storedVolume.flush(); + } catch (e:Error) { + log.error("unable to persist volume"); + } + } + + public function get volume():Number { + log.debug("get volume " + _storedVolume.data.volume); + if (_storedVolume.size == 0) return 0.5; + return getVolume(_storedVolume.data.volume); + } + + public function get muted():Boolean { + return _storedVolume.data.volumeMuted; + } + + public function set volume(value:Number):void { + _storedVolume.data.volume = value; + } + + public function set muted(value:Boolean):void { + _storedVolume.data.volumeMuted = value; + } + + private function getVolume(volumeObj:Object):Number { + if (volumeObj == 0) return 0; + if (!volumeObj is Number) return 0.5; + if (isNaN(volumeObj as Number)) return 0.5; + if (volumeObj as Number > 1) return 1; + if (volumeObj as Number < 0) return 0; + return volumeObj as Number; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/MediaController.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/MediaController.as new file mode 100644 index 0000000000000000000000000000000000000000..226e4f0ae414e72644964665554d48759b39a3f7 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/MediaController.as @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import org.flowplayer.model.ClipEventType; + import org.flowplayer.model.State; + import org.flowplayer.model.Status; + + /** + * @author anssi + */ + public interface MediaController { + + /** + * Handles the specified event. This function also dispatches + * the specified event when the given event has been successfully + * initiated. For example, the PlayEventType.START event is dispatched + * when the media playback has been initiated without errors. + * + * @param event the type of the event to be handled, the event's before phase + * has been already processed, and the event cannot be canceled at this point any more + * @param params parameters related to this event + */ + function onEvent(event:ClipEventType, params:Array = null):void; + + /** + * Gets the status of this controller. + */ + function getStatus(state:State):Status; + + /** + * Stops loading the media. + */ + function stopBuffering():void; + + /** + * Gets the current playhead time. + */ + function get time():Number; + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/MediaControllerFactory.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/MediaControllerFactory.as new file mode 100644 index 0000000000000000000000000000000000000000..6ae0bad3452c2b72945c9134c46c1dfbbea4f9a1 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/MediaControllerFactory.as @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import org.flowplayer.model.ClipError; + import org.flowplayer.config.Config; + import org.flowplayer.model.ClipEventType; + import org.flowplayer.view.PlayerEventDispatcher; + import org.flowplayer.util.Log; + + import flash.utils.Dictionary; + + import org.flowplayer.flow_internal; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipType; + import org.flowplayer.model.Playlist; + import org.flowplayer.model.ProviderModel; + + /** + * @author anssi + */ + internal class MediaControllerFactory { + + private var log:Log = new Log(this); + private var _streamProviderController:MediaController; + private var _inStreamController:MediaController; + + private var _imageController:ImageController; + private var _inStreamImageController:ImageController; + + private static var _instance:MediaControllerFactory; + private var _volumeController:VolumeController; + private var _providers:Dictionary; + private var _playerEventDispatcher:PlayerEventDispatcher; + private var _config:Config; + private var _loader:ResourceLoader; + + use namespace flow_internal; + + public function MediaControllerFactory(providers:Dictionary, playerEventDispatcher:PlayerEventDispatcher, config:Config, loader:ResourceLoader) { + _providers = providers; + _instance = this; + _playerEventDispatcher = playerEventDispatcher; + _volumeController = new VolumeController(_playerEventDispatcher); + _config = config; + _loader = loader; + } + + flow_internal function getMediaController(clip:Clip, playlist:Playlist):MediaController { + var clipType:ClipType = clip.type; + //allow for chromeless swf video players to be treated as video + if (clipType == ClipType.VIDEO || clipType == ClipType.AUDIO || clipType == ClipType.API) { + return getStreamProviderController(playlist, clip.isInStream); + } + if (clipType == ClipType.IMAGE) { + return getImageController(playlist, clip.isInStream); + } + throw new Error("No media controller found for clip type " + clipType); + return null; + } + + flow_internal function getVolumeController():VolumeController { + return _volumeController; + } + + private function getStreamProviderController(playlist:Playlist, inStream:Boolean = false):MediaController { + if (inStream) { + if (! _inStreamController) { + _inStreamController = new StreamProviderController(this, getVolumeController(), _config, playlist); + } + return _inStreamController; + } + + if (!_streamProviderController) { + _streamProviderController = new StreamProviderController(this, getVolumeController(), _config, playlist); + } + return _streamProviderController; + } + + private function getImageController(playlist:Playlist, inStream:Boolean = false):MediaController { + if (inStream) { + if (! _inStreamImageController) { + _inStreamImageController = new ImageController(_loader, getVolumeController(), playlist); + } + return _inStreamImageController; + } + + if (!_imageController) + _imageController = new ImageController(_loader, getVolumeController(), playlist); + return _imageController; + } + + internal function addProvider(provider:ProviderModel):void { + _providers[provider.name] = provider.pluginObject; + } + + public function getProvider(clip:Clip):StreamProvider { + var provider:StreamProvider = _providers[clip.provider]; + if (! provider) { + for (var key:String in _providers) { + log.debug("found provider " + key); + } + clip.dispatchError(ClipError.PROVIDER_NOT_LOADED, "Provider '" + clip.provider + "' " + getInstreamProviderErrorMsg(clip)); + return null; + } + provider.volumeController = getVolumeController(); + return provider; + } + + private function getInstreamProviderErrorMsg(clip:Clip):String { + if (! clip.isInStream) return ""; + return "(if this instream clip was started using play() you need to explicitly load/configure provider '" + clip.provider + "' before calling play())"; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NetConnectionClient.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NetConnectionClient.as new file mode 100644 index 0000000000000000000000000000000000000000..f5b5661000f6d8a57b6601cd2127abf7d331d132 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NetConnectionClient.as @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import org.flowplayer.util.Log; + import org.flowplayer.model.ClipEventType; + import org.flowplayer.controller.ConnectionCallbacks; + import org.flowplayer.model.Clip; + + /** + * @author api + */ + public dynamic class NetConnectionClient implements ConnectionCallbacks { + private var log:Log = new Log(this); + private var _clip:Clip; + + +// public function onBWCheck(...rest):void { +// log.debug("received onBWCheck " + _clip); +// _clip.dispatch(ClipEventType.CONNECTION_EVENT, "onBWCheck"); +// } +// +// public function onBWDone(...rest):void { +// log.debug("received onBWDone"); +// _clip.dispatch(ClipEventType.CONNECTION_EVENT, "onBWDone", rest.length > 0 ? rest[0] : null); +// } + + public function onFCSubscribe(infoObject:Object):void { + _clip.dispatch(ClipEventType.CONNECTION_EVENT, "onFCSubscribe", infoObject); + } + + public function get clip():Clip { + return _clip; + } + + public function set clip(val:Clip):void { + _clip = val; + } + + public function addConnectionCallback(name:String, listener:Function):void { + log.debug("registering callback " + name); + this[name] = listener; +// this[name] = function(infoObj:Object = null):void { +// log.debug("received callback " + name); +// _clip.dispatch(ClipEventType.CONNECTION_EVENT, name, infoObj); +// } + } + + public function registerCallback(name:String):void { + _clip.dispatch(ClipEventType.CONNECTION_EVENT, "registerCallback", name); + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NetStreamCallbacks.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NetStreamCallbacks.as new file mode 100644 index 0000000000000000000000000000000000000000..27ca5f19716be9410058ef08088395988a6408bb --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NetStreamCallbacks.as @@ -0,0 +1,41 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + + /** + * An interface for objects to be set to the NetStream.client property. + */ + public interface NetStreamCallbacks { + + function onMetaData(infoObject:Object):void; + + function onXMPData(infoObject:Object):void; + + function onCaption(cps:String,spk:Number):void; + + function onCaptionInfo(obj:Object):void; + + function onImageData(obj:Object):void; + + function RtmpSampleAccess(obj:Object):void; + + function onTextData(obj:Object):void; + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NetStreamClient.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NetStreamClient.as new file mode 100644 index 0000000000000000000000000000000000000000..c90ae53acba32e9e583968ab29a62e0c25ccf811 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NetStreamClient.as @@ -0,0 +1,116 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { +import flash.utils.Dictionary; +import org.flowplayer.util.Log; +import org.flowplayer.config.Config; +import org.flowplayer.controller.NetStreamCallbacks; +import org.flowplayer.model.Clip; +import org.flowplayer.model.ClipEventType; + + /** + * @author api + */ + public dynamic class NetStreamClient implements NetStreamCallbacks { + + private var log:Log = new Log(this); + private var _config:Config; + private var _clip:Clip; + private var _previousUrl:String; + + public function NetStreamClient(clip:Clip, config:Config, streamCallbacks:Dictionary) { + _clip = clip; + _config = config; + for (var key:Object in streamCallbacks) { + addStreamCallback(key as String, streamCallbacks[key]); + } + } + + public function onMetaData(infoObject:Object):void { + log.info("onMetaData, current clip " + _clip); + + log.debug("onMetaData, data for clip " + _clip + ":"); + var metaData:Object = new Object(); + for (var key:String in infoObject) { + if ( key == "duration" && ! isNewFile() && _clip && _clip.metaData && _clip.metaData.duration ) { + log.debug ("Already got duration, reusing old one"); + metaData.duration = _clip.metaData.duration; + continue; + } + + log.debug(key + ": " + infoObject[key]); + metaData[key] = infoObject[key]; + } + _clip.metaData = metaData; + + if (metaData.cuePoints && isNewFile()) { + log.debug("clip has embedded cuepoints"); + _clip.addCuepoints(_config.createCuepoints(metaData.cuePoints, "embedded", _clip.cuepointMultiplier)); + } + + _previousUrl = _clip.url; + _clip.dispatch(ClipEventType.METADATA); + log.info("metaData parsed and injected to the clip"); + } + + private function isNewFile():Boolean { + if (! _previousUrl) return true; + return _clip.url != _previousUrl; + } + + public function onXMPData(infoObject:Object):void { + _clip.dispatchNetStreamEvent("onXMPData", infoObject); + } + + public function onCaption(cps:String, spk:Number):void { + _clip.dispatchNetStreamEvent("onCaption", { 'cps': cps, 'spk': spk }); + } + + public function onCaptionInfo(infoObject:Object):void { + _clip.dispatchNetStreamEvent("onCaptionInfo", infoObject); + } + + public function onImageData(infoObject:Object):void { + _clip.dispatchNetStreamEvent("onImageData", infoObject); + } + + public function RtmpSampleAccess(infoObject:Object):void { + _clip.dispatchNetStreamEvent("RtmpSampleAccess", infoObject); + } + + public function onTextData(infoObject:Object):void { + _clip.dispatchNetStreamEvent("onTextData", infoObject); + } + + private function addStreamCallback(name:String, listener:Function):void { + log.debug("registering callback " + name); + this[name] = listener; + } + + public function registerCallback(name:String):void { + _clip.dispatchNetStreamEvent("registerCallback", name); + } + +// +// public function onCuePoint(infoObject:Object):void { +// _clip.dispatchNetStreamEvent("onCuePoint", infoObject); +// } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NetStreamControllingStreamProvider.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NetStreamControllingStreamProvider.as new file mode 100644 index 0000000000000000000000000000000000000000..fe95a54aea32a1f0bc72733e8dafd4e32fb7fa11 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NetStreamControllingStreamProvider.as @@ -0,0 +1,856 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import flash.utils.Dictionary; + + import org.flowplayer.controller.StreamProvider; + import org.flowplayer.controller.TimeProvider; + import org.flowplayer.controller.VolumeController; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipError; + import org.flowplayer.model.ClipEvent; + import org.flowplayer.model.ClipEventType; + import org.flowplayer.model.EventType; + import org.flowplayer.model.Playlist; + import org.flowplayer.model.PluginEventType; + import org.flowplayer.model.PluginModel; + import org.flowplayer.model.ProviderModel; + import org.flowplayer.util.Assert; + import org.flowplayer.util.Log; + import org.flowplayer.view.Flowplayer; + + import flash.display.DisplayObject; + import flash.errors.IOError; + import flash.events.NetStatusEvent; + import flash.events.TimerEvent; + import flash.media.Video; + import flash.net.NetConnection; + import flash.net.NetStream; + import flash.utils.Timer; + + /** + * A StreamProvider that does it's job using the Flash's NetStream class. + * Implements standard HTTP based progressive download. + */ + public class NetStreamControllingStreamProvider implements StreamProvider { + + private var _ParrallelRTMPConnectionProviderDummyRef:ParallelRTMPConnectionProvider; + + protected var log:Log = new Log(this); + private var _connection:NetConnection; + private var _connectionArgs:Array; + private var _netStream:NetStream; + private var _startedClip:Clip; + private var _playlist:Playlist; + private var _pauseAfterStart:Boolean; + private var _volumeController:VolumeController; + private var _seekTargetWaitTimer:Timer; + private var _seekTarget:Number; + private var _model:ProviderModel; + private var _connectionProvider:ConnectionProvider; + private var _clipUrlResolverHelper:ClipURLResolverHelper; + private var _player:Flowplayer; + + // state variables + private var _silentSeek:Boolean; + private var _paused:Boolean; + private var _stopping:Boolean; + private var _started:Boolean; + private var _connectionClient:NetConnectionClient; + private var _streamCallbacks:Dictionary = new Dictionary(); + private var _timeProvider:TimeProvider; + private var _seeking:Boolean; + + public function NetStreamControllingStreamProvider() { + _connectionClient = new NetConnectionClient(); + } + + /** + * Sets the provider model. + */ + public function set model(model:ProviderModel):void { + _model = model; + onConfig(model); + } + + /** + * Gets the provider model. + * @return + */ + public function get model():ProviderModel { + return _model; + } + + /** + * Sets the player instance. + */ + public function set player(player:Flowplayer):void { + _player = player; + createConnectionProvider(); + createClipUrlResolver(); + onLoad(player); + } + + /* ---- implementation of StreamProvider: ---- */ + + /** + * @inheritDoc + */ + public final function load(event:ClipEvent, clip:Clip, pauseAfterStart:Boolean = false):void { + _paused = false; + _stopping = false; + Assert.notNull(clip, "load(clip): clip cannot be null"); + if (pauseAfterStart) { + log.info("this clip will pause after start"); + } + _pauseAfterStart = pauseAfterStart; + clip.onMetaData(onMetaData, function(clip:Clip):Boolean { + return clip.provider == (_model ? _model.name : (clip.parent ? 'httpInstream' : 'http')); + }); + + clip.startDispatched = false; + log.debug("previously started clip " + _startedClip); + if (_startedClip && _startedClip == clip && _connection && _netStream) { + log.info("playing previous clip again, reusing existing connection and resuming"); + _started = false; + replay(clip); + } else { + log.debug("will create a new connection"); + _startedClip = clip; + + connect(clip); + } + } + + private function replay(clip:Clip):void { + try { + seek(new ClipEvent(ClipEventType.SEEK, 0), 0); + netStream.resume(); + _started = true; + clip.dispatchEvent(new ClipEvent(ClipEventType.BEGIN, _pauseAfterStart)); +// start(null, _startedClip, _pauseAfterStart); + } catch (e:Error) { + if (e.errorID == 2154) { + log.debug("error when reusing existing netStream " + e); + connect(clip); + } else { + throw e; + } + } + } + + /** + * @inheritDoc + */ + public function get allowRandomSeek():Boolean { + return false; + } + + /** + * @inheritDoc + */ + public function stopBuffering():void { + if (! _netStream) return; + log.debug("stopBuffering, closing netStream"); + _netStream.close(); + _netStream = null; + dispatchPlayEvent(ClipEventType.BUFFER_STOP); + } + + /** + * @inheritDoc + */ + public final function resume(event:ClipEvent):void { + _paused = false; + _stopping = false; + doResume(_netStream, event); + } + + /** + * @inheritDoc + */ + public final function pause(event:ClipEvent):void { + _paused = true; + doPause(_netStream, event); + } + + /** + * @inheritDoc + * @see #doSeek() + */ + public final function seek(event:ClipEvent, seconds:Number):void { + silentSeek = event == null; + log.debug("seekTo " + seconds); + _seekTarget = seconds; + doSeek(event, _netStream, seconds); + } + + /** + * @inheritDoc + */ + public final function stop(event:ClipEvent, closeStreamAndConnection:Boolean = false):void { + log.debug("stop called"); + if (! _netStream) return; + doStop(event, _netStream, closeStreamAndConnection); + } + + public final function switchStream(event:ClipEvent, clip:Clip, netStreamPlayOptions:Object = null):void { + log.debug("switchStream called"); + if (! _netStream) return; + //clip.currentTime = 0; + doSwitchStream(event, _netStream, clip, netStreamPlayOptions); + } + + /** + * @inheritDoc + */ + public function get time():Number { + if (! _netStream) return 0; + // if (! currentClipStarted()) return 0; + // if (! _started) { + // return 0; + // } + return getCurrentPlayheadTime(netStream); + } + + /** + * @inheritDoc + */ + public function get bufferStart():Number { + return 0; + } + + /** + * @inheritDoc + */ + public function get bufferEnd():Number { + if (! _netStream) return 0; + if (! currentClipStarted()) return 0; + // log.debug("bytes loaded: " + _netStream.bytesLoaded +", bytes total: " + _netStream.bytesTotal + ", duration: " + clip.durationFromMetadata); + return Math.min(_netStream.bytesLoaded / _netStream.bytesTotal * clip.durationFromMetadata, clip.duration); + } + + /** + * @inheritDoc + */ + public function get fileSize():Number { + if (! _netStream) return 0; + if (! currentClipStarted()) return 0; + return _netStream.bytesTotal; + } + + /** + * @inheritDoc + */ + public function set volumeController(volumeController:VolumeController):void { + _volumeController = volumeController; + } + + /** + * @inheritDoc + */ + public function get stopping():Boolean { + return _stopping; + } + + /** + * @inheritDoc + */ + public function getVideo(clip:Clip):DisplayObject { + var video:Video = new Video(); + video.smoothing = clip.smoothing; + return video; + } + + /** + * @inheritDoc + */ + public function attachStream(video:DisplayObject):void { + Video(video).attachNetStream(_netStream); + } + + /** + * @inheritDoc + */ + public function get playlist():Playlist { + return _playlist; + } + + /** + * @inheritDoc + */ + public function set playlist(playlist:Playlist):void { + _playlist = playlist; + } + + /** + * @inheritDoc + */ + public function addConnectionCallback(name:String, listener:Function):void { + log.debug("addConnectionCallback " + name); + _connectionClient.addConnectionCallback(name, listener); + } + + /** + * @inheritDoc + */ + public function addStreamCallback(name:String, listener:Function):void { + log.debug("addStreamCallback " + name); + _streamCallbacks[name] = listener; + } + + /** + * @inheritDoc + */ + public final function get netStream():NetStream { + return _netStream; + } + + /** + * @inheritDoc + * + */ + public function get netConnection():NetConnection { + return _connection; + } + + /** + * @inheritDoc + */ + public function get streamCallbacks():Dictionary { + return _streamCallbacks; + } + + /* ---- Methods that can be overridden ----- */ + /* ----------------------------------------- */ + + /** + * Connects to the backend. The implementation creates a new NetConnection then calls + * <code>addConnectionStatusListener(connection)</code> and <code>NetConnection.connect(getConnectUrl(clip))</code>. + * + * @see #getConnectUrl() + */ + protected function connect(clip:Clip, ... rest):void { + + if (_netStream) { + _netStream.close(); + _netStream = null; + } + if (_connection) { + _connection.close(); + _connection = null; + } + _connectionArgs = rest; + resolveClipUrl(clip, onClipUrlResolved); + } + + /** + * Starts loading using the specified netStream and clip. Can be overridden in subclasses. + * + * @param event the event that is dispatched after the loading has been successfully + * started + * @param netStream + * @param clip + */ + protected function doLoad(event:ClipEvent, netStream:NetStream, clip:Clip):void { + //clip.currentTime = 0; + netStream.client = new NetStreamClient(clip, _player.config, _streamCallbacks); + netStreamPlay(getClipUrl(clip)); + } + + /** + * Gets the clip URL from the specified clip. The URL is supplied to NetStream.play(url). + * Can be overridden unsubclasses. + * + * @param clip + * @return + */ + protected function getClipUrl(clip:Clip):String { + return clip.completeUrl; + } + + /** + * Pauses the specified netStream. This implementation calls <code>netStream.pause()</code> + * and dispatches the specified event. + * + * @param netStream + * @param event the event that is dispatched after pausing, is <code>null</code> if + * we are pausing silently + */ + protected function doPause(netStream:NetStream, event:ClipEvent = null):void { + if (! netStream) return; +// if (clip.live) { +// log.debug("pausing a live stream, closing netStream"); +// netStream.close(); +// } else { +// netStream.pause(); +// } + netStream.pause(); + if (event) { + dispatchEvent(event); + } + } + + /** + * Resumes the specified netStream. The implementation in this class calls <code>netStream.resume()</code> + * and dispatches the specified event. + * @param netStream + * @param event the event that is dispatched after resuming + */ + protected function doResume(netStream:NetStream, event:ClipEvent):void { + try { + _volumeController.netStream = netStream; + netStream.resume(); + dispatchEvent(event); + } catch (e:Error) { + // netStream is invalid because of a timeout + log.info("doResume(): error catched " + e + ", will connect again. All resolved URLs are discarded."); + clip.clearResolvedUrls(); + dispatchEvent(new ClipEvent(ClipEventType.STOP)); + _started = false; + connect(clip); + } + } + + /** + * Silent seek mode. When enabled the SEEK event is not dispatched. + * @see ClipEventType#SEEK + */ + protected final function set silentSeek(value:Boolean):void { + _silentSeek = value; + log.info("silent mode was set to " + _silentSeek); + } + + protected final function get silentSeek():Boolean { + return _silentSeek; + } + + /** + * Are we paused? + */ + protected final function get paused():Boolean { + return _paused; + } + + /** + * Is the seek in process? + * @return + */ + protected final function get seeking():Boolean { + return _seeking; + } + + protected final function set seeking(value:Boolean):void { + _seeking = value; + } + + /** + * Seeks the netStream to the specified target. The implementation in this class calls + * <code>netStream.seek(seconds)</code>. Override if you need something different. + * @param event the event that is dispatched after seeking successfully + * @param netStream + * @param seconds the seek target position + */ + protected function doSeek(event:ClipEvent, netStream:NetStream, seconds:Number):void { + // the seek event is dispatched when we recevive the seek notification from netStream + log.debug("calling netStream.seek(" + seconds + ")"); + _seeking = true; + netStream.seek(seconds); + } + + protected function doSwitchStream(event:ClipEvent, netStream:NetStream, clip:Clip, netStreamPlayOptions:Object = null):void { + load(event, clip); + dispatchEvent(event); + } + + /** + * Can we dispatch the start event now? This class uses this method every time + * before it's about to dispatch the start event. The event is only dispatched + * if this method returns <code>true</code>. + * + * @return <code>true</code> if the start event can be dispatched + * @see ClipEventType#BEGIN + */ + protected function canDispatchBegin():Boolean { + return true; + } + + /** + * Can we disppatch the onStreamNotFound ERROR event now? + * @return <code>true</code> if the start event can be dispatched + * + * @see ClipEventType#ERROR + */ + protected function canDispatchStreamNotFound():Boolean { + return true; + } + + /** + * Dispatches the specified event. + */ + protected final function dispatchEvent(event:ClipEvent):void { + if (! event) return; + log.debug("dispatching " + event + " on clip " + clip); + clip.dispatchEvent(event); + } + + /** + * Called when NetStatusEvents are received. + */ + protected function onNetStatus(event:NetStatusEvent):void { + // can be overridden in subclasses + } + + /** + * Is the playback duration of current clip reached? + */ + protected function isDurationReached():Boolean { + return Math.abs(getCurrentPlayheadTime(netStream) - clip.duration) <= 0.5; + } + + /** + * Gets the current playhead time. This should be overridden if the time + * is not equl to netStream.time + */ + protected function getCurrentPlayheadTime(netStream:NetStream):Number { + if (_timeProvider) { + return _timeProvider.getTime(netStream); + } + return netStream.time; + } + + /** + * The current clip in the playlist. + */ + protected final function get clip():Clip { + return _playlist.current; + } + + /** + * Should we pause on first frame after starting. + * @see #load() the load() method has an autoPlay parameter that controls whether we stop on first frame or not + */ + protected final function get pauseAfterStart():Boolean { + return _pauseAfterStart; + } + + protected final function set pauseAfterStart(value:Boolean):void { + _pauseAfterStart = value; + } + + /** + * Have we started streaming the playlist's current clip? + */ + protected function currentClipStarted():Boolean { + return _startedClip == clip; + } + + /** + * Have we already received a NetStream.Play.Start from the NetStream + */ + protected function get started():Boolean { + return _started; + } + + /** + * Resolves the url for the specified clip. + */ + protected final function resolveClipUrl(clip:Clip, successListener:Function):void { + _clipUrlResolverHelper.resolveClipUrl(clip, successListener); + } + + /** + * Previous seek target value in seconds. + */ + public function get seekTarget():Number { + return _seekTarget; + } + + /** + * Override this to receive the plugin model. + */ + public function onConfig(model:PluginModel):void { + } + + /** + * Override this to receive the player instance. + */ + public function onLoad(player:Flowplayer):void { + } + + /** + * Gets the default clip url resolver to be used if the ProviderModel + * supplied to this provider does not specify a connection provider. + */ + protected function getDefaultClipURLResolver():ClipURLResolver { + return new DefaultClipURLResolver(); + } + + /** + * Calls netStream.play(url) + * @param url + * @return + */ + protected function netStreamPlay(url:String):void { + log.debug("netStreamPlay(): starting playback with resolved url " + url); + _netStream.play(url); + } + + protected function onClipUrlResolved(clip:Clip):void { + _connectionClient.clip = clip; + connectionProvider.connectionClient = _connectionClient; + log.debug("about to call connectionProvider.connect, objectEncoding " + _model.objectEncoding); + connectionProvider.connect(this, clip, onConnectionSuccess, _model.objectEncoding, _connectionArgs || []); + } + + /** + * Gets the connection provider for the specified clip. Note: this function should return the same instance + * on repeated calls for the same clip. + * @param clip + * @return + */ + protected function getConnectionProvider(clip:Clip):ConnectionProvider { + return _connectionProvider; + } + + + /* ---- Private methods ----- */ + /* -------------------------- */ + + private function createClipUrlResolver():void { + var defaultResolver:ClipURLResolver = null; + if (_model.urlResolver) { + defaultResolver = PluginModel(_player.pluginRegistry.getPlugin(_model.urlResolver)).pluginObject as ClipURLResolver; + } + + _clipUrlResolverHelper = new ClipURLResolverHelper(_player, this, defaultResolver); + } + + private function createConnectionProvider():void { + if (_model.connectionProvider) { + log.debug("getting connection provider " + _model.connectionProvider + " from registry"); + _connectionProvider = PluginModel(_player.pluginRegistry.getPlugin(_model.connectionProvider)).pluginObject as ConnectionProvider; + if (! _connectionProvider) { + throw new Error("connection provider " + _model.connectionProvider + " not loaded"); + } + } + _connectionProvider = new DefaultRTMPConnectionProvider(); + } + + private function dispatchError(error:ClipError, info:String):void { + clip.dispatchError(error, info); + } + + private function _onNetStatus(event:NetStatusEvent):void { + log.info("_onNetStatus, code: " + event.info.code); + + if (! _clipUrlResolverHelper.getClipURLResolver(clip).handeNetStatusEvent(event)) { + log.debug("clipURLResolver.handeNetStatusEvent returned false, ignoring this event"); + return; + } + + if (! connectionProvider.handeNetStatusEvent(event)) { + log.debug("connectionProvider.handeNetStatusEvent returned false, ignoring this event"); + return; + } + + if (_stopping) { + log.info("_onNetStatus(), _stopping == true and will not process the event any further"); + return; + } + + if (event.info.code == "NetStream.Buffer.Empty") { + dispatchPlayEvent(ClipEventType.BUFFER_EMPTY); + } else if (event.info.code == "NetStream.Buffer.Full") { + dispatchPlayEvent(ClipEventType.BUFFER_FULL); + } else if (event.info.code == "NetStream.Play.Start") { + if (! _paused && canDispatchBegin()) { + log.debug("dispatching onBegin"); + clip.dispatchEvent(new ClipEvent(ClipEventType.BEGIN, _pauseAfterStart)); + } + } else if (event.info.code == "NetStream.Play.Stop") { + if (clip.duration - _player.status.time < 1) + { + // we need to send buffer full at end of the video + clip.dispatchEvent(new ClipEvent(ClipEventType.BUFFER_FULL)); // Bug #39 + } + + // dispatchPlayEvent(ClipEventType.STOP); + } else if (event.info.code == "NetStream.Seek.Notify") { + if (! silentSeek) { + startSeekTargetWait(); + } else { + _seeking = false; + } + silentSeek = false; + + } else if (event.info.code == "NetStream.Seek.InvalidTime") { + + } else if (event.info.code == "NetStream.Play.StreamNotFound" || + event.info.code == "NetConnection.Connect.Rejected" || + event.info.code == "NetConnection.Connect.Failed") { + + if (canDispatchStreamNotFound()) { + clip.dispatchError(ClipError.STREAM_NOT_FOUND, event.info.code); + } + } + + onNetStatus(event); + } + + private function onConnectionSuccess(connection:NetConnection):void { + _connection = connection; + _createNetStream(); + start(null, clip, _pauseAfterStart); + dispatchPlayEvent(ClipEventType.CONNECT); + } + + private function startSeekTargetWait():void { + if (_seekTarget < 0) return; + if (_seekTargetWaitTimer && _seekTargetWaitTimer.running) return; + log.debug("starting seek target wait timer"); + _seekTargetWaitTimer = new Timer(200); + _seekTargetWaitTimer.addEventListener(TimerEvent.TIMER, onSeekTargetWait); + _seekTargetWaitTimer.start(); + } + + private function onSeekTargetWait(event:TimerEvent):void { + if (time >= _seekTarget) { + _seekTargetWaitTimer.stop(); + log.debug("dispatching onSeek"); + dispatchPlayEvent(ClipEventType.SEEK, _seekTarget); + _seekTarget = -1; + _seeking = false; + } + } + + private function dispatchPlayEvent(playEvent:ClipEventType, info:Object = null):void { + dispatchEvent(new ClipEvent(playEvent, info)); + } + + protected function doStop(event:ClipEvent, netStream:NetStream, closeStreamAndConnection:Boolean = false):void { + log.debug("doStop"); + _stopping = true; + + if (clip.live) { + _netStream.close(); + _netStream = null; + + } else if (closeStreamAndConnection) { + _startedClip = null; + log.debug("doStop(), closing netStream and connection"); + + try { + netStream.close(); + _netStream = null; + } catch (e:Error) { + } + + if (_connection) { + _connection.close(); + _connection = null; + } + clip.setContent(null); + } else { + silentSeek = true; + netStream.client = new NullNetStreamClient(); + netStream.pause(); + netStream.seek(0); + } + dispatchEvent(event); + } + + private function _createNetStream():void { + _netStream = createNetStream(_connection) || new NetStream(_connection); + netStream.client = new NetStreamClient(clip, _player.config, _streamCallbacks); + _netStream.bufferTime = clip.bufferLength; + _volumeController.netStream = _netStream; + clip.setNetStream(_netStream); + _netStream.addEventListener(NetStatusEvent.NET_STATUS, _onNetStatus); + } + + protected function createNetStream(connection:NetConnection):NetStream { + return null; + } + + protected function onMetaData(event:ClipEvent):void { + log.info("in NetStreamControllingStremProvider.onMetaData: " + event.target); + if (! clip.startDispatched) { + clip.dispatch(ClipEventType.START, _pauseAfterStart); + clip.startDispatched = true; + } + // some files require that we seek to the first frame only after receiving metadata + // otherwise we will never receive the metadata + if (_pauseAfterStart) { + log.info("seeking to frame zero"); + seek(null, 0); + dispatchPlayEvent(ClipEventType.PAUSE); + _pauseAfterStart = false; + } + } + + private function start(event:ClipEvent, clip:Clip, pauseAfterStart:Boolean = false):void { + log.debug("start called with clip " + clip + ", pauseAfterStart " + pauseAfterStart); + + try { + doLoad(event, _netStream, clip); + _started = true; + } catch (e:SecurityError) { + dispatchError(ClipError.STREAM_LOAD_FAILED, "cannot access the video file (try loosening Flash security settings): " + e.message); + } catch (e:IOError) { + dispatchError(ClipError.STREAM_LOAD_FAILED, "cannot load the video file, incorrect URL?: " + e.message); + } catch (e:Error) { + dispatchError(ClipError.STREAM_LOAD_FAILED, "cannot play video: " + e.message); + } + + if (pauseAfterStart) { + log.info("pausing to first frame!"); + doPause(_netStream, null); + // _netStream.seek(0); + } + } + + + + private function get connectionProvider():ConnectionProvider { + var provider:ConnectionProvider; + if (clip.connectionProvider) { + provider = PluginModel(_player.pluginRegistry.getPlugin(clip.connectionProvider)).pluginObject as ConnectionProvider; + if (! provider) { + throw new Error("connectionProvider " + clip.connectionProvider + " not loaded"); + } + } else { + provider = getConnectionProvider(clip); + } + provider.onFailure = function(message:String = null):void { + clip.dispatchError(ClipError.STREAM_LOAD_FAILED, "connection failed" + (message ? ": " + message : "")); + }; + return provider; + } + + public function set timeProvider(timeProvider:TimeProvider):void { + log.debug("set timeprovider() " + timeProvider); + _timeProvider = timeProvider; + } + + public function get type():String { + return "http"; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NullNetStreamClient.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NullNetStreamClient.as new file mode 100644 index 0000000000000000000000000000000000000000..2e402096c11a69ea5bd731d9a9f9ca8ac3dee363 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NullNetStreamClient.as @@ -0,0 +1,63 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import org.flowplayer.controller.NetStreamCallbacks; + + /** + * @author api + */ + internal class NullNetStreamClient implements NetStreamCallbacks { + public function onCuePoint(infoObject:Object):void { + } + + public function onXMPData(infoObject:Object):void { + } + + public function onBWDone(infoObject:Object):void { + } + + public function onCaption(cps:String, spk:Number):void { + } + + public function onCaptionInfo(infoObject:Object):void { + } + + public function onFCSubscribe(infoObject:Object):void { + } + + public function onLastSecond(infoObject:Object):void { + } + + public function onPlayStatus(infoObject:Object):void { + } + + public function onImageData(infoObject:Object):void { + } + + public function RtmpSampleAccess(infoObject:Object):void { + } + + public function onTextData(infoObject:Object):void { + } + + public function onMetaData(infoObject:Object):void { + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NullVolumeStorage.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NullVolumeStorage.as new file mode 100644 index 0000000000000000000000000000000000000000..058846a511b72cf651549676765829a14dd09c8c --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/NullVolumeStorage.as @@ -0,0 +1,51 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import org.flowplayer.util.Log; + import org.flowplayer.controller.VolumeStorage; + + /** + * @author api + */ + internal class NullVolumeStorage implements VolumeStorage { + private var log:Log = new Log(this); + + public function NullVolumeStorage() { + log.warn("not allowed to store data on this machine"); + } + + public function persist():void { + } + + public function get volume():Number { + return 1; + } + + public function get muted():Boolean { + return false; + } + + public function set volume(value:Number):void { + } + + public function set muted(value:Boolean):void { + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ParallelRTMPConnectionProvider.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ParallelRTMPConnectionProvider.as new file mode 100644 index 0000000000000000000000000000000000000000..677a174fceb55a32dd7a33d3fe34850173aff625 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ParallelRTMPConnectionProvider.as @@ -0,0 +1,184 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import flash.events.NetStatusEvent; + import flash.events.NetStatusEvent; + + import flash.events.TimerEvent; + import flash.net.NetConnection; + + import flash.utils.Timer; + + import org.flowplayer.controller.ConnectionProvider; + import org.flowplayer.controller.DefaultRTMPConnectionProvider; + import org.flowplayer.controller.NetStreamControllingStreamProvider; + import org.flowplayer.controller.StreamProvider; + import org.flowplayer.model.Clip; + import org.flowplayer.model.Clip; + import org.flowplayer.util.Log; + + /** + * @author api + */ + public class ParallelRTMPConnectionProvider implements ConnectionProvider { + + protected var log:Log = new Log(this); + // private var _config:Config; + + protected var _successListener:Function; + protected var _failureListener:Function; + protected var _connectionClient:Object; + protected var _connector1:ParallelRTMPConnector; + protected var _connector2:ParallelRTMPConnector; + protected var _connection:NetConnection; + + protected var _netConnectionUrl:String; + protected var _proxyType:String; + protected var _failOverDelay:int; + + public function ParallelRTMPConnectionProvider(netConnectionUrl:String, proxyType:String = "best", failOverDelay:int = 250) { + _netConnectionUrl = netConnectionUrl; + _proxyType = proxyType; + _failOverDelay = failOverDelay; + } + + public function connect(ignored:StreamProvider, clip:Clip, successListener:Function, objectEncoding:uint, connectionArgs:Array):void { + + _successListener = successListener; + _connection = null; + + var configuredUrl:String = getNetConnectionUrl(clip) + if (! configuredUrl && _failureListener != null) { + _failureListener("netConnectionURL is not defined"); + } + var parts:Array = getUrlParts(configuredUrl); + var connArgs:Array = (clip.getCustomProperty("connectionArgs") as Array) || connectionArgs; + + if (parts && (parts[0] == 'rtmp' || parts[0] == 'rtmpe')) { + + log.debug("will connect using RTMP and RTMPT in parallel, connectionClient " + _connectionClient); + _connector1 = createConnector((parts[0] == 'rtmp' ? 'rtmp' : 'rtmpe') + '://' + parts[1]); + _connector2 = createConnector((parts[0] == 'rtmp' ? 'rtmpt' : 'rtmpte') + '://' + parts[1]); + + doConnect(_connector1, _proxyType, objectEncoding, connArgs); + + // RTMPT connect is started after 250 ms + var delay:Timer = new Timer(_failOverDelay, 1); + delay.addEventListener(TimerEvent.TIMER, function(event:TimerEvent):void { + doConnect(_connector2, _proxyType, objectEncoding, connectionArgs); + }); + delay.start(); + + } else { + log.debug("connecting to URL " + configuredUrl); + _connector1 = createConnector(configuredUrl); + doConnect(_connector1, _proxyType, objectEncoding, connArgs); + } + } + + protected function createConnector(url:String):ParallelRTMPConnector { + return new ParallelRTMPConnector(url, connectionClient, onConnectorSuccess, onConnectorFailure); + } + + private function doConnect(connector1:ParallelRTMPConnector, proxyType:String, objectEncoding:uint, connectionArgs:Array):void { + if (connectionArgs.length > 0) { + connector1.connect(_proxyType, objectEncoding, connectionArgs); + } else { + connector1.connect(_proxyType, objectEncoding, null); + } + } + + protected function onConnectorSuccess(connector:ParallelRTMPConnector, connection:NetConnection):void { + log.debug(connector + " established a connection"); + if (_connection) return; + _connection = connection; + + if (connector == _connector2 && _connector1) { + _connector1.stop(); + } else if (_connector2) { + _connector2.stop(); + } + _successListener(connection); + } + + protected function onConnectorFailure():void { + if (isFailedOrNotUsed(_connector1) && isFailedOrNotUsed(_connector2) && _failureListener != null) { + _failureListener(); + } + } + + private function isFailedOrNotUsed(connector:ParallelRTMPConnector):Boolean { + if (! connector) return true; + return connector.failed; + } + + private function getUrlParts(url:String):Array { + var pos:int = url.indexOf('://'); + if (pos > 0) { + return [url.substring(0, pos), url.substring(pos + 3)]; + } + return null; + } + + protected function getNetConnectionUrl(clip:Clip):String { + if (isRtmpUrl(clip.completeUrl)) { + log.debug("clip has complete rtmp url"); + var url:String = clip.completeUrl; + var lastSlashPos:Number = url.lastIndexOf("/"); + return url.substring(0, lastSlashPos); + } + if (clip.customProperties && clip.customProperties.netConnectionUrl) { + log.debug("clip has netConnectionUrl as a property " + clip.customProperties.netConnectionUrl); + return clip.customProperties.netConnectionUrl; + } + log.debug("using netConnectionUrl from config" + _netConnectionUrl); + return _netConnectionUrl; + } + + protected function isRtmpUrl(url:String):Boolean { + return url && url.toLowerCase().indexOf("rtmp") == 0; + } + + public function set connectionClient(client:Object):void { + log.debug("received connection client " + client); + _connectionClient = client; + } + + public function get connectionClient():Object { + if (! _connectionClient) { + _connectionClient = new NetConnectionClient(); + } + log.debug("using connection client " + _connectionClient); + return _connectionClient; + } + + public function set onFailure(listener:Function):void { + _failureListener = listener; + } + + public function handeNetStatusEvent(event:NetStatusEvent):Boolean { + return true; + } + + public function get connection():NetConnection { + return _connection; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ParallelRTMPConnector.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ParallelRTMPConnector.as new file mode 100644 index 0000000000000000000000000000000000000000..b5dea970d1766340230baaf746e744c40617b339 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ParallelRTMPConnector.as @@ -0,0 +1,115 @@ +/* + * This file is part of Flowplayer, http://flowplayer.org + * + * By: Anssi Piirainen, <support@flowplayer.org> + * Copyright (c) 2009 Flowplayer Ltd + * + * Released under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + */ + +package org.flowplayer.controller { + import flash.events.NetStatusEvent; + import flash.net.NetConnection; + + import flash.utils.setTimeout; + + import org.flowplayer.util.Log; + + public class ParallelRTMPConnector { + protected var log:Log = new Log(this); + protected var _url:String; + protected var _successListener:Function; + protected var _connectionClient:Object; + protected var _connection:NetConnection; + protected var _failureListener:Function; + protected var _failed:Boolean; + + public function ParallelRTMPConnector(url:String, connectionClient:Object, onSuccess:Function, onFailure:Function) { + _url = url; + _connectionClient = connectionClient; + _successListener = onSuccess; + _failureListener = onFailure; + _failed = false; + log.debug("created with connection client " + _connectionClient); + } + + public function connect(proxyType:String, objectEncoding:uint, connectionArgs:Array):void { + log.debug(this +"::connect() using proxy type '" + proxyType + "'" + ", object encoding " + objectEncoding); + if (_successListener == null) { + log.debug(this + ", this connector has been stopped, will not proceed with connect()"); + return; + } + _connection = new NetConnection(); + _connection.proxyType = proxyType; + _connection.objectEncoding = objectEncoding; + + log.debug("using connection client " + _connectionClient); + if (_connectionClient) { + _connection.client = _connectionClient; + } + _connection.addEventListener(NetStatusEvent.NET_STATUS, _onConnectionStatus); + + log.debug("netConnectionUrl is " + _url); + if (connectionArgs && connectionArgs.length > 0) { + _connection.connect.apply(_connection, [ _url ].concat(connectionArgs)); + } else { + _connection.connect(_url); + } + } + + protected function onConnectionStatus(event:NetStatusEvent):void { + + } + + private function _onConnectionStatus(event:NetStatusEvent):void { + + onConnectionStatus(event); + + log.debug(this + "::_onConnectionStatus() " + event.info.code); + + if (event.info.code == "NetConnection.Connect.Success") { + if (_successListener != null) { + _successListener(this, _connection); + } else { + log.debug("this connector is stopped, will not call successListener"); + _connection.close(); + } + return; + + } + + if (event.info.code == "NetConnection.Connect.Rejected" && event.info.ex && event.info.ex.code == 302) { + log.debug("starting a timeout to connect to a redirected URL " + event.info.ex.redirect); + setTimeout(function():void{ + log.debug("connecting to a redirected URL " + event.info.ex.redirect); + _connection.connect(event.info.ex.redirect); + }, 100); + return; + } + + if (["NetConnection.Connect.Failed", "NetConnection.Connect.Rejected", "NetConnection.Connect.AppShutdown", "NetConnection.Connect.InvalidApp"].indexOf(event.info.code) >= 0) { + _failed = true; + if (_failureListener != null) { + _failureListener(); + } + } + } + + public function stop():void { + log.debug("stop()"); + if (_connection) { + _connection.close(); + } + _successListener = null; + } + + public function toString():String { + return "Connector, [" + _url + "]"; + } + + public function get failed():Boolean { + return _failed; + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/PausedState.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/PausedState.as new file mode 100644 index 0000000000000000000000000000000000000000..28225af91f4d9fda80d035079c91893505600111 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/PausedState.as @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import flash.utils.Dictionary; + + import org.flowplayer.controller.PlayListController; + import org.flowplayer.model.ClipEventSupport; +import org.flowplayer.model.ClipEventType; + import org.flowplayer.model.Playlist; + import org.flowplayer.model.State; + import org.flowplayer.model.Status; + + /** + * @author api + */ + internal class PausedState extends PlayState { + + public function PausedState(stateCode:State, playList:Playlist, playListController:PlayListController, providers:Dictionary) { + super(stateCode, playList, playListController, providers); + } + + override protected function setEventListeners(eventSupport:ClipEventSupport, add:Boolean = true):void { + if (add) { + log.debug("adding event listeners"); + eventSupport.onStop(onClipStop); + } else { + eventSupport.unbind(onClipStop); + } + } + + internal override function play():void { + resume(); + } + + internal override function resume():void { + log.debug("resume(), changing to stage " + playingState); + if (canOnEvent(ClipEventType.RESUME)) { + changeState(playingState); + onEvent(ClipEventType.RESUME); + } + } + + internal override function stopBuffering():void { + log.debug("stopBuffering() called"); + stop(); + getMediaController().stopBuffering(); + } + + internal override function seekTo(seconds:Number):void { + if ( canOnEvent(ClipEventType.SEEK, [seconds], seconds)) + onEvent(ClipEventType.SEEK, [seconds]); + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/PlayListController.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/PlayListController.as new file mode 100644 index 0000000000000000000000000000000000000000..e19fb2053bdc1bb5ddfbdd34b02ef5098851e1f1 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/PlayListController.as @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import org.flowplayer.config.Config; + import org.flowplayer.flow_internal; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipEvent; + import org.flowplayer.model.ClipType; + import org.flowplayer.model.Playlist; + import org.flowplayer.model.ProviderModel; + import org.flowplayer.model.State; + import org.flowplayer.model.Status; + import org.flowplayer.util.Log; + import org.flowplayer.view.PlayerEventDispatcher; + + import flash.utils.Dictionary; + + use namespace flow_internal; + + /** + * PlayListController is responsible in moving the playback within the clips in the playList. + * It does this by delegating to the the PlayStates. + * + * @author anssi + */ + public class PlayListController { + + private var log:Log; + private var _playList:Playlist; + private var _state:PlayState; + private var _providers:Dictionary; + private var _config:Config; + private var _loader:ResourceLoader; + + public function PlayListController(playList:Playlist, providers:Dictionary, config:Config, loader:ResourceLoader) { + log = new Log(this); + _playList = playList; + _providers = providers; + _config = config; + _loader = loader; + } + + flow_internal function get streamProvider():StreamProvider { + return _state.streamProvider; + } + + flow_internal function set playerEventDispatcher(playerEventDispatcher:PlayerEventDispatcher):void { + PlayState.initStates(_playList, this, _providers, playerEventDispatcher, _config, _loader); + } + + flow_internal function setPlaylist(clips:Array):void { + if (getState() != State.WAITING) { + close(false); + } + _playList.replaceClips2(clips); + } + + flow_internal function get playlist():Playlist { + return _playList; + } + + + flow_internal function rewind():Clip { + log.info("rewind()"); + setPlayState(PlayState.waitingState); + _playList.toIndex(firstNonSplashClip()); + _state.play(); + return _playList.current; + } + + private function firstNonSplashClip():Number { + var clips:Array = _playList.clips; + for (var i:Number = 0; i < clips.length; i++) { + var clip:Clip = clips[i]; + if (clip.type == ClipType.IMAGE && clip.duration > 0) { + return i; + } + if (clip.type == ClipType.IMAGE && i < clips.length - 1) { + var nextClip:Clip = clips[i+1] as Clip; + if (nextClip.type == ClipType.AUDIO && nextClip.image) { + // this is a splash image for the next audio clip + nextClip.autoPlayNext = true; + return i; + } + } + if (clip.type == ClipType.VIDEO || clip.type == ClipType.AUDIO) { + return i; + } + } + return 0; + } + + flow_internal function playClips(clips:Array):void { + replacePlaylistAndPlay(clips); + } + + flow_internal function playInstream(clip:Clip):void { + _state.pause(); + playlist.setInStreamClip(clip); + setPlayState(PlayState.waitingState); + _state.play(); + } + + flow_internal function switchStream(clip:Clip, netStreamPlayOption:Object = null):void { + _state.switchStream(netStreamPlayOption); + } + + flow_internal function play(clip:Clip = null, clipIndex:Number = -1):Clip { + log.debug("play() " + clip + ", " + clipIndex); + if (clip || clipIndex >= 0) { + return playClip(clip, clipIndex); + } else if (! _playList.hasNext() && status.ended) { + return rewind(); + } + _state.play(); + return _playList.current; + } + + private function playClip(clip:Clip = null, clipIndex:Number = undefined):Clip { + if (clip) { + replacePlaylistAndPlay(clip); + return clip; + } + if (clipIndex >= 0) { + if (clipIndex == _playList.currentIndex && getState() != State.WAITING) { + log.debug("play(): already playing this clip, returning"); + return _playList.current; + } + _state.stop(); + if (_playList.toIndex(clipIndex) == null) { + log.error("There is no clip at index " + clipIndex + ", cannot play"); + return _playList.current; + } + _state.play(); + } + return _playList.current; + } + + flow_internal function startBuffering():Clip { + _state.startBuffering(); + return _playList.current; + } + + flow_internal function stopBuffering():Clip { + _state.stopBuffering(); + return _playList.current; + } + + flow_internal function next(obeyClipPlaySettings:Boolean, silent:Boolean = false, skipPreAndPostroll:Boolean = true):Clip { + if (!_playList.hasNext(skipPreAndPostroll)) return _playList.current; + return moveTo(_playList.next, obeyClipPlaySettings, silent, skipPreAndPostroll); + } + + flow_internal function previous(skipPreAndPostroll:Boolean = true):Clip { + if (!_playList.hasPrevious(skipPreAndPostroll)) return _playList.current; + + if (currentIsAudioWithSplash() && _playList.currentIndex >= 3) { + _state.stop(); + _playList.toIndex(_playList.currentIndex - 2); + _state.play(); + return _playList.current; + } + + return moveTo(_playList.previous, false, false, skipPreAndPostroll); + } + + private function currentIsAudioWithSplash():Boolean { + return _playList.current.type == ClipType.AUDIO && _playList.current.image + && _playList.previousClip && _playList.previousClip.type == ClipType.IMAGE; + } + + flow_internal function moveTo(advanceFunction:Function, obeyClipPlaySettings:Boolean, silent:Boolean, skipPreAndPostroll:Boolean = true):Clip { + var stateBeforeStopping:State = getState(); + + log.debug("moveTo() current state is " + _state); + + if (silent) { + _state.stop(true, true); + setPlayState(PlayState.waitingState); + } else { + _state.stop(); + } + + // now we can move to next/previous in the playList + var clip:Clip = advanceFunction(skipPreAndPostroll) as Clip; + log.info("moved in playlist, current clip is " + _playList.current + ", next clip is " + clip); + + log.debug("moved in playlist, next clip autoPlay " + clip.autoPlay + ", autoBuffering " + clip.autoBuffering); + if (obeyClipPlaySettings) { + log.debug("obeying clip autoPlay & autoBuffeing"); + // autoPlayNext is used when rewinding + log.debug("autoPlayNext? " + clip.autoPlayNext + ", autoPlay? " + clip.autoPlay + ", autoBuffering? " + clip.autoBuffering); + if (clip.autoPlayNext) { + clip.autoPlayNext = false; + _state.play(); + } else if (clip.autoPlay) { + _state.play(); + } else if (clip.autoBuffering) { + if (clip.type == ClipType.IMAGE && clip.autoBuffering) { + _state.play(); + }else { + _state.startBuffering(); + } + } + } else { + log.debug("not obeying playlist settings"); + if (stateBeforeStopping == State.PAUSED || stateBeforeStopping == State.WAITING) { + _state.startBuffering(); + } else { + _state.play(); + } + } + + return clip; + } + + flow_internal function pause():Clip { + _state.pause(); + return _playList.current; + } + + flow_internal function resume():Clip { + _state.resume(); + return _playList.current; + } + + flow_internal function stop(silent:Boolean = false):Clip { + if (silent) { + setPlayState(PlayState.waitingState); + } else { + if (_state) { + _state.stop(); + } + } + if (! _playList) return null; + return _playList.current; + } + + flow_internal function close(silent:Boolean):void { + _state.close(silent); + } + + flow_internal function seekTo(seconds:Number):Clip { + log.debug("seekTo " + seconds); + if (seconds >= 0) { + _state.seekTo(seconds); + } else { + log.warn("seekTo was called with seconds value " + seconds); + } + return _playList.current; + } + + flow_internal function getState():State { + if (! _state) return null; + return _state.state; + } + + flow_internal function getPlayState():PlayState { + return _state; + } + + flow_internal function setPlayState(state:PlayState):void { + log.debug("moving to state " + state); + if (_state) + _state.active = false; + _state = state; + _state.active = true; + } + + flow_internal function isInState(state:PlayState):Boolean { + return _state == state; + } + + flow_internal function get muted():Boolean { + return _state.muted; + } + + flow_internal function set muted(value:Boolean):void { + _state.muted = value; + } + + flow_internal function set volume(volume:Number):void { + _state.volume = volume; + } + + flow_internal function get volume():Number { + if (! _state) return 0; + return _state.volume; + } + + flow_internal function get status():Status { + return _state.status; + } + + flow_internal function addConnectionCallback(name:String, listener:Function):void { + addCallback(name, listener, "addConnectionCallback"); + } + + flow_internal function addStreamCallback(name:String, listener:Function):void { + addCallback(name, listener, "addStreamCallback"); + } + + private function addCallback(name:String, listener:Function, registerFuncName:String):void { + for each (var obj:Object in _providers) { + log.debug("provider" + obj); + var provider:StreamProvider = obj as StreamProvider; + provider[registerFuncName](name, listener); + } + } + + private function replacePlaylistAndPlay(clips:Object):void { + stop(); + if (clips is Clip) { + _playList.replaceClips(clips as Clip); + } else { + _playList.replaceClips2(clips as Array); + } + play(); + } + + flow_internal function addProvider(provider:ProviderModel):void { + PlayState.addProvider(provider); + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/PlayState.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/PlayState.as new file mode 100644 index 0000000000000000000000000000000000000000..102cbe9fc98c5bbd10b0e789fb3ae2a9aa438a72 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/PlayState.as @@ -0,0 +1,318 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import flash.utils.Dictionary; + + import org.flowplayer.config.Config; + import org.flowplayer.controller.MediaController; + import org.flowplayer.controller.MediaControllerFactory; + import org.flowplayer.controller.PlayListController; + import org.flowplayer.flow_internal; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipType; + import org.flowplayer.model.ClipEvent; + import org.flowplayer.model.ClipEventSupport; + import org.flowplayer.model.ClipEventType; + import org.flowplayer.model.Playlist; + import org.flowplayer.model.ProviderModel; + import org.flowplayer.model.State; + import org.flowplayer.model.Status; + import org.flowplayer.util.Assert; + import org.flowplayer.util.Log; + import org.flowplayer.view.PlayerEventDispatcher; + use namespace flow_internal; + + /** + * PlayStates are responsible for controlling the media playback of one clip. + * The states delegate to MediaControllers. PlayStates also dispatch PlayEvents. + * + * + * @author api + */ + internal class PlayState { + + protected var log:Log = new Log(this); + protected var playListController:PlayListController; + protected var playList:Playlist; + //private var screen:Screen; + + internal static var waitingState:PlayState; + internal static var endedState:EndedState; + internal static var playingState:PlayingState; + internal static var pausedState:PausedState; + internal static var bufferingState:BufferingState; + private static var _controllerFactory:MediaControllerFactory; + private var _stateCode:State; + private var _active:Boolean; + + internal static function initStates( + playList:Playlist, + playListController:PlayListController, + providers:Dictionary, + playerEventDispatcher:PlayerEventDispatcher, + config:Config, + loader:ResourceLoader):void { + + waitingState = new WaitingState(State.WAITING, playList, playListController, providers); + endedState = new EndedState(State.ENDED, playList, playListController, providers); + playingState = new PlayingState(State.PLAYING, playList, playListController, providers); + pausedState = new PausedState(State.PAUSED, playList, playListController, providers); + bufferingState = new BufferingState(State.BUFFERING, playList, playListController, providers); + playListController.setPlayState(waitingState); + if (!_controllerFactory) + _controllerFactory = new MediaControllerFactory(providers, playerEventDispatcher, config, loader); + } + + internal static function addProvider(provider:ProviderModel):void { + _controllerFactory.addProvider(provider); + } + + public function PlayState(stateCode:State, playList:Playlist, playListController:PlayListController, providers:Dictionary) { + this._stateCode = stateCode; + this.playList = playList; + playList.onPlaylistReplace(onPlaylistChanged); + playList.onClipAdd(onClipAdded); + this.playListController = playListController; + } + + internal final function set active(active:Boolean):void { + log.debug(" is active: " + active); + _active = active; + setEventListeners(playList, active); + } + + protected function setEventListeners(eventHelper:ClipEventSupport, add:Boolean = true):void { + // overridden in subclasses + } + + internal function get streamProvider():StreamProvider { + return _controllerFactory.getProvider(playList.current); + } + + internal function get state():State { + return _stateCode; + } + + internal function startBuffering():void { + log.debug("cannot start buffering in this state"); + } + + internal function stopBuffering():void { + log.debug("cannot stop buffering in this state"); + } + + internal function play():void { + log.debug("cannot start playing in this state"); + } + + internal function switchStream(netStreamPlayOptions:Object = null):void { + log.debug("cannot start playing in this state"); + } + + internal function stop(closeStreamAndConnection:Boolean = false, silent:Boolean = false):void { + log.debug("stop() called"); + + if (silent) { + getMediaController().onEvent(null, [closeStreamAndConnection]); + + if (closeStreamAndConnection && playList.current.parent != null) { + playList.setInStreamClip(null); + getMediaController().onEvent(null, [true]); + } + + } else { + if ( canOnEvent(ClipEventType.STOP, [closeStreamAndConnection]) ) + onEvent(ClipEventType.STOP, [closeStreamAndConnection]); + + if (closeStreamAndConnection && playList.current.parent != null) { + playList.setInStreamClip(null); + onEvent(ClipEventType.STOP, [true]); + } + } + } + + internal function close(silent:Boolean):void { + if (canOnEvent(ClipEventType.STOP, [true, silent])) { + changeState(waitingState); + onEvent(ClipEventType.STOP, [true, silent]); + } + } + + internal function pause():void { + log.debug("cannot pause in this state"); + } + + internal function resume():void { + log.debug("cannot resume in this state"); + } + + internal function seekTo(seconds:Number):void { + log.debug("cannot seek in this state"); + } + + internal function get muted():Boolean { + return _controllerFactory.getVolumeController().muted; + } + + internal function set muted(value:Boolean):void { + _controllerFactory.getVolumeController().muted = value; + } + + internal function set volume(volume:Number):void { + _controllerFactory.getVolumeController().volume = volume; + } + + internal function get volume():Number { + return _controllerFactory.getVolumeController().volume; + } + + internal function get status():Status { + var status:Status = getMediaController().getStatus(_stateCode); + return status; + } + + protected function canOnEvent(eventType:ClipEventType, params:Array = null, beforeEventInfo:Object = null):Boolean { + log.debug("canOnEvent() " + eventType.name + ", current clip " + playList.current); + Assert.notNull(eventType, "eventType must be non-null"); + if (playList.current.isNullClip) return false; + + if (eventType.isCancellable) { + log.debug("canOnEvent(): dispatching before event for " + eventType.name); + if (! playList.current.dispatchBeforeEvent(new ClipEvent(eventType, beforeEventInfo))) { + log.info("event default was prevented, will not execute a state change"); + return false; + } + } else { + log.debug("event is not cancellable, will not dispatch before event"); + } + return true; + } + + protected function onEvent(eventType:ClipEventType, params:Array = null):void { + log.debug("calling onEvent(" + eventType.name + ") on media controller "); + getMediaController().onEvent(eventType, params); + } + + protected function changeState(newState:PlayState):void { + if (playListController.getPlayState() != newState) { + playListController.setPlayState(newState); + } + } + + internal function getMediaController():MediaController { + var myclip:Clip = playList.current; + return _controllerFactory.getMediaController(myclip, playList); + } + + protected function removeOneShotClip(clip:Clip):void { + if (clip.isOneShot) { + log.debug("removing one shot child clip from the playlist"); + playList.removeChildClip(clip); + } + } + + protected function onClipDone(event:ClipEvent):void { + var defaultAction:Boolean = ! event.isDefaultPrevented(); + var clip:Clip = event.target as Clip; + log.info(this + " onClipDone " + clip); + clip.dispatchEvent(event); + + // check if this is still the active state after dispatching the event. The state might have changed if + // there is a JS onFinish listener (for example) that calls play() + if (! _active) { + log.debug("I'm not the active state any more, returning."); + return; + } + + if (clip.isMidroll) { + log.debug("midroll clip finished"); + stop(false, true); + playList.setInStreamClip(null); + changeState(pausedState); + playListController.resume(); + removeOneShotClip(clip); + return; + } + +// var isLastSplashImage:Boolean = clip.duration == 0 && clip.type == ClipType.IMAGE && ! playList.hasNext(); +// log.debug("isLastSplashImage ? "+ (isLastSplashImage?"true":"false")); + + if (playList.hasNext(false)) { + if (defaultAction) { + log.debug("onClipDone, moving to next clip"); + playListController.next(true, true, false); + } else { + stop(false, true); + changeState(waitingState); + } + } else { + // #111, check if this is a post roll image so we can rewind +// if (defaultAction && ! isLastSplashImage) { + if (defaultAction) { + log.debug("onClipDone(), calling stop(closeStream = false, silent = true)"); + stop(false, true); + changeState(waitingState); + } else { + playListController.rewind(); + } + } + } + + protected function onClipStop(event:ClipEvent):void { + log.debug("onClipStop"); + if (event.isDefaultPrevented()) { + log.debug("default was prevented"); + return; + } + + var clip:Clip = Clip(event.target); + + if (clip.isMidroll) { + log.debug("midroll clip finished"); + playList.setInStreamClip(null); + changeState(pausedState); + playListController.resume(); + } else { + changeState(waitingState); + } + removeOneShotClip(clip); + } + + private function onPlaylistChanged(event:ClipEvent):void { + setEventListeners(ClipEventSupport(event.info), false); + if (_active) { + setEventListeners(ClipEventSupport(event.target)); + } + } + + private function onClipAdded(event:ClipEvent):void { + if (_active) { + setEventListeners(ClipEventSupport(event.target)); + } + } + + protected function get playListReady():Boolean { + if (! playList.current || playList.current.isNullClip) { + log.debug("playlist has nos clips to play, returning"); + return false; + } + return true; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/PlayTimeTracker.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/PlayTimeTracker.as new file mode 100644 index 0000000000000000000000000000000000000000..fc71d291adb6bc23555893ec3836b9f6d6b3b867 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/PlayTimeTracker.as @@ -0,0 +1,160 @@ +package org.flowplayer.controller { + import org.flowplayer.model.ClipType; + import org.flowplayer.model.ClipEventType; + import org.flowplayer.model.Cuepoint; + import org.flowplayer.util.Log; + + import flash.events.TimerEvent; + import flash.utils.Timer; + import flash.events.EventDispatcher; + + import org.flowplayer.model.Clip;import flash.utils.getTimer; + + /** + * PlayTimeTracker is responsible of tracking the playhead time. It checks + * if the clip's whole duration has been played and notifies listeners when + * this happens. It's also responsible of firing cuepoints. + * + * @author Anssi + */ + internal class PlayTimeTracker extends EventDispatcher { + + private var log:Log = new Log(this); + private var _clip:Clip; + private var _startTime:int; + private var _timer:Timer; + private var _storedTime:int = 0; + private var _onLastSecondDispatched:Boolean; + private var _controller:MediaController; + + public function PlayTimeTracker(clip:Clip, controller:MediaController) { + _clip = clip; + _controller = controller; + } + + public function start():void { + if (_timer && _timer.running) + stop(); + _timer = new Timer(30); + _timer.addEventListener(TimerEvent.TIMER, checkProgress); + _startTime = getTimer(); + log.debug("started at time " + time); + _timer.start(); + _onLastSecondDispatched = false; + } + + public function stop():void { + if (!_timer) return; + _storedTime = time; + _timer.stop(); + log.debug("stopped at time " + _storedTime); + } + + public function set time(value:Number):void { + log.debug("setting time to " + value); + _storedTime = value; + _startTime = getTimer(); + } + + public function get time():Number { + if (! _timer) return 0; + + var timeNow:Number = getTimer(); + var _timePassed:Number = _storedTime + (timeNow - _startTime)/1000; + + if (_clip.type == ClipType.VIDEO || _clip.type == ClipType.API) { + // this is a sanity check that we have played at least one second + if (getTimer() - _startTime < 2000) { + return _timePassed; + } + return _controller.time; + } + + if (! _timer.running) return _storedTime; + return _timePassed; + } + + private function checkProgress(event:TimerEvent):void { + if (!_timer) { + log.debug("no timer running"); + return; + } + checkAndFireCuepoints(); + + if (_clip.live) return; + var timePassed:Number = time; + if (! _clip.duration) { + // The clip does not have a duration, wait a few seconds before stopping the _timer. + // Duration may become available once it's loaded from metadata. + if (timePassed > 5) { + log.debug("durationless clip, stopping duration tracking"); + _timer.stop(); + } + return; + } + if (completelyPlayed(_clip)) { + stop(); + log.info(this + " completely played, dispatching complete"); + log.info("clip.durationFromMetadata " + _clip.durationFromMetadata); + log.info("clip.duration " + _clip.duration); + dispatchEvent(new TimerEvent(TimerEvent.TIMER_COMPLETE)); + } + + if (! _onLastSecondDispatched && timePassed >= _clip.duration - 1) { + _clip.dispatch(ClipEventType.LAST_SECOND); + _onLastSecondDispatched = true; + } + } + + private function completelyPlayed(clip:Clip):Boolean { + + if (clip.durationFromMetadata > clip.duration) { + return time >= clip.duration; + } + return clip.duration - time < clip.endLimit; + } + + private function checkAndFireCuepoints():void { + var streamTime:Number = _controller.time; + var timeRounded:Number = Math.round(streamTime*10) * 100; +// log.debug("checkAndFireCuepoints, rounded stream time is " + timeRounded); + + // also get the points from previous rounds, just to make sure we are not skipping any + var points:Array = collectCuepoints(_clip, timeRounded); + + if (! points || points.length == 0) { + return; + } + for (var i:Number = 0; i < points.length; i++) { + var cue:Cuepoint = points[i]; + log.info("cuePointReached: " + cue); + if (! alreadyFired(cue)) { + log.debug("firing cuepoint with time " + cue.time); + _clip.dispatch(ClipEventType.CUEPOINT, cue); + cue.lastFireTime = getTimer(); + } else { + log.debug("this cuepoint already fired"); + } + } + } + + private function collectCuepoints(clip:Clip, timeRounded:Number):Array { + var result:Array = new Array(); + for (var i:Number = 5; i >= 0; i--) { + result = result.concat(clip.getCuepoints(timeRounded - i * 100)); + } + return result; + } + + private function alreadyFired(cue:Cuepoint):Boolean { + var lastFireTime:int = cue.lastFireTime; + if (lastFireTime == -1) return false; + return getTimer() - cue.lastFireTime < 2000; + } + + public function get durationReached():Boolean { + return _clip.duration > 0 && time >= _clip.duration; + } + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/PlayingState.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/PlayingState.as new file mode 100644 index 0000000000000000000000000000000000000000..fde19b668ee837878b062684ceb1002e340b2cdc --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/PlayingState.as @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import flash.utils.Dictionary; + + import org.flowplayer.flow_internal; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipEvent; + import org.flowplayer.model.ClipEventSupport; + import org.flowplayer.model.ClipEventType; + import org.flowplayer.model.Playlist; + import org.flowplayer.model.State; + + use namespace flow_internal; + /** + * @author api + */ + internal class PlayingState extends PlayState { + private var _inStreamTracker:InStreamTracker; + + public function PlayingState(stateCode:State, playlist:Playlist, playlistController:PlayListController, providers:Dictionary) { + super(stateCode, playlist, playlistController, providers); + _inStreamTracker = new InStreamTracker(playlistController); + playList.onStart(onStart, hasMidstreamClips); + playList.onResume(onResume, hasMidstreamClips); + } + + private function hasMidstreamClips(clip:Clip):Boolean { + var children:Array = clip.playlist; + if (children.length == 0) return false; + for (var i:int = 0; i < children.length; i++) { + if (Clip(children[i]).isMidroll) { + return true; + } + } + return false; + } + + internal override function play():void { + log.debug("play()"); + stop(); + bufferingState.nextStateAfterBufferFull = playingState; + + if (canOnEvent(ClipEventType.BEGIN, [false])) { + changeState(bufferingState); + playList.current.played = true; + onEvent(ClipEventType.BEGIN, [false]); + } + } + + internal override function switchStream(netStreamPlayOptions:Object = null):void { + log.debug("cannot start playing in this state"); + if ( canOnEvent(ClipEventType.SWITCH, [netStreamPlayOptions]) ) + onEvent(ClipEventType.SWITCH, [netStreamPlayOptions]); + } + + override protected function setEventListeners(eventSupport:ClipEventSupport, add:Boolean = true):void { + if (add) { + log.debug("adding event listeners"); + eventSupport.onPause(onPause); + eventSupport.onStop(onStop); + eventSupport.onFinish(onFinish); + eventSupport.onBeforeFinish(onClipDone); + eventSupport.onStop(onClipStop); + eventSupport.onSeek(onSeek, hasMidstreamClips); + eventSupport.onClipAdd(onClipAdd); + } else { + eventSupport.unbind(onPause); + eventSupport.unbind(onStop); + eventSupport.unbind(onFinish); + eventSupport.unbind(onClipDone, ClipEventType.FINISH, true); + eventSupport.unbind(onClipStop); + eventSupport.unbind(onSeek); + eventSupport.unbind(onClipAdd); + } + } + + private function onClipAdd(event:ClipEvent):void { + if (playList.current.playlist.length > 0) { + _inStreamTracker.start(); + } + } + + private function onStart(event:ClipEvent):void { + log.debug("onStart"); + _inStreamTracker.start(true); + } + + private function onResume(event:ClipEvent):void { + _inStreamTracker.start(); + } + + private function onPause(event:ClipEvent):void { + _inStreamTracker.stop(); + } + + private function onStop(event:ClipEvent):void { + _inStreamTracker.stop(); + playList.setInStreamClip(null); + } + + private function onFinish(event:ClipEvent):void { + _inStreamTracker.stop(); + removeOneShotClip(event.target as Clip); + } + + private function onSeek(event:ClipEvent):void { + _inStreamTracker.reset(); + _inStreamTracker.start(); + } + + internal override function stopBuffering():void { + log.debug("stopBuffering() called"); + stop(); + getMediaController().stopBuffering(); + } + + internal override function pause():void { + if (canOnEvent(ClipEventType.PAUSE)) { + + // with a live stream we need to stop + if (playList.current.live) { + stop(); + return; + } + + changeState(pausedState); + onEvent(ClipEventType.PAUSE); + } + } + + internal override function seekTo(seconds:Number):void { + if ( canOnEvent(ClipEventType.SEEK, [seconds], seconds) ) + onEvent(ClipEventType.SEEK, [seconds]); + } + + override protected function onClipStop(event:ClipEvent):void { + super.onClipStop(event); + var clip:Clip = event.target as Clip; + if (clip.isMidroll) { + _inStreamTracker.stop(); + _inStreamTracker.reset(); + } + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ProviderTypes.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ProviderTypes.as new file mode 100644 index 0000000000000000000000000000000000000000..313a7b580ddac81db16231fcde26207ad084638d --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ProviderTypes.as @@ -0,0 +1,9 @@ +package org.flowplayer.controller { + + public class ProviderTypes { + + public static const PSEUDO:String = "pseudo"; + public static const RTMP:String = "rtmp"; + public static const HTTP:String = "http"; + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ResourceLoader.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ResourceLoader.as new file mode 100644 index 0000000000000000000000000000000000000000..09aafb6af802b4a044b6b034277bcff013bd2388 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ResourceLoader.as @@ -0,0 +1,54 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + + /** + * Loader is to load different kinds of resources of the net. The URLs will + * be resolved relative to the embedding HTML page or to the player SWF. + * The urls are resolved relative to the player SWF when the player is + * in "embedded mode" (embedded outside of the hosting site). + * + * @author api + */ + public interface ResourceLoader { + + function addTextResourceUrl(url:String):void; + + function addBinaryResourceUrl(url:String):void; + + /** + * Clears the urls previously added. + */ + function clear():void; + + function set completeListener(listener:Function):void; + + /** + * Loads the specified url or from urls previously added. + */ + function load(url:String = null, completeListener:Function = null, isTextResource:Boolean = false):void; + + + function getContent(url:String = null):Object; + + function get loadComplete():Boolean; + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ResourceLoaderImpl.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ResourceLoaderImpl.as new file mode 100644 index 0000000000000000000000000000000000000000..65c5ed517aca21d7bfdcff9e24a79da17b170f47 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/ResourceLoaderImpl.as @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import flash.system.LoaderContext; + + import org.flowplayer.model.PlayerError; + import org.flowplayer.util.URLUtil; + + import flash.display.Loader; + import flash.events.Event; + import flash.events.EventDispatcher; + import flash.events.IOErrorEvent; + import flash.events.SecurityErrorEvent; + import flash.net.URLLoader; + import flash.net.URLRequest; + + import org.flowplayer.util.Log; + import org.flowplayer.view.ErrorHandler; + + /** + * @author api + */ + public class ResourceLoaderImpl implements ResourceLoader { + + private var log:Log = new Log(this); + private var _loaders:Object = new Object(); + private var _errorHandler:ErrorHandler; + private var _urls:Array = new Array(); + private var _loadedCount:Number; + private var _completeListener:Function; + private var _baseUrl:String; + private var _loadCompete:Boolean; + + public function ResourceLoaderImpl(baseURL:String, errorHandler:ErrorHandler = null) { + _baseUrl = baseURL; + _errorHandler = errorHandler; + } + + public function addTextResourceUrl(url:String):void { + _urls.push(url); + _loaders[url] = createURLLoader(); + } + + public function addBinaryResourceUrl(url:String):void { + _urls.push(url); + _loaders[url] = createLoader(); + } + + public function set completeListener(listener:Function):void { + _completeListener = listener; + } + + /** + * Starts loading. + * @param url the resource to be loaded, alternatively add the URLS using addUrl() before calling this + * @see #addTextResourceUrl() + * @see #addBinaryResourceUrl() + */ + public function load(url:String = null, completeListener:Function = null, isTextResource:Boolean = false):void { + if (completeListener != null) { + _completeListener = completeListener; + } + if (url) { + clear(); + if (isTextResource) { + log.debug("loading text resource from " + url); + addTextResourceUrl(url); + } else { + log.debug("loading binary resource from " + url); + addBinaryResourceUrl(url); + } + } + if (! _urls || _urls.length == 0) { + log.debug("nothing to load"); + return; + } + startLoading(); + } + + public function getContent(url:String = null):Object { + try { + var loader:Object = _loaders[url ? url : _urls[0]]; + return loader is URLLoader ? URLLoader(loader).data : loader; + } catch (e:SecurityError) { + handleError("cannot access file (try loosening Flash security settings): " + e.message); + } + return null; + } + + private function startLoading():void { + _loadedCount = 0; + _loadCompete = false; + for (var url:String in _loaders) { + log.debug("startLoading() " + URLUtil.addBaseURL(_baseUrl, url)); + if (_loaders[url] is URLLoader) { + _loaders[url].load(new URLRequest(URLUtil.addBaseURL(_baseUrl, url))); + } else { + var context:LoaderContext = new LoaderContext(); + // set the check policy flag in the loader context + context.checkPolicyFile=true; + Loader(_loaders[url]).load(new URLRequest(URLUtil.addBaseURL(_baseUrl, url)), context); + } + } + } + + private function createURLLoader():URLLoader { + var loader:URLLoader = new URLLoader(); + loader.addEventListener(Event.COMPLETE, onLoadComplete); + loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError); + loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError); + return loader; + } + + private function createLoader():Loader { + log.debug("creating new loader"); + var loader:Loader = new Loader(); + loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete); + loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError); + loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError); + return loader; + } + + private function onLoadComplete(event:Event):void { + log.debug("onLoadComplete, loaded " + (_loadedCount + 1) + " resources out of " + _urls.length); + if (++_loadedCount == _urls.length) { + _loadCompete = true; + log.debug("onLoadComplete, all resources were loaded"); + if (_completeListener != null) { + log.debug("calling complete listener function"); + _completeListener(this); + } + } + } + + private function onIOError(event:IOErrorEvent):void { + log.error("IOError: " + event.text); + handleError("Unable to load resources: " + event.text); + } + + private function onSecurityError(event:SecurityErrorEvent):void { + log.error("SecurityError: " + event.text); + handleError("cannot access the resource file (try loosening Flash security settings): " + event.text); + } + + protected function handleError(errorMessage:String, e:Error = null):void { + if (_errorHandler) { + _errorHandler.handleError(PlayerError.RESOURCE_LOAD_FAILED, errorMessage + (e ? ": " + e.message : "")); + } + } + + /** + * Sets the error handler. All load errors will be handled with the specified + * handler. + */ + public function set errorHandler(errorHandler:ErrorHandler):void { + _errorHandler = errorHandler; + } + + public function clear():void { + _urls = new Array(); + _loaders = new Array(); + } + + public function get loadComplete():Boolean { + return _loadCompete; + } + + public function get baseUrl():String { + return _baseUrl; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/StreamProvider.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/StreamProvider.as new file mode 100644 index 0000000000000000000000000000000000000000..ce6e962acfa540ffb35cd5281c6a7020dce4b3bb --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/StreamProvider.as @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import flash.net.NetConnection; + import flash.net.NetStream; + import flash.utils.Dictionary; + + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipEvent; + import org.flowplayer.model.Playlist; + + import flash.display.DisplayObject; + + /** + * StreamProviders are used to load video content into the player. They are used to + * integrate to different streaming servers and Content Delivery Networks (CDNs). + * + * Usually in the Flash platform providers are implemented using + * <a href="flash.net.NetStream">http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/NetStream.html</a>. + */ + public interface StreamProvider { + + /** + * Starts loading the specivied clip. Once video data is available the provider + * must set it to the clip using <code>clip.setContent()</code>. Typically the video + * object passed to the clip is an instance of <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/media/Video.html">flash.media.Video</a>. + * + * @param event the event that this provider should dispatch once loading has successfully started, + * once dispatched the player will call <code>getVideo()</code> + * @param clip the clip to load + * @param pauseAfterStart if <code>true</code> the playback is paused on first frame and + * buffering is continued + * @see Clip#setContent() + * @see #getVideo() + */ + function load(event:ClipEvent, clip:Clip, pauseAfterStart:Boolean = true):void; + + /** + * Gets the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/media/Video.html">Video</a> object. + * A stream will be attached to the returned video object using <code>attachStream()</code>. + * @param clip the clip for which the Video object is queried for + * @see #attachStream() + */ + function getVideo(clip:Clip):DisplayObject; + + /** + * Attaches a stream to the specified display object. + * @param video the video object that was originally retrieved using <code>getVideo()</code>. + * @see #getVideo() + */ + function attachStream(video:DisplayObject):void; + + /** + * Pauses playback. + * @param event the event that this provider should dispatch once loading has been successfully paused + */ + function pause(event:ClipEvent):void; + + /** + * Resumes playback. + * @param event the event that this provider should dispatch once loading has been successfully resumed + */ + function resume(event:ClipEvent):void; + + /** + * Stops and rewinds to the beginning of current clip. + * @param event the event that this provider should dispatch once loading has been successfully stopped + */ + function stop(event:ClipEvent, closeStream:Boolean = false):void; + + /** + * Seeks to the specified point in the timeline. + * @param event the event that this provider should dispatch once the seek is in target + * @param seconds the target point in the timeline + */ + function seek(event:ClipEvent, seconds:Number):void; + + /** + * File size in bytes. + */ + function get fileSize():Number; + + /** + * Current playhead time in seconds. + */ + function get time():Number; + + /** + * The point in timeline where the buffered data region begins, in seconds. + */ + function get bufferStart():Number; + + /** + * The point in timeline where the buffered data region ends, in seconds. + */ + function get bufferEnd():Number; + + /** + * Does this provider support random seeking to unbuffered areas in the timeline? + */ + function get allowRandomSeek():Boolean; + + /** + * Volume controller used to control the video volume. + */ + function set volumeController(controller:VolumeController):void; + + /** + * Stops loading data into the buffer. + */ + function stopBuffering():void; + + /** + * Is this provider in the process of stopping the stream? + * When stopped the provider should not dispatch any events resulting from events that + * might get triggered by the underlying streaming implementation. + */ + function get stopping():Boolean; + + /** + * The playlist instance. + */ + function set playlist(playlist:Playlist):void; + + function get playlist():Playlist; + + /** + * Adds a callback function to the NetConnection instance. This function will fire ClipEvents whenever + * the callback is invoked in the connection. + * @param name + * @param listener + * @return + * @see ClipEventType#CONNECTION_EVENT + */ + function addConnectionCallback(name:String, listener:Function):void; + + /** + * Adds a callback function to the NetStream object. This function will fire a ClipEvent of type StreamEvent whenever + * the callback has been invoked on the stream. The invokations typically come from a server-side app running + * on RTMP server. + * @param name + * @param listener + * @return + * @see ClipEventType.NETSTREAM_EVENT + */ + function addStreamCallback(name:String, listener:Function):void; + + /** + * Get the current stream callbacks. + * @return a dictionary of callbacks, keyed using callback names and values being the callback functions + */ + function get streamCallbacks():Dictionary; + + /** + * Gets the underlying NetStream object. + * @return the netStream currently in use, or null if this provider has not started streaming yet + */ + function get netStream():NetStream; + + /** + * Gets the underlying netConnection object. + * @return the netConnection currently in use, or null if this provider has not started streaming yet + */ + function get netConnection():NetConnection; + + + /** + * Sets a time provider to be used by this StreamProvider. Normally the playhead time is queried from + * the NetStream.time property. + * + * @param timeProvider + */ + function set timeProvider(timeProvider:TimeProvider):void; + + /** + * Gets the type of StreamProvider either http, rtmp, psuedo. + */ + function get type():String; + + /** + * Switch the stream in realtime with / without dynamic stream switching support + * + * @param event ClipEvent the clip event + * @param clip Clip the clip to switch to + * @param netStreamPlayOptions Object the NetStreamPlayOptions object to enable dynamic stream switching + */ + function switchStream(event:ClipEvent, clip:Clip, netStreamPlayOptions:Object = null):void; + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/StreamProviderController.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/StreamProviderController.as new file mode 100644 index 0000000000000000000000000000000000000000..7c675e0f2a18816172e136a0272305f2fc2c5ebd --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/StreamProviderController.as @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import org.flowplayer.config.Config; + import org.flowplayer.controller.AbstractDurationTrackingController; + import org.flowplayer.controller.MediaController; + import org.flowplayer.controller.StreamProvider; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipEvent; + import org.flowplayer.model.ClipEventType; + import org.flowplayer.model.ClipType; + import org.flowplayer.model.Playlist; + import org.flowplayer.util.Log; + + import flash.display.DisplayObject; + import flash.media.Video; + + /** + * Video controller is responsible for loading and showing video. + * It's also responsible for scaling and resizing the video screen. + * It receives the cuePoints and metaData from the loaded video data. + * + * @author anssi + */ + internal class StreamProviderController extends AbstractDurationTrackingController implements MediaController { + private var _config:Config; + private var _controllerFactory:MediaControllerFactory; +// private var _metadataDispatched:Boolean; + + public function StreamProviderController(controllerFactory:MediaControllerFactory, volumeController:VolumeController, config:Config, playlist:Playlist) { + super(volumeController, playlist); + _controllerFactory = controllerFactory; + _config = config; + var filter:Function = function(clip:Clip):Boolean { + //allow for chromeless swf video players to be added into the filter + return clip.type == ClipType.VIDEO || clip.type == ClipType.AUDIO || clip.type == ClipType.API; + }; + playlist.onBegin(onBegin, filter, true); + playlist.onBufferFull(onBegin, filter, true); + playlist.onStart(onBegin, filter, true); + } + + private function onBegin(event:ClipEvent):void { + var clip:Clip = event.target as Clip; + log.info("onBegin, initializing content for clip " + clip); + var video:DisplayObject = clip.getContent(); + if (video && video is Video) { + getProvider(clip).attachStream(video); + } else { + video = getProvider(clip).getVideo(clip); + if (video && video is Video) { + getProvider(clip).attachStream(video); + if (!video) throw new Error("No video object available for clip " + clip); + clip.setContent(video); + } else if (video) { + //we have a chromeless swf video player, add it's display object to the clip content + clip.setContent(video); + } + } + } + + override protected function doLoad(event:ClipEvent, clip:Clip, pauseAfterStart:Boolean = false):void { + getProvider().load(event, clip, pauseAfterStart); + } + + override protected function doPause(event:ClipEvent):void { + getProvider().pause(event); + } + + override protected function doResume(event:ClipEvent):void { + getProvider().resume(event); + } + + override protected function doStop(event:ClipEvent, closeStream:Boolean):void { + getProvider().stop(event, closeStream); + } + + override protected function doStopBuffering():void { + getProvider().stopBuffering(); + } + + override protected function doSeekTo(event:ClipEvent, seconds:Number):void { + durationTracker.time = seconds; + getProvider().seek(event, seconds); + } + + override protected function doSwitchStream(event:ClipEvent, clip:Clip, netStreamPlayOptions:Object = null):void { + var provider:StreamProvider = getProvider(); + provider.switchStream(event, clip, netStreamPlayOptions); + } + + public override function get time():Number { + return getProvider().time; + } + + override protected function get bufferStart():Number { + return getProvider().bufferStart; + } + + override protected function get bufferEnd():Number { + return getProvider().bufferEnd; + } + + override protected function get fileSize():Number { + return getProvider().fileSize; + } + + override protected function get allowRandomSeek():Boolean { + return getProvider().allowRandomSeek; + } + + override protected function onDurationReached():void { + // pause silently + if (clip.durationFromMetadata > clip.duration) { + getProvider().pause(null); + } + } + + public function getProvider(clipParam:Clip = null):StreamProvider { + if (!(clipParam || clip)) return null; + var provider:StreamProvider = _controllerFactory.getProvider(clipParam || clip); + provider.playlist = playlist; + return provider; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/TimeProvider.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/TimeProvider.as new file mode 100644 index 0000000000000000000000000000000000000000..eb7b5da9b2bf00600912d2efd86fa1eeb63f54ea --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/TimeProvider.as @@ -0,0 +1,19 @@ +/* + * Author: Anssi Piirainen, <api@iki.fi> + * + * Copyright (c) 2009-2011 Flowplayer Oy + * + * This file is part of Flowplayer. + * + * Flowplayer is licensed under the GPL v3 license with an + * Additional Term, see http://flowplayer.org/license_gpl.html + */ +package org.flowplayer.controller { + import flash.net.NetStream; + + public interface TimeProvider { + + function getTime(netStream:NetStream):Number; + + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/VolumeController.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/VolumeController.as new file mode 100644 index 0000000000000000000000000000000000000000..484c28e0419d5138ece4724b677f157e91f8e54b --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/VolumeController.as @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import org.flowplayer.flow_internal; + import org.flowplayer.model.PlayerEvent; + import org.flowplayer.util.Log; + import org.flowplayer.view.PlayerEventDispatcher; + + import flash.events.TimerEvent; + import flash.media.SoundChannel; + import flash.media.SoundTransform; + import flash.net.NetStream; + import flash.utils.Timer; + + use namespace flow_internal; + + /** + * @author api + */ + public class VolumeController { + + private var log:Log = new Log(this); + private var _soundTransform:SoundTransform; + private var _netStream:NetStream; + private var _storedVolume:VolumeStorage; + private var _storeDelayTimer:Timer; + private var _muted:Boolean; + private var _playerEventDispatcher:PlayerEventDispatcher; + private var _soundChannel:SoundChannel; + + public function VolumeController(playerEventDispatcher:PlayerEventDispatcher) { + _playerEventDispatcher = playerEventDispatcher; + _soundTransform = new SoundTransform(); + restoreVolume(); + _storeDelayTimer = new Timer(2000, 1); + _storeDelayTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerDelayComplete); + } + + public function set netStream(netStream:NetStream):void { + _netStream = netStream; + setTransform(_muted ? new SoundTransform(0) : _soundTransform); + } + + private function setTransform(transform:SoundTransform):void { + if (_netStream) { + _netStream.soundTransform = transform; + } + if (_soundChannel) { + _soundChannel.soundTransform = transform; + } + } + + private function doMute(persistMuteSetting:Boolean):void { + log.debug("muting volume"); + if (dispatchBeforeEvent(PlayerEvent.mute())) { + _muted = true; + setTransform(new SoundTransform(0)); + dispatchEvent(PlayerEvent.mute()); + if (persistMuteSetting) + storeVolume(true); + } + } + + private function unMute():Number { + log.debug("unmuting volume to level " + _soundTransform.volume); + if (dispatchBeforeEvent(PlayerEvent.unMute())) { + _muted = false; + setTransform(_soundTransform); + dispatchEvent(PlayerEvent.unMute()); + storeVolume(false); + } + return volume; + } + + public function set volume(volumePercentage:Number):void { + if (this.volume == volumePercentage) return; + if (dispatchBeforeEvent(PlayerEvent.volume(volumePercentage))) { + if (volumePercentage > 100) { + volumePercentage = 100; + } + if (volumePercentage < 0) { + volume = 0; + } + _soundTransform.volume = volumePercentage / 100; + if (!_muted) { + setTransform(_soundTransform); + } + dispatchEvent(PlayerEvent.volume(this.volume)); + if (!_storeDelayTimer.running) { + log.info("starting delay timer"); + _storeDelayTimer.start(); + } + } + } + + /** + * Gets the volume percentage. + */ + public function get volume():Number { + return _soundTransform.volume * 100; + } + + private function onTimerDelayComplete(event:TimerEvent):void { + storeVolume(); + } + + private function storeVolume(muted:Boolean = false):void { + log.info("persisting volume level"); + _storeDelayTimer.stop(); + _storedVolume.volume = _soundTransform.volume; + _storedVolume.muted = muted; + _storedVolume.persist(); + } + + private function restoreVolume():void { + _storedVolume = LocalSOVolumeStorage.create(); + + _soundTransform.volume = _storedVolume.volume; + if (_storedVolume.muted) + doMute(false); + } + + private function dispatchBeforeEvent(event:PlayerEvent):Boolean { + return _playerEventDispatcher.dispatchBeforeEvent(event); + } + + private function dispatchEvent(event:PlayerEvent):void { + _playerEventDispatcher.dispatchEvent(event); + } + + public function get muted():Boolean { + return _muted; + } + + public function set muted(muted:Boolean):void { + if (muted) { + doMute(true); + } else { + unMute(); + } + } + + public function set soundChannel(channel:SoundChannel):void { + _soundChannel = channel; + setTransform(_muted ? new SoundTransform(0) : _soundTransform); + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/VolumeStorage.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/VolumeStorage.as new file mode 100644 index 0000000000000000000000000000000000000000..9f0e0bf9904af8b8c67241957ce6cc1f5d9f6200 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/VolumeStorage.as @@ -0,0 +1,38 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + + /** + * @author api + */ + internal interface VolumeStorage { + + function set volume(value:Number):void; + + function get volume():Number; + + function set muted(value:Boolean):void; + + function get muted():Boolean; + + function persist():void; + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/WaitingState.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/WaitingState.as new file mode 100644 index 0000000000000000000000000000000000000000..354ee307234c937c8dddc2b98da184f1249487f5 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/controller/WaitingState.as @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.controller { + import org.flowplayer.model.Clip; +import org.flowplayer.model.ClipEventType; + + import flash.utils.Dictionary; + + import org.flowplayer.controller.PlayListController; + import org.flowplayer.model.ClipEvent; + import org.flowplayer.model.Playlist; + import org.flowplayer.model.State; + + /** + * @author api + */ + internal class WaitingState extends PlayState { + + public function WaitingState(stateCode:State, playList:Playlist, playListController:PlayListController, providers:Dictionary) { + super(stateCode, playList, playListController, providers); + } + + internal override function play():void { + log.debug("play()"); + if (! playListReady) return; + bufferingState.nextStateAfterBufferFull = playingState; + if (canOnEvent(ClipEventType.BEGIN, [false], false)) { + playList.current.played = true; + changeState(bufferingState); + onEvent(ClipEventType.BEGIN, [false]); + } + } + + internal override function stopBuffering():void { + log.debug("stopBuffering() called"); + getMediaController().stopBuffering(); + } + + override internal function stop(closeStreamAndConnection:Boolean = false, silent:Boolean = false):void { + log.debug("cannot stop in waiting state "); + } + + internal override function startBuffering():void { + if (! playListReady) return; + log.debug("startBuffering()"); + bufferingState.nextStateAfterBufferFull = pausedState; + if (canOnEvent(ClipEventType.BEGIN, [true], true)) { + changeState(bufferingState); + onEvent(ClipEventType.BEGIN, [true]); + } + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/flow_internal.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/flow_internal.as new file mode 100644 index 0000000000000000000000000000000000000000..c029782ca6c56679ebc9acf699d47be78172b4c3 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/flow_internal.as @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer { + + public namespace flow_internal = "http://flowplayer.org/core/internal"; + +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/AbstractConstraint.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/AbstractConstraint.as new file mode 100644 index 0000000000000000000000000000000000000000..ea46c31df4551857ba281fad927782a211a2e036 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/AbstractConstraint.as @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ +package org.flowplayer.layout { + import org.flowplayer.util.Arrange; + + import flash.display.StageDisplayState; + import flash.display.DisplayObject; + import flash.display.Stage; + import flash.events.EventDispatcher; + import flash.geom.Rectangle; + + import org.flowplayer.layout.Layout; + + internal class AbstractConstraint extends EventDispatcher { + + private var layout:Layout; + private var margins:Array; + private var view:DisplayObject; + + public function AbstractConstraint(view:DisplayObject, layout:Layout, margins:Array) { + this.layout = layout; + this.view = view; + this.margins = margins; + if (! this.margins) { + this.margins = new Array(); + } + } + + public function setMarginConstraint(margin:Number, constraint:Constraint):void { + margins[margin] = constraint; + } + + public function removeMarginConstraint(constraint:Constraint):void { + for (var i : Number = 0; i < margins.length; i++) { + if (margins[i] == constraint) + margins[i] = null; + } + } + + public function getConstrainedView():DisplayObject { + return view; + } + + public function getMarginConstraints():Array { + return margins; + } + + protected function getContainer():DisplayObject { + return layout.getContainer(); + } + + protected function getContainerWidth():Number { + return getContainer() is Stage ? Arrange.getStageWidth(getContainer() as Stage) : getContainer().width; + } + + protected function getContainerHeight():Number { + return getContainer() is Stage ? Arrange.getStageHeight(getContainer() as Stage) : getContainer().height; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/AbstractLayout.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/AbstractLayout.as new file mode 100644 index 0000000000000000000000000000000000000000..cfaceb70c7d333c0abeb66df8584cba50f85a5ea --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/AbstractLayout.as @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.layout { + import org.flowplayer.model.DisplayProperties; + + import flash.display.DisplayObject; + import flash.display.DisplayObjectContainer; + import flash.display.Stage; + import flash.events.Event; + import flash.events.EventDispatcher; + import flash.geom.Rectangle; + import flash.utils.Dictionary; + + import org.flowplayer.util.Log; + + /** + * @author anssi + */ + internal class AbstractLayout extends EventDispatcher implements Layout { + + private var log:Log = new Log(this); + private var _container:DisplayObjectContainer; + private var _constraints:Dictionary = new Dictionary(); + private var _listeners:Dictionary = new Dictionary(); + + public function AbstractLayout(container:DisplayObjectContainer) { + this._container = container; + if (container is Stage) + container.addEventListener(Event.RESIZE, onContainerResize); + } + + private function onContainerResize(event:Event):void { + draw(); + } + + public function draw(disp:DisplayObject = null):void { + log.info("redrawing layout"); + if (disp) { + var listenerFunc:Function = _listeners[disp]; + if (listenerFunc != null) { + listenerFunc(new LayoutEvent(LayoutEvent.RESIZE, this)); + } + } else { + dispatchEvent(new LayoutEvent(LayoutEvent.RESIZE, this)); + } + } + + + public function addConstraint(constraint:Constraint, listenerFunc:Function = null):void { + _constraints[constraint.getConstrainedView()] = constraint; + if (listenerFunc != null) { + _listeners[constraint.getConstrainedView()] = listenerFunc; + this.addEventListener(LayoutEvent.RESIZE, listenerFunc); + } + } + + public function getConstraint(view:DisplayObject):Constraint { + return _constraints[view]; + } + + public function removeView(view:DisplayObject):void { + if (_listeners[view]) { + this.removeEventListener(LayoutEvent.RESIZE, _listeners[view]); + } + delete _listeners[view]; + delete _constraints[view]; + } + + public function getContainer():DisplayObject { + return _container; + } + + public function getBounds(view:Object):Rectangle { + var constraint:Constraint = _constraints[view]; + if (! constraint) return null; + return constraint.getBounds(); + } + + protected function get constraints():Dictionary { + return _constraints; + } + + protected function get listeners():Dictionary { + return _listeners; + } + + public function addView(view:DisplayObject, listener:Function, properties:DisplayProperties):void { + } + + public function update(view:DisplayObject, properties:DisplayProperties):Rectangle { + return null; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/Constraint.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/Constraint.as new file mode 100644 index 0000000000000000000000000000000000000000..ce806ad0f91118649b7243598897cbe1229f5abc --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/Constraint.as @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ +package org.flowplayer.layout { + import flash.display.DisplayObject; + import flash.geom.Rectangle; + + public interface Constraint { + + function getConstrainedView():DisplayObject; + + function getBounds():Rectangle; + + function getMarginConstraints():Array; + + function setMarginConstraint(margin:Number, constraint:Constraint):void; + + function removeMarginConstraint(constraint:Constraint):void; + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/Dimensions.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/Dimensions.as new file mode 100644 index 0000000000000000000000000000000000000000..d55e3bc91f8e198d59632ba452aad484d3897834 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/Dimensions.as @@ -0,0 +1,87 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.layout { + import flash.display.DisplayObject; + + import org.flowplayer.model.Cloneable; + import org.flowplayer.util.Arrange; + + /** + * @author api + */ + public class Dimensions implements Cloneable { + + private var _width:Length = new Length(); + private var _height:Length = new Length(); + + public function clone():Cloneable { + var clone:Dimensions = new Dimensions(); + clone._width = _width.clone() as Length; + clone._height = _height.clone() as Length; + return clone; + } + + public function get width():Length { + return _width; + } + + public function set widthValue(width:Object):void { + if (width is Length) { + _width = width as Length; + } else { + _width.value = width; + } + } + + public function get height():Length { + return _height; + } + + public function set heightValue(height:Object):void { + if (height is Length) { + _height = height as Length; + } else { + _height.value = height; + } + } + + public function fillValues(container:DisplayObject):void { + if (_width.px >= 0) + _width.pct = _width.px / Arrange.getWidth(container) * 100; + else if (_width.pct >= 0) + _width.px = width.pct/100 * Arrange.getWidth(container); + + if (_height.px >= 0) + _height.pct = _height.px / Arrange.getHeight(container) * 100; + else if (_height.pct >= 0) + _height.px = height.pct/100 * Arrange.getHeight(container); + } + + public function toString():String { + return "(" + _width + ") x (" + _height + ")"; + } + + public function hasValue(property:String):Boolean { + if (property == "width") return _width.hasValue(); + if (property == "height") return _height.hasValue(); + return false; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/DrawWrapper.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/DrawWrapper.as new file mode 100644 index 0000000000000000000000000000000000000000..ba934659956839c0c024b571cb230d12b609efdd --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/DrawWrapper.as @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.layout { + import org.flowplayer.view.AbstractSprite; + import org.flowplayer.util.Log; + + import flash.display.DisplayObject; + import flash.geom.Rectangle; + + /** + * @author api + */ + public class DrawWrapper { + + private var view:DisplayObject; + private var log:Log = new Log(this); + + public function DrawWrapper(view:DisplayObject) { + this.view = view; + } + + public function draw(event:LayoutEvent):void { + var bounds:Rectangle = event.layout.getBounds(view); + if (bounds == null) { + log.warn("Did not get bounds for view " + view); + return; + } + log.debug("got bounds " + bounds + " for view " + view); + view.x = bounds.x; + view.y = bounds.y; + if (view is AbstractSprite) { + AbstractSprite(view).setSize(bounds.width, bounds.height); + } else { + view.width = bounds.width; + view.height = bounds.height; + } + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/FixedContraint.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/FixedContraint.as new file mode 100644 index 0000000000000000000000000000000000000000..76215e43e9481110388ae6af83eb762e1f320274 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/FixedContraint.as @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.layout { + import flash.display.DisplayObject; + import flash.geom.Rectangle; + + import org.flowplayer.layout.Constraint; + + /** + * @author anssi + */ + internal class FixedContraint implements Constraint { + + private var length:Number; + + public function FixedContraint(length:Number) { + this.length = length; + } + + public function getBounds():Rectangle { + return new Rectangle(0, 0, length, length); + } + + public function getConstrainedView():DisplayObject { + return null; + } + + public function getMarginConstraints():Array { + return null; + } + + public function setMarginConstraint(margin:Number, constraint:Constraint):void { + } + + public function removeMarginConstraint(constraint:Constraint):void { + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/Layout.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/Layout.as new file mode 100644 index 0000000000000000000000000000000000000000..55c6a88dcade3b504025d3a0beeea1e006575d45 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/Layout.as @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ +package org.flowplayer.layout { + import org.flowplayer.model.DisplayProperties; + + import flash.display.DisplayObject; + import flash.geom.Rectangle; + + public interface Layout { + + function addView(view:DisplayObject, listener:Function, properties:DisplayProperties):void; + + function update(view:DisplayObject, properties:DisplayProperties):Rectangle; + + function removeView(view:DisplayObject):void; + + function getContainer():DisplayObject; + + function getBounds(view:Object):Rectangle; + + function draw(disp:DisplayObject = null):void; + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/LayoutEvent.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/LayoutEvent.as new file mode 100644 index 0000000000000000000000000000000000000000..e26b175404a57a61dd170b869c036c9edcf6223f --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/LayoutEvent.as @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.layout { + import flash.events.Event; + + /** + * @author anssi + */ + public class LayoutEvent extends Event { + + public static const RESIZE:String = "resize"; + public var layout:Layout; + + public function LayoutEvent(type:String, layout:Layout, bubbles:Boolean = false, cancelable:Boolean = true) { + super(type, bubbles, cancelable); + this.layout = layout; + } + + public override function clone():Event { + return new LayoutEvent(type, layout, bubbles, cancelable); + } + + public override function toString():String { + return formatToString("ResizeEvent", "type", "layout", "bubbles", "cancelable", "eventPhase"); + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/Length.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/Length.as new file mode 100644 index 0000000000000000000000000000000000000000..2d8eaee1ccaa28cf97d95f6151449fcda53ba63f --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/Length.as @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.layout { + import org.flowplayer.util.Log; + import org.flowplayer.model.Cloneable; + import org.flowplayer.util.NumberUtil; + + /** + * @author api + */ + public class Length implements Cloneable { + private var log:Log = new Log(this); + private var _px:Number; + private var _pct:Number; + private var _clearPct:Boolean; + + public function Length(value:Object = null) { + _px = NaN; + _pct = NaN; + if (value || (value is Number && Number(value) == 0)) { + setValue(value); + } + } + + public function clone():Cloneable { + var clone:Length = new Length(); + clone._pct = _pct; + clone._px = _px; + return clone; + } + + public function set value(value:Object):void { + setValue(value); + } + + public function clear():void { + _px = NaN; + _pct = NaN; + } + + public function setValue(valueObject:Object):void { + if (valueObject && valueObject is String) { + var valStr:String = valueObject as String; + _pct = NumberUtil.decodePercentage(valStr); + _px = NumberUtil.decodePixels(valStr); + } else { + _px = valueObject as Number; + _pct = NaN; + } + } + + public function plus(other:Length, toPxFunc:Function, toPctFunc:Function):Length { + log.debug(this + " plus() " + other); + var result:Length = new Length(); + if (_px >= 0 && ! isNaN(other.px)) { + result.px = _px + other.px; + } + if (_pct >= 0 && ! isNaN(other.pct)) { + result.pct = _pct + other._pct; + } + if (_px >= 0 && ! isNaN(other.pct)) { + result.px = toPxFunc(toPctFunc(_px) + other.pct); + } + if (_pct >= 0 && ! isNaN(other.px)) { + result.pct = toPctFunc(toPxFunc(_pct) + other.px); + } + log.debug("plus(), result is " + result); + return result; + } + + public function hasValue():Boolean { + return _px >= 0 || _pct>= 0; + } + + public function get px():Number { + return _px; + } + + public function set px(px:Number):void { + _px = px; + } + + public function get pct():Number { + return _pct; + } + + public function set pct(pct:Number):void { + _pct = pct; + } + + public function asObject():Object { + if (_px >= 0) return _px; + if (_pct >= 0) return _pct + "%"; + return undefined; + } + + public function toString():String { + return "[Dimension] " + _px + "px -- " + _pct + "%"; + } + + public function toPx(containerLength:Number):Number { + if (_pct >= 0) return containerLength * _pct / 100; + if (_px >= 0) return _px; + return undefined; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/LengthMath.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/LengthMath.as new file mode 100644 index 0000000000000000000000000000000000000000..18c197e1bb181084d58169da37845ccbfef73138 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/LengthMath.as @@ -0,0 +1,150 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.layout { + import org.flowplayer.util.Log; + import org.flowplayer.util.Arrange; + + import flash.display.DisplayObject; + + import org.flowplayer.model.DisplayProperties; + + import com.adobe.utils.StringUtil; + + /** + * @author api + */ + public class LengthMath { + private static const log:Log = new Log("org.flowplayer.layout::LengthMath"); + + public static function sum(props:DisplayProperties, valuesToAdd:Object, container:DisplayObject):DisplayProperties { + var containerWidth:Number = Arrange.getWidth(container); + var containerHeight:Number = Arrange.getHeight(container); + + addValue(props, valuesToAdd, "alpha"); + addValue(props, valuesToAdd, "opacity"); + addValue(props, valuesToAdd, "display"); + addValue(props, valuesToAdd, "visible"); + addValue(props, valuesToAdd, "zIndex"); + + addDimension("width", props, valuesToAdd, dimToPx(containerWidth), dimToPct(containerWidth)); + addDimension("height", props, valuesToAdd, dimToPx(containerHeight), dimToPct(containerHeight)); + log.debug("sum(): result dimensions " + props.dimensions); + + log.debug("sum(), current position " + props.position); + var height:Number = props.dimensions.height.toPx(containerHeight); + if (hasValue(valuesToAdd, "top")) { + props.position.toTop(containerHeight, height); + addPosition("top", props, valuesToAdd, height, posToPx(height, containerHeight), posToPct(height, containerHeight)); + + } else if (hasValue(valuesToAdd, "bottom")) { + props.position.toBottom(containerHeight, height); + addPosition("bottom", props, valuesToAdd, height, posToPx(height, containerHeight), posToPct(height, containerHeight)); + } + + var width:Number = props.dimensions.width.toPx(containerWidth); + if (hasValue(valuesToAdd, "left")) { + log.debug("adding to left"); + props.position.toLeft(containerWidth, width); + addPosition("left", props, valuesToAdd, width, posToPx(width, containerWidth), posToPct(width, containerWidth)); + + } if (hasValue(valuesToAdd, "right")) { + props.position.toRight(containerWidth, width); + addPosition("right", props, valuesToAdd, width, posToPx(width, containerWidth), posToPct(width, containerWidth)); + } + log.debug("sum(): result position " + props.position); + return props; + } + + private static function addValue(props:DisplayProperties, valuesToAdd:Object, prop:String):void { + if (! valuesToAdd) return; + if (! props) return; + if (! containsValue(valuesToAdd[prop])) return; + props[prop] = valuesToAdd[prop]; + } + + private static function addDimension(dimProp:String, to:DisplayProperties, valuesToAdd:Object, widthToPxFunc:Function, widthToPctFunc:Function):void { + var width:Object = valuesToAdd[dimProp]; + if (! containsValue(width)) return; + if (incremental(width)) { + to[dimProp] = to.dimensions[dimProp].plus(new Length(width), widthToPxFunc, widthToPctFunc); + log.debug("new dimension is " + to.dimensions[dimProp]); + } else { + to[dimProp] = width; + } + } + + private static function addPosition(posProp:String, to:DisplayProperties, valuesToAdd:Object, height:Number, toPxFunc:Function, toPctFunc:Function):void { + var top:Object = valuesToAdd[posProp]; + if (incremental(top)) { + log.debug("adding incremental position value " + top); + var pos:Length = to.position[posProp].plus(new Length(top), toPxFunc, toPctFunc); + if (pos.px < 0) { + pos.px = 0; + } + to[posProp] = pos; + } else { + to[posProp] = top; + } + } + + private static function posToPct(dim:Number, containerDim:Number):Function { + return function(px:Number):Number { + return ((px + dim/2) / containerDim) * 100; + }; + } + + private static function posToPx(dim:Number, containerDim:Number):Function { + return function(pct:Number):Number { + return pct/100 * containerDim - dim/2; + }; + } + + private static function dimToPct(containerDim:Number):Function { + return function(px:Number):Number { + return px / containerDim * 100; + }; + } + + private static function dimToPx(containerDim:Number):Function { + return function(pct:Number):Number { + return containerDim * pct / 100; + }; + } + + private static function incremental(width:Object):Boolean { + if (! width is String) return false; + var result:Boolean = StringUtil.beginsWith(String(width), "+") || StringUtil.beginsWith(String(width), "-"); + log.debug("incremental? " + width + ", " + result); + return result; + } + + private static function hasValue(valueObj:Object, prop:String):Boolean { + return containsValue(valueObj[prop]); + } + + private static function containsValue(val:Object):Boolean { + if (val is String) return true; + if (val is Boolean) return true; + var result:Boolean = val is Number && ! isNaN(val as Number); + log.debug("hasValue? " + val + ", " + result); + return result; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/MarginConstraint.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/MarginConstraint.as new file mode 100644 index 0000000000000000000000000000000000000000..33e5c678a51e8b5b3674dd36c3a895ccbfcdcabe --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/MarginConstraint.as @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.layout { + import org.flowplayer.util.Log; + import org.flowplayer.layout.Constraint; + + import flash.display.DisplayObject; + import flash.geom.Rectangle; + + import org.flowplayer.layout.AbstractConstraint; + import org.flowplayer.layout.Layout; + + /** + * @author anssi + */ + internal class MarginConstraint extends AbstractConstraint implements Constraint { + private var log:Log = new Log(this); + // TODO: percentage dimensions + private var _dimensions:Dimensions; + + public function MarginConstraint(view:DisplayObject, layout:Layout, margins:Array, dimensions:Dimensions) { + super(view, layout, margins); + _dimensions = dimensions; + } + + public function getBounds():Rectangle { + return new Rectangle(getLeftMargin(), getTopMargin(), getWidth(), getHeight()); + } + + private function getWidth():Number { + return _dimensions.width.toPx(getContainerWidth()) || getContainerWidth() - getLeftMargin() - getRightMargin(); + } + + private function getHeight():Number { + return _dimensions.height.toPx(getContainerHeight()) || getContainerHeight() - getTopMargin() - getBottomMargin(); + } + + protected function getTopMargin():Number { + return getMargin(0, 2, "height", getContainerHeight()); + } + + protected function getRightMargin():Number { + return getMargin(1, 3, "width", getContainerWidth()); + } + + protected function getBottomMargin():Number { + return getMargin(2, 0, "height", getContainerHeight()); + } + + protected function getLeftMargin():Number { + return getMargin(3, 1, "width", getContainerWidth()); + } + + private function getMargin(margin:Number, otherMargin:Number, dimensionProp:String, containerLength:Number):Number { + log.debug(getConstrainedView() + ", getMargin() " + margin); + var constraint:Constraint = getMarginConstraints()[margin]; + if (! constraint) { + // if we have the opposite constraint, that will rule now + var oppositeConstraint:Constraint = getMarginConstraints()[otherMargin]; + + var length:Number = _dimensions[dimensionProp].toPx(containerLength); + if (!oppositeConstraint) + throw new Error(getConstrainedView() + ": not enough info to place object on Panel. Need top|bottom and left|right display properties."); + + + var result:Number = oppositeConstraint ? containerLength - length - oppositeConstraint.getBounds()[dimensionProp] : 0; +// log.debug(getConstrainedView() + ": " + dimensionProp + ": " + length + ": getMargin(), margin " +margin+ " using opposite constraint " + otherMargin + " is " + result); + return result; + } else { + log.debug(getConstrainedView() + ": getMargin(), constraint at margin " + margin + ": " + constraint + ", returns value " + constraint.getBounds()[dimensionProp]); + return constraint.getBounds()[dimensionProp]; + } + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/MarginLayout.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/MarginLayout.as new file mode 100644 index 0000000000000000000000000000000000000000..1815d6fb0110d3f42c5e3256a9f9b1c7cfddbe79 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/MarginLayout.as @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.layout { + import org.flowplayer.model.DisplayProperties; + + import flash.display.DisplayObject; + import flash.display.DisplayObjectContainer; + import flash.display.Stage; + import flash.geom.Rectangle; + + import org.flowplayer.layout.AbstractLayout; + import org.flowplayer.layout.Constraint; + import org.flowplayer.layout.Layout; + import org.flowplayer.util.Log; + + /** + * @author anssi + */ + public class MarginLayout extends AbstractLayout implements Layout { + + private var log:Log = new Log(this); + + public function MarginLayout(container:DisplayObjectContainer) { + super(container); + } + + public override function addView(view:DisplayObject, listener:Function, properties:DisplayProperties):void { + log.debug("addView, name " + properties.name + ", position " + properties.position); + var constraint:MarginConstraint = new MarginConstraint(view, this, null, properties.dimensions); + initConstraint(view, constraint, properties); + addConstraint(constraint, listener); +// log.info("added view " +view+ " to panel " + constraint.getBounds()); + draw(view); + } + + public override function update(view:DisplayObject, properties:DisplayProperties):Rectangle { +// log.debug("update, margins " + margins); + var constraint:MarginConstraint = new MarginConstraint(view, this, null, properties.dimensions); + initConstraint(view, constraint, properties); + addConstraint(constraint); +// log.info("updated view " +view+ " to position " + constraint.getBounds()); + return constraint.getBounds(); + } + + private function initConstraint(view:DisplayObject, constraint:MarginConstraint, properties:DisplayProperties):void { + if (properties.position) { + for (var i : Number = 0; i < 4; i++) { + var margin:Constraint = getMarginConstraint(view, i, properties); + if (margin) + constraint.setMarginConstraint(i, margin); + } + } + } + + private function getMarginConstraint(view:DisplayObject, i:Number, properties:DisplayProperties):Constraint { + var position:Position = properties.position; + if (i == 0) { + if (position.top.pct >= 0) return new RelativeConstraint(view, properties.dimensions.height, getContainer(), position.top.pct, "height"); + if (position.top.px >= 0) return new FixedContraint(position.top.px); + } + if (i == 1) { + if (position.right.pct >= 0) return new RelativeConstraint(view, properties.dimensions.width, getContainer(), position.right.pct, "width"); + if (position.right.px >= 0) return new FixedContraint(position.right.px); + } + if (i == 2) { + if (position.bottom.pct >= 0) return new RelativeConstraint(view, properties.dimensions.height, getContainer(), position.bottom.pct, "height"); + if (position.bottom.px >= 0) return new FixedContraint(position.bottom.px); + } + if (i == 3) { + if (position.left.pct >= 0) return new RelativeConstraint(view, properties.dimensions.width, getContainer(), position.left.pct, "width"); + if (position.left.px >= 0) return new FixedContraint(position.left.px); + } + return null; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/Position.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/Position.as new file mode 100644 index 0000000000000000000000000000000000000000..08687e10e5288b0097809269b0e2ce2b09e0081c --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/Position.as @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.layout { + import org.flowplayer.util.Log; + import org.flowplayer.util.Arrange; + + import flash.display.DisplayObject; + + /** + * @author api + */ + public class Position { + private var log:Log = new Log(this); + private var _top:Length = new Length(); + private var _right:Length = new Length(); + private var _bottom:Length = new Length(); + private var _left:Length = new Length(); + + public function set topValue(top:Object):void { + setValue("_top", top); + } + + public function get top():Length { + return _top; + } + + private function setValue(property:String, value:Object):void { + if (value is Length) { + this[property] = value; + log.debug(property + " set to " + value); + } else { + Length(this[property]).value = value; + } + Length(this[getOtherProperty(property)]).clear(); + } + + private function getOtherProperty(property:String):String { + if (property == "_top") return "_bottom"; + if (property == "_bottom") return "_top"; + if (property == "_left") return "_right"; + if (property == "_right") return "_left"; + throw new Error("Trying to set unknown property " + property); + } + + public function set rightValue(value:Object):void { + setValue("_right", value); + } + + public function get right():Length { + return _right; + } + + public function set bottomValue(value:Object):void { + setValue("_bottom", value); + } + + public function get bottom():Length { + return _bottom; + } + + public function set leftValue(value:Object):void { + setValue("_left", value); + } + + public function get left():Length { + return _left; + } + + public function set values(value:Array):void { + setValue("_top", value[0]); + setValue("_right", value[1]); + setValue("_bottom", value[2]); + setValue("_left", value[3]); + } + + public function get values():Array { + return [ _top.asObject(), _right.asObject(), _bottom.asObject(), _left.asObject() ]; + } + + public function clone():Position { + var clone:Position = new Position(); + clone._top = _top.clone() as Length; + clone._right = _right.clone() as Length; + clone._bottom = _bottom.clone() as Length; + clone._left = _left.clone() as Length; + return clone; + } + + public function toString():String { + return "[Margins] left: " + _left + ", righ " + _right + ", top " + _top + ", bottom " + _bottom; + } + + public function hasValue(property:String):Boolean { + if (property == "top") return _top.hasValue(); + if (property == "right") return _right.hasValue(); + if (property == "bottom") return _bottom.hasValue(); + if (property == "left") return _left.hasValue(); + return false; + } + + public function toLeft(containerWidth:Number, width:Number):void { + if (_left.hasValue()) return; + if (_right.pct >= 0) { + _left.pct = 100 - _right.pct; + } + if (_right.px > 0) { + _left.px = containerWidth - width - _right.px; + } + _right.clear(); + } + + public function toRight(containerWidth:Number, width:Number):void { + if (_right.hasValue()) return; + if (_left.pct >= 0) { + _right.pct = 100 - _left.pct; + } + if (_left.px > 0) { + _right.px = containerWidth - width - _left.px; + } + _left.clear(); + } + + public function toTop(containerHeight:Number, height:Number):void { + if (_top.hasValue()) return; + if (_bottom.pct >= 0) { + _top.pct = 100 - _bottom.pct; + } + if (_bottom.px > 0) { + _top.px = containerHeight - height - _bottom.px; + } + _bottom.clear(); + } + + public function toBottom(containerHeight:Number, height:Number):void { + if (_bottom.hasValue()) return; + if (_top.pct >= 0) { + _bottom.pct = 100 - _top.pct; + } + if (_top.px > 0) { + _bottom.px = containerHeight - height - _top.px; + } + _top.clear(); + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/RelativeConstraint.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/RelativeConstraint.as new file mode 100644 index 0000000000000000000000000000000000000000..ddab067f2fe17ac91e6de01a282518dd7fd272af --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/layout/RelativeConstraint.as @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.layout { + import org.flowplayer.util.Arrange; + + import flash.display.DisplayObject; + import flash.display.Stage; + import flash.geom.Rectangle; + + import org.flowplayer.layout.Constraint; + import org.flowplayer.util.Log; + + /** + * @author api + */ + internal class RelativeConstraint implements Constraint { + + private var log:Log = new Log(this); + private var _view:DisplayObject; + private var _reference:DisplayObject; + private var _marginPercentage:Number; + private var _viewProperty:String; + private var _length:Length; + + public function RelativeConstraint(view:DisplayObject, length:Length, reference:DisplayObject, marginPercentage:Number, viewProperty:String) { + _view = view; + _length = length; + _reference = reference; + _marginPercentage = marginPercentage; + _viewProperty = viewProperty; + } + + public function getConstrainedView():DisplayObject { + return null; + } + + public function getBounds():Rectangle { + var viewLength:Number = getViewLength(); + var length:Number = getReferenceLength() * _marginPercentage/100 - viewLength/2; + return new Rectangle(0, 0, length, length); + } + + private function getReferenceLength():Number { + return _viewProperty == "width" ? Arrange.getWidth(_reference) : Arrange.getHeight(_reference); + } + + private function getViewLength():Number { + if (_length.pct >= 0) { + var result:Number = getReferenceLength() * _length.pct / 100; + log.debug("relative length " + _length.pct + "% out of " +getReferenceLength() + " is " + result); + return result; + } + if (_length.px >= 0) return _length.px; + return _view[_viewProperty]; + } + + public function getMarginConstraints():Array { + return null; + } + + public function setMarginConstraint(margin:Number, constraint:Constraint):void { + } + + public function removeMarginConstraint(constraint:Constraint):void { + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/AbstractEvent.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/AbstractEvent.as new file mode 100644 index 0000000000000000000000000000000000000000..cbf1e43fec12aaccbbd024b6f382cec98165eca6 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/AbstractEvent.as @@ -0,0 +1,179 @@ +package org.flowplayer.model { + import flash.events.Event; + import flash.external.ExternalInterface; + +import flash.utils.getQualifiedClassName; + import mx.utils.object_proxy; +import org.flowplayer.flow_internal; + import org.flowplayer.util.Log; +import org.flowplayer.util.ObjectConverter; + + + + + + + + + + + + use namespace flow_internal; + /** + * @author anssi + */ + public class AbstractEvent extends Event { + protected var log:Log = new Log(this); + private var _info:Object; + private var _info2:Object; + private var _info3:Object; + private var _info4:Object; + private var _info5:Object; + private var _eventType:EventType; + private var _target:Object; + private var _propagationStopped:Boolean; + private var _isDefaultPrevented:Boolean; + + public function AbstractEvent(eventType:EventType, info:Object = null, info2:Object = null, info3:Object = null, info4:Object = null, info5:Object = null) { + super(eventType.name); + this._eventType = eventType; + this._info = info; + this._info2 = info2; + this._info3 = info3; + this._info4 = info4; + this._info5 = info5; + _target = target; + log.debug(_info + ", " + _info2 + ", " + _info3 + ", " + _info4 + ", " + _info5); + } + + public function get error():ErrorCode { + return _info as ErrorCode; + } + + public function isCancellable():Boolean { + return _eventType.isCancellable; + } + + public override function clone():Event { + return new AbstractEvent(_eventType, _info); + } + + public override function toString():String { + return formatToString("AbstractEvent", "type", "target", "info", "info2", "info3", "info4", "info5"); + } + + public function get info():Object { + return _info; + } + + override public function get target():Object { + if (_target) return _target; + return super.target; + } + + public function set target(target:Object):void { + _target = target; + } + + public function get eventType():EventType { + return _eventType; + } + + override public function stopPropagation():void { + _propagationStopped = true; + } + + override public function stopImmediatePropagation():void { + _propagationStopped = true; + } + + public function isPropagationStopped():Boolean { + return _propagationStopped; + } + + flow_internal function fireErrorExternal(playerId:String):void { + try { + ExternalInterface.call( + "flowplayer.fireEvent", + playerId || ExternalInterface.objectID, getExternalName(eventType.name, false), ErrorCode(_info).code, ErrorCode(_info).message + info2 ? ": " + info2 : ""); + } catch (e:Error) { + log.error("Error in fireErrorExternal() "+ e); + } + } + + flow_internal function fireExternal(playerId:String, beforePhase:Boolean = false):Boolean { + log.debug("fireExternal " + getExternalName(eventType.name, beforePhase) + ", " + externalEventArgument + ", " + externalEventArgument2 + ", " + externalEventArgument3 + "," + externalEventArgument4 + ", " + externalEventArgument5); + if (!ExternalInterface.available) return true; + // NOTE: externalEventArgument3 is not converted! + try { + var returnVal:Object = ExternalInterface.call( + "flowplayer.fireEvent", + playerId || ExternalInterface.objectID, getExternalName(eventType.name, beforePhase), convert(externalEventArgument), convert(externalEventArgument2), externalEventArgument3, externalEventArgument4, externalEventArgument5); + } catch (e:Error) { + log.error("Error in fireExternal() " + e); + } + if (returnVal + "" == "false") return false; + return true; + } + + private function convert(objToConvert:Object):Object { + if (_eventType.custom) return objToConvert; + return new ObjectConverter(objToConvert).convert(); + } + +// private function jsonize(externalEventArgument:Object):String { +// if (externalEventArgument is String) return externalEventArgument as String; +// return JSON.encode(externalEventArgument); +// } + + protected function getExternalName(name:String, beforePhase:Boolean):String { + if (! beforePhase) return name; + if (! name.indexOf("on") == 0) return "onBefore" + name; + return "onBefore" + name.substr(2); + } + + protected function get externalEventArgument():Object { + return target; + } + + protected function get externalEventArgument2():Object { + return _info; + } + + protected function get externalEventArgument3():Object { + return _info2; + } + + protected function get externalEventArgument4():Object { + return _info3; + } + + protected function get externalEventArgument5():Object { + return _info4; + } + + override public function isDefaultPrevented():Boolean { + return _isDefaultPrevented; + } + + override public function preventDefault():void { + _isDefaultPrevented = true; + } + + public function get info2():Object { + return _info2; + } + + public function get info3():Object { + return _info3; + } + + public function get info4():Object { + return _info4; + } + + public function get info5():Object { + return _info5; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Callable.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Callable.as new file mode 100644 index 0000000000000000000000000000000000000000..6b0087c73ba09dd6f1370d2d4033b478be543f3e --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Callable.as @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + + /** + * @author api + */ + public interface Callable { + + function addMethod(method:PluginMethod):void; + + function getMethod(externalName:String):PluginMethod; + + /** + * Invokes a method that has a return value. + * @param args arguments in an Array, if a callback is supported by the method + * the callbackId should be the last element in the array. + * @return the value returned by the invoked method + */ + function invokeMethod(externalName:String, args:Array = null):Object; + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Canvas.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Canvas.as new file mode 100644 index 0000000000000000000000000000000000000000..1f846fa471ae3a59aff2cdbed9f9f81da48e1db1 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Canvas.as @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ +package org.flowplayer.model { + public class Canvas { + private var _style:Object; + private var _linkUrl:String; + private var _linkWindow:String = '_self'; + + public function get linkUrl():String { + return _linkUrl; + } + + public function set linkUrl(val:String):void { + _linkUrl = val; + } + + public function get linkWindow():String { + return _linkWindow; + } + + public function set linkWindow(val:String):void { + _linkWindow = val; + } + + public function Canvas() { + + } + + public function get style():Object { + return _style; + } + + public function set style(val:Object):void { + _style = val; + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Clip.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Clip.as new file mode 100644 index 0000000000000000000000000000000000000000..a6d1f6bccb991e2760030e2deee437cfaada684a --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Clip.as @@ -0,0 +1,998 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import flash.net.NetStream; + + import org.flowplayer.controller.ClipURLResolver; + import org.flowplayer.controller.ConnectionProvider; +import org.flowplayer.flow_internal; + import org.flowplayer.model.ClipEvent; + import org.flowplayer.util.ArrayUtil; + import org.flowplayer.util.Log; + import org.flowplayer.util.URLUtil; + + import flash.display.DisplayObject; + import flash.media.Video; + import flash.utils.Dictionary; + + use namespace flow_internal; + + /** + * @inheritDoc + */ + public class Clip extends ClipEventDispatcher { + + // the main playlist where this clip belongs to + private var _playlist:Playlist; + private var _childPlaylist:TimedPlaylist; + private var _preroll:Clip; + private var _postroll:Clip; + private var _parent:Clip; + + private var _cuepoints:Dictionary; + private var _cuepointsInNegative:Array; +// private var _previousPositives:Array; + private var _baseUrl:String; + private var _url:String; + private var _urlsByResolver:Array; + private var _urlResolverObjects:Array; + private var _type:ClipType; + private var _start:Number; + private var _position:Number = -100; + private var _duration:Number = 0; + private var _metaData:Object = undefined; + private var _autoPlay:Boolean = true; + private var _autoPlayNext:Boolean = false; + private var _autoBuffering:Boolean; + private var _scaling:MediaSize; + private var _accelerated:Boolean; + private var _smoothing:Boolean; + private var _content:DisplayObject; + private var _originalWidth:int; + private var _originalHeight:int; + private var _bufferLength:int; + private var _played:Boolean; + private var _provider:String; + private var _customProperties:Object; + private var _fadeInSpeed:int; + private var _fadeOutSpeed:int; + private var _live:Boolean; + private var _linkUrl:String; + private var _linkWindow:String; + private var _image:Boolean; + private var _cuepointMultiplier:Number; + private var _urlResolvers:Array; + private var _connectionProvider:String; + private var _seekableOnBegin:Object; + private var _clipObject:Object; + private var _netStream:NetStream; + private var _startDispatched:Boolean; + private var _currentTime:Number = 0; + private var _endLimit:Number = 0.5; + private var _encoding:Boolean = false; + + public function Clip() { + _childPlaylist = new TimedPlaylist(); + + _cuepoints = new Dictionary(); + _cuepointsInNegative = []; + _urlsByResolver = []; + _start = 0; + _bufferLength = 3; + _scaling = MediaSize.FILLED_TO_AVAILABLE_SPACE; + _provider = "http"; + _smoothing = true; + _fadeInSpeed = 1000; + _fadeOutSpeed = 1000; + _linkWindow = "_self"; + _image = true; + _cuepointMultiplier = 1000; + _seekableOnBegin = null; + } + + public static function create(clipObj:Object, url:String, baseUrl:String = null):Clip { + return init(new Clip(), clipObj, url, baseUrl); + } + + /** + * Use Playlist#addClip() to add child clips to the playlist. This is for internal use only. + * @param clip + * @return + */ + public function addChild(clip:Clip):void { + clip.parent = this; + if (clip.isPreroll) { + _preroll = clip; + } + if (clip.isPostroll) { + _postroll = clip; + } + if (clip.isMidroll) { + log.info("adding midstream clip " + clip + ", position " + clip.position + " to parent clip " + this); + _childPlaylist.addClip(clip); + } + } + + private static function init(clip:Clip, clipObj:Object, url:String, baseUrl:String = null):Clip { + clip._clipObject = clipObj; + clip._url = url; + clip._baseUrl = baseUrl; + clip._autoPlay = true; + return clip; + } + + public function getParentPlaylist():Playlist { + return _playlist; + } + + public function setParentPlaylist(playlist:Playlist):void { + _playlist = playlist; + var children:Array = _childPlaylist.clips; + if (_preroll) { + children.push(_preroll); + } + if (_postroll) { + children.push(_postroll); + } + for (var i:int = 0; i < children.length; i++) { + var clip:Clip = Clip(children[i]); + clip.setParentPlaylist(playlist); + clip.setEventListeners(playlist); + } + } + + internal function setEventListeners(playlist:Playlist):void { + unbindEventListeners(); + onAll(playlist.commonClip.onClipEvent); + onBeforeAll(playlist.commonClip.onBeforeClipEvent); + } + + internal function unbindEventListeners():void { + unbind(_playlist.commonClip.onClipEvent); + unbind(_playlist.commonClip.onBeforeClipEvent, null, true); + } + + [Value] + public function get index():int { + return _playlist.indexOf(this._parent || this); + } + + [Value] + public function get isCommon():Boolean { + if (! _playlist) return false; + return this == _playlist.commonClip; + } + + public function addCuepoints(cuepoints:Array):void { + for (var i:Number = 0; i < cuepoints.length; i++) { + addCuepoint(cuepoints[i]); + } + } + + /** + * Removes cuepoints from this clip + * @param filter a filter function, that should return true for all cuepoints to be removed. takes in the cuepoint object. + * @return + */ + public function removeCuepoints(filter:Function = null):void { + if (filter == null) { + _cuepoints = new Dictionary(); + return; + } + for (var time:Object in _cuepoints) { + var points:Array = _cuepoints[time]; + for (var i:int = 0; i < points.length; i++) { + if (filter(points[i] as Cuepoint)) { + delete _cuepoints[time]; + } + } + } + } + + public function addCuepoint(cue:Cuepoint):void { + if (! cue) return; + if (cue.time >= 0) { + log.info(this + ": adding cuepoint to time " + cue.time) + if (!_cuepoints[cue.time]) { + _cuepoints[cue.time] = new Array(); + } + // do not add if this same cuepoint *instance* is already there + if ((_cuepoints[cue.time] as Array).indexOf(cue) >= 0) return; + + (_cuepoints[cue.time] as Array).push(cue); + } else { + log.info("storing negative cuepoint " + (this == commonClip ? "to common clip" : "")); + _cuepointsInNegative.push(cue); +// if (duration > 0) { +// convertToPositive(cue); +// } else { +// log.info("duration not available yet, storing negative cuepoint to be used when duration is set") +// _cuepointsInNegative.push(cue); +// } + } + } + + private function removeCuepoint(cue:Cuepoint):void { + var points:Array = _cuepoints[cue.time]; + if (! points) return; + var index:int = points.indexOf(cue); + if (index >= 0) { + log.debug("removing previous negative cuepoint at timeline time " + cue.time); + points.splice(index, 1); + } + } + + public function getCuepoints(time:int, dur:Number = -1):Array { + var result:Array = new Array(); + result = ArrayUtil.concat(result, _cuepoints[time]); + result = ArrayUtil.concat(result, getNegativeCuepoints(time, this == commonClip ? dur : this.duration)); + if (this == commonClip) return result; + result = ArrayUtil.concat(result, commonClip.getCuepoints(time, this.duration)); + if (result.length > 0) { + log.info("found " + result.length + " cuepoints for time " + time); + } + return result; + } + + private function getNegativeCuepoints(time:int, dur:Number):Array { + if (dur <= 0) return []; + var result:Array = new Array(); + for (var i:int = 0; i < _cuepointsInNegative.length; i++) { + var positive:Cuepoint = convertToPositive(_cuepointsInNegative[i], dur); + if (positive.time == time) { + log.info("found negative cuepoint corresponding to time " + time); + result.push(positive); + } + } + return result; + } +// +// private function setNegativeCuepointTimes(duration:int):void { +// log.debug("setNegativeCuepointTimes, transferring " + _cuepointsInNegative.length + " to timeline duration " + duration); +// _previousPositives.forEach( +// function(cue:*, index:int, array:Array):void { +// removeCuepoint(cue as Cuepoint); +// }); +// _previousPositives = new Array(); +// +// _cuepointsInNegative.forEach( +// function(cue:*, index:int, array:Array):void { +// convertToPositive(cue); +// }); +// } + + private function convertToPositive(cue:Cuepoint, dur:Number):Cuepoint { + var positive:Cuepoint = cue.clone() as Cuepoint; + positive.time = Math.round((dur * 1000 - Math.abs(Cuepoint(cue).time))/100) * 100; + return positive; + } + + [Value] + public function get baseUrl():String { + return _baseUrl; + } + + public function set baseUrl(baseURL:String):void { + this._baseUrl = baseURL; + } + + [Value] + public function get url():String { + return getResolvedUrl() || _url; + } + + [Value] + public function get originalUrl():String { + return _url; + } + + public function set url(url:String):void { + if (_url != url) { + _metaData = null; + _content = null; + } + this._url = url; + } + + /** + * Sets the resolved url- + * @param resolver the resolver used in resolving + * @param val + */ + public function setResolvedUrl(resolver:ClipURLResolver, val:String):void { + for (var i:int = 0; i < _urlsByResolver.length; i++) { + var resolverAndUrl:Array = _urlsByResolver[i]; + if (resolver == resolverAndUrl[0]) { + resolverAndUrl[1] = val; + return; + } + } + + _urlsByResolver.push([resolver, val]); + } + + /** + * Gets the url that was resolved using the specified resolver. + * @param resolver the resolver whose result to look up, if null returns the result of the most recent resolver that was executed. + * null if no resolvers are in use, or if the url has not been resolved yet. + * @return + */ + public function getResolvedUrl(resolver:ClipURLResolver = null):String { + if (resolver) { + return findResolvedUrl(resolver); + } else if (_urlsByResolver.length > 0) { + var resolverAndUrl:Array = _urlsByResolver[_urlsByResolver.length - 1]; + return resolverAndUrl ? resolverAndUrl[1] as String : null; + } + return null; + } + + + [Value] + public function get resolvedUrl():String { + return getResolvedUrl(); + } + + private function findResolvedUrl(resolver:ClipURLResolver):String { + for (var i:int = 0; i < _urlsByResolver.length; i++) { + var resolverAndUrl:Array = _urlsByResolver[i]; + if (resolver == resolverAndUrl[0]) { + return resolverAndUrl[1] as String; + } + } + return null; + } + + /** + * Gets the url that was resolved using the resolver that's before the specified resolver + * in the resolver chain. URL resolvers should use this method to fetch the URL that is used as the starting + * point in resolving. + * @param resolver + * @return + */ + public function getPreviousResolvedUrl(resolver:ClipURLResolver):String { + if (! _urlResolverObjects) throw new Error("Clip.urlResolverObjects is null"); + var pos:int = _urlResolverObjects.indexOf(resolver); + if (pos > 0) { + return findResolvedUrl(_urlResolverObjects[pos-1]); + } else if (pos < 0) { + throw new Error("Resolver " + resolver + " is not a registered URL Resolver in clip " + this); + } + return _url; + } + + /** + * Clears all resolved URLs. + * @return + */ + public function clearResolvedUrls():void { + _urlsByResolver = []; + } + + /* + * If the encoding is set property, uri encode for ut8 urls + */ + [Value] + public function get completeUrl():String { + return urlEncoding ? encodeURI(URLUtil.completeURL(_baseUrl, url)) : URLUtil.completeURL(_baseUrl, url); + } + + public function get type():ClipType { + if (_type) { + return _type; + } + if (_url && _url.indexOf("mp3:") >= 0) { + return ClipType.AUDIO; + } + if (! _type && _url) { + _type = ClipType.fromFileExtension(url); + } + if (_type) { + return _type; + } + return ClipType.VIDEO; + } + + public function get isFlashVideo():Boolean { + return ClipType.isFlashVideo(_url); + } + + [Value] + public function get extension():String { + return ClipType.getExtension(_url); + } + + [Value(name="type")] + public function get typeStr():String { + return type ? type.type : ClipType.VIDEO.type; + } + + public function setType(type:String):void { + this._type = ClipType.resolveType(type); + } + + public function set type(type:ClipType):void { + _type = type; + } + + [Value] + public function get start():Number { + return _start; + } + + public function set start(start:Number):void { + this._start = start; + } + + public function set duration(value:Number):void { + this._duration = value; + log.info("clip duration set to " + value); + } + + public function get durationFromMetadata():Number { + if (_metaData) + return decodeDuration(_metaData.duration); + return 0; + } + + private function decodeDuration(duration:Object):Number { + if (! duration) return 0; + if (duration is Number) return duration as Number; + if (! duration is String) return 0; + var parts:Array = duration.split("."); + + // for some reason duration can have 3 part value, for example "130.000.123" + if (parts.length >= 3) { + return Number(parts[0] + "." + parts[1]); + } + return duration as Number; + } + + public function set durationFromMetadata(value:Number):void { + if (! _metaData) { + _metaData = new Object(); + } + _metaData.duration = value; + } + + [Value] + public function get duration():Number { + if (_duration > 0) { + return _duration; + } + var metadataDur:Number = durationFromMetadata; + if (_start > 0 && metadataDur > _start) { + return metadataDur - _start; + } + return metadataDur || 0; + } + + [Value] + public function get metaData():Object { + return _metaData; + } + + public function set metaData(metaData:Object):void { + this._metaData = metaData; +// if (! (_duration >= 0) && metaData && metaData.duration) { +// setNegativeCuepointTimes(metaData.duration); +// addCommonClipNegativeCuepoints(); +// } + } + + [Value] + public function get autoPlay():Boolean { + if (isPreroll) return _parent._autoPlay; + if (! _parent && preroll) return true; + if (isPostroll) return true; + return _autoPlay; + } + + public function set autoPlay(autoPlay:Boolean):void { + this._autoPlay = autoPlay; + } + + [Value] + public function get autoBuffering():Boolean { + return _autoBuffering; + } + + public function set autoBuffering(autoBuffering:Boolean):void { + this._autoBuffering = autoBuffering; + } + + public function setContent(content:DisplayObject):void { + if (_content && _content is Video && ! content) { + log.debug("clearing video content"); + Video(_content).clear(); + } + this._content = content; + } + + public function getContent():DisplayObject { + return _content; + } + + public function setScaling(scaling:String):void { + this.scaling = MediaSize.forName(scaling); + } + + public function set scaling(scaling:MediaSize):void { + this._scaling = scaling; + + log.debug("scaling : " + scaling + ", disptching update"); + + if (_playlist) { + _playlist.dispatch(ClipEventType.UPDATE); + } + } + + public function get scaling():MediaSize { + return this._scaling; + } + + [Value(name="scaling")] + public function get scalingStr():String { + if (! _scaling) return MediaSize.FILLED_TO_AVAILABLE_SPACE.value; + return this._scaling.value; + } + + public function toString():String { + return "[Clip] '" + (provider == "http" ? completeUrl : url) + "'"; + } + + public function set originalWidth(width:int):void { + this._originalWidth = width; + } + + public function get originalWidth():int { + if (type == ClipType.VIDEO) { + if (_metaData && _metaData.width >= 0) { + return _metaData.width; + } + if (! _content) { +// log.warn("Getting originalWidth from a clip that does not have content loaded yet, returning zero"); + return 0; + } + return _content is Video ? (_content as Video).videoWidth : _originalWidth; + } + return _originalWidth; + } + + public function set originalHeight(height:int):void { + this._originalHeight = height; + } + + public function get originalHeight():int { + if (type == ClipType.VIDEO) { + if (_metaData && _metaData.height >= 0) { + return _metaData.height; + } + if (! _content) { +// log.warn("Getting originalHeight from a clip that does not have content loaded yet, returning zero"); + return 0; + } + return _content is Video ? (_content as Video).videoHeight : _originalHeight; + } + return _originalHeight; + } + + public function set width(width:int):void { + if (! _content) { + log.warn("Trying to change width of a clip that does not have media content loaded yet"); + return; + } + _content.width = width; + } + + [Value] + public function get width():int { + return getWidth(); + } + + private function getWidth():int { + if (! _content) { +// log.warn("Getting width from a clip that does not have content loaded yet, returning zero"); + return 0; + } + return _content.width; + } + + public function set height(height:int):void { + if (! _content) { + log.warn("Trying to change height of a clip that does not have media content loaded yet"); + return; + } + _content.height = height; + } + + [Value] + public function get height():int { + return getHeight(); + } + + private function getHeight():int { + if (! _content) { +// log.warn("Getting height from a clip that does not have content loaded yet, returning zero"); + return 0; + } + return _content.height; + } + + [Value] + public function get bufferLength():int { + return _bufferLength; + } + + public function set bufferLength(bufferLength:int):void { + _bufferLength = bufferLength; + } + + public function get played():Boolean { + return _played; + } + + public function set played(played:Boolean):void { + _played = played; + } + + [Value] + public function get provider():String { + if (type == ClipType.AUDIO && _provider == "http") return "audio"; + if (_url && _url.toLowerCase().indexOf("rtmp") == 0 && _provider == "http") return "rtmp"; + if (parent) return _provider + "Instream"; + return _provider; + } + + public function get configuredProviderName():String { + return _provider; + } + + public function set provider(provider:String):void { + _provider = provider; + } + + [Value] + public function get cuepoints():Array { + var cues:Array = new Array(); + for each (var cue:Object in _cuepoints) { + cues.push(cue); + } + return cues; + } + + public function set accelerated(accelerated:Boolean):void { + _accelerated = accelerated; + } + + [Value] + public function get accelerated():Boolean { + return _accelerated; + } + + public function get isNullClip():Boolean { + return false; + } + + // common clip listens to events from the normal clips and redispatches + public function onClipEvent(event:ClipEvent):void { + log.info("received onClipEvent, I am commmon clip: " + (this == _playlist.commonClip)); + doDispatchEvent(event, true); + log.debug(this + ": dispatched play event with target " + event.target); + } + + public function onBeforeClipEvent(event:ClipEvent):void { + log.info("received onBeforeClipEvent, I am commmon clip: " + (this == _playlist.commonClip)); + doDispatchBeforeEvent(event, true); + log.debug(this + ": dispatched before event with target " + event.target); + } + + private function get commonClip():Clip { + if (! _playlist) return null; + return _playlist.commonClip; + } + + public function get customProperties():Object { + return _customProperties; + } + + public function set customProperties(props:Object):void { + _customProperties = props; + + // workaraound to not allow setting cuepoints to custom properties + if (_customProperties && _customProperties["cuepoints"]) { + delete _customProperties["cuepoints"]; + } + if (_customProperties && _customProperties["playlist"]) { + delete _customProperties["playlist"]; + } + } + + public function get smoothing():Boolean { + return _smoothing; + } + + public function set smoothing(smoothing:Boolean):void { + _smoothing = smoothing; + } + + public function getCustomProperty(property:String):Object { + if (!_customProperties) return null; + return _customProperties[property]; + } + + public function setCustomProperty(property:String, value:Object):void { + if (property == "playlist") return; + if (!_customProperties) { + _customProperties = new Object(); + } + _customProperties[property] = value; + } + + [Value] + public function get fadeInSpeed():int { + return _fadeInSpeed; + } + + public function set fadeInSpeed(fadeInSpeed:int):void { + _fadeInSpeed = fadeInSpeed; + } + + [Value] + public function get fadeOutSpeed():int { + return _fadeOutSpeed; + } + + public function set fadeOutSpeed(fadeOutSpeed:int):void { + _fadeOutSpeed = fadeOutSpeed; + } + + [Value] + public function get live():Boolean { + return _live; + } + + public function set live(live:Boolean):void { + _live = live; + } + + [Value] + public function get linkUrl():String { + return _linkUrl; + } + + public function set linkUrl(linkUrl:String):void { + _linkUrl = linkUrl; + } + + [Value] + public function get linkWindow():String { + return _linkWindow; + } + + public function set linkWindow(linkWindow:String):void { + _linkWindow = linkWindow; + } + + protected function get cuepointsInNegative():Array { + return _cuepointsInNegative; + } + + /** + * Use the previous clip in the playlist as an image for this audio clip? + * This is only for audio clips. + */ + [Value] + public function get image():Boolean { + return _image; + } + + public function set image(image:Boolean):void { + _image = image; + } + + public function get autoPlayNext():Boolean { + return _autoPlayNext; + } + + public function set autoPlayNext(autoPlayNext:Boolean):void { + _autoPlayNext = autoPlayNext; + } + + [Value] + public function get cuepointMultiplier():Number { + return _cuepointMultiplier; + } + + public function set cuepointMultiplier(cuepointMultiplier:Number):void { + _cuepointMultiplier = cuepointMultiplier; + } + + public function dispatchNetStreamEvent(name:String, infoObject:Object):void { + dispatch(ClipEventType.NETSTREAM_EVENT, name, infoObject); + } + + public function get connectionProvider():String { + return _connectionProvider; + } + + public function set connectionProvider(val:String):void { + _connectionProvider = val; + } + + [Value] + public function get urlResolvers():Array { + return _urlResolvers; + } + + public function setUrlResolvers(val:Object):void { + _urlResolvers = val is Array ? val as Array : [val]; + } + + public function get seekableOnBegin():Boolean { + if (_seekableOnBegin == null) { + return isFlashVideo; + } + return _seekableOnBegin as Boolean; + } + + public function set seekableOnBegin(val:Boolean):void { + _seekableOnBegin = val; + } + + public function get hasChildren():Boolean { + return _childPlaylist.length > 0; + } + + [Value] + public function get playlist():Array { + var result:Array = _childPlaylist.clips; + if (_preroll) { + result = [_preroll].concat(result); + } + if (_postroll) { + result.push(_postroll); + } + return result; + } + + public function removeChild(child:Clip):void { + if (child == _preroll) { + _preroll = null; + return; + } + if (child == _postroll) { + _postroll = null; + return; + } + _childPlaylist.removeClip(child); + } + + public function getMidroll(time:int):Clip { + return _childPlaylist.getClipAt(time); + } + + public function get preroll():Clip { + return _preroll; + } + + public function get postroll():Clip { + return _postroll; + } + + [Value] + public function get isInStream():Boolean { + return _parent != null; + } + + public function get isMidroll():Boolean { + if (isOneShot) return true; + return _parent && _position > 0; + } + + public function get isPreroll():Boolean { + return _parent && _position == 0; + } + + public function get isPostroll():Boolean { + return _parent && _position == -1; + } + + public function get parent():Clip { + return _parent; + } + + [Value] + public function get parentUrl():String { + return _parent ? _parent.url : null; + } + + public function set parent(val:Clip):void { + _parent = val; + } + + [Value] + public function get position():Number { + return _position; + } + + public function set position(val:Number):void { + _position = val; + } + + public function get isOneShot():Boolean { + return _parent && position == -2; + } + + flow_internal function get clipObject():Object { + return _clipObject; + } + + /** + * Gets the NetStream object that is currently associated with this clip, or <code>null</code> if none is + * currently associated. + * @return + */ + public function getNetStream():NetStream { + return _netStream; + } + + public function setNetStream(value:NetStream):void { + _netStream = value; + } + + public function set urlResolverObjects(urlResolverObjects:Array):void { + _urlResolverObjects = urlResolverObjects; + } + + public function get startDispatched():Boolean { + return _startDispatched; + } + + public function set startDispatched(value:Boolean):void { + _startDispatched = value; + } + + public function get currentTime():Number { + return _currentTime; + } + + public function set currentTime(time:Number):void { + _currentTime = (_currentTime ==0 ? time + _start : time); + } + + [Value] + public function get endLimit():Number { + return _endLimit; + } + + public function set endLimit(value:Number):void { + _endLimit = value; + } + + public function set urlEncoding(value:Boolean):void { + _encoding = value; + } + + [Value] + public function get urlEncoding():Boolean { + return _encoding; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipError.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipError.as new file mode 100644 index 0000000000000000000000000000000000000000..4ef8fa768b1938a94124d8982e3ce4b4c62630c2 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipError.as @@ -0,0 +1,36 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import org.flowplayer.model.ErrorCode; + + /** + * Clip error codes. + */ + public class ClipError extends ErrorCode { + + public static const STREAM_NOT_FOUND:ClipError = new ClipError(ClipEventType.ERROR, 200, "Stream not found"); + public static const STREAM_LOAD_FAILED:ClipError = new ClipError(ClipEventType.ERROR, 201, "Unable to load stream or clip file"); + public static const PROVIDER_NOT_LOADED:ClipError = new ClipError(ClipEventType.ERROR, 202, "The provider specified in this clip is not loaded"); + + public function ClipError(eventType:EventType, code:int, message:String) { + super(eventType, code, message); + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipEvent.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipEvent.as new file mode 100644 index 0000000000000000000000000000000000000000..2104bb2f4e9ab67391b11d7b510a3949e3712f0f --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipEvent.as @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import flash.events.Event; + import org.flowplayer.util.ObjectConverter; + + /** + * @author anssi + */ + public class ClipEvent extends AbstractEvent { + + public function ClipEvent(eventType:EventType, info:Object = null, info2:Object = null, info3:Object = null) { + super(eventType, info, info2, info3); + } + + public override function clone():Event { + return new ClipEvent(eventType, info); + } + + public override function toString():String { + return formatToString("ClipEvent", "type", "info"); + } + + protected override function get externalEventArgument():Object { + if (eventType == ClipEventType.PLAYLIST_REPLACE) { + return (target as ClipEventSupport).clips; + } + if (eventType == ClipEventType.CLIP_ADD) { + return info2 || (target as ClipEventSupport).clips[info]; + } + if (target is Clip) { + return Clip(target).index; + } + return target; + } + + protected override function get externalEventArgument2():Object { + if (eventType == ClipEventType.CUEPOINT) { + return Cuepoint(info).callbackId; + } + if ([ClipEventType.START, ClipEventType.UPDATE, ClipEventType.METADATA, ClipEventType.RESUME, ClipEventType.BEGIN].indexOf(eventType) >= 0) { + return target; + } + return super.externalEventArgument2; + } + + protected override function get externalEventArgument3():Object { + if (eventType == ClipEventType.CLIP_ADD ) { + return null; + } + if (eventType == ClipEventType.CUEPOINT) { + return info is DynamicCuepoint ? info : Cuepoint(info).time; + } + return super.externalEventArgument3; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipEventDispatcher.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipEventDispatcher.as new file mode 100644 index 0000000000000000000000000000000000000000..a4e18e1fa40f5e3a788711cb281002b2f7747b47 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipEventDispatcher.as @@ -0,0 +1,164 @@ +package org.flowplayer.model { + import flash.utils.Dictionary; + + import org.flowplayer.flow_internal; + import org.flowplayer.model.ClipEvent; + import org.flowplayer.model.EventDispatcher; + + use namespace flow_internal; + + /** + * ClipEventDispatcher is used to attach listeners for ClipEvents and for dispatching ClipEvents. + * + * @see ClipEvent + */ + public class ClipEventDispatcher extends EventDispatcher { + + public function dispatch(eventType:ClipEventType, info:Object = null, info2:Object = null, info3:Object = null):void { + doDispatchEvent(new ClipEvent(eventType, info, info2, info3), false); + } + + public function dispatchError(error:ClipError, info:Object = null):void { + doDispatchErrorEvent(new ClipEvent(error.eventType, error, info), false); + } + + public function dispatchEvent(event:ClipEvent):void { + doDispatchEvent(event, false); + } + + public function dispatchBeforeEvent(event:AbstractEvent):Boolean { + return doDispatchBeforeEvent(event, false); + } + + public function onUpdate(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.UPDATE, listener, clipFilter, false, addToFront); + } + + public function onBeforeAll(listener:Function, clipFilter:Function = null):void { + setListener(null, listener, clipFilter, true); + } + + public function onAll(listener:Function, clipFilter:Function = null):void { + setListener(null, listener, clipFilter); + } + + public function onConnect(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.CONNECT, listener, clipFilter, false, addToFront); + } + + /** + * Adds a listener for the start event. + * + * @param listener the listener to add + * @param clipFilter a clip filter function, the listener is only added if the filter function returns true for a clip + * @param addToFront if <code>true</code> the listener is added to the front of the listener list so that it will get notified before the listeners that had been added before this one + */ + public function onStart(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.START, listener, clipFilter, false, addToFront); + } + + public function onMetaData(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.METADATA, listener, clipFilter, false, addToFront); + } + + public function onBeforeBegin(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.BEGIN, listener, clipFilter, true, addToFront); + } + + public function onBegin(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.BEGIN, listener, clipFilter, false, addToFront); + } + + public function onBeforePause(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.PAUSE, listener, clipFilter, true, addToFront); + } + + public function onPause(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.PAUSE, listener, clipFilter, false, addToFront); + } + + public function onBeforeResume(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.RESUME, listener, clipFilter, true, addToFront); + } + + public function onResume(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.RESUME, listener, clipFilter, false, addToFront); + } + + public function onBeforeStop(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.STOP, listener, clipFilter, true, addToFront); + } + + public function onStop(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.STOP, listener, clipFilter, false, addToFront); + } + + public function onFinish(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.FINISH, listener, clipFilter, false, addToFront); + } + + public function onBeforeFinish(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.FINISH, listener, clipFilter, true, addToFront); + } + + public function onCuepoint(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.CUEPOINT, listener, clipFilter, false, addToFront); + } + + public function onBeforeSeek(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.SEEK, listener, clipFilter, true, addToFront); + } + + public function onSeek(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.SEEK, listener, clipFilter, false, addToFront); + } + + public function onBufferEmpty(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.BUFFER_EMPTY, listener, clipFilter, false, addToFront); + } + + public function onBufferFull(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.BUFFER_FULL, listener, clipFilter, false, addToFront); + } + + public function onBufferStop(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.BUFFER_STOP, listener, clipFilter, false, addToFront); + } + + public function onLastSecond(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.LAST_SECOND, listener, clipFilter, false, addToFront); + } + + public function onNetStreamEvent(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.NETSTREAM_EVENT, listener, clipFilter, false, addToFront); + } + + public function onConnectionEvent(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.CONNECTION_EVENT, listener, clipFilter, false, addToFront); + } + + public function onError(listener:Function, clipFilter:Function = null, addToFront:Boolean = false):void { + setListener(ClipEventType.ERROR, listener, clipFilter, false, addToFront); + } + + public function onPlaylistReplace(listener:Function, addToFront:Boolean = false):void { + setListener(ClipEventType.PLAYLIST_REPLACE, listener, null, false, addToFront); + } + + public function onClipAdd(listener:Function, addToFront:Boolean = false):void { + setListener(ClipEventType.CLIP_ADD, listener, null, false, addToFront); + } + + public function onResized(listener:Function, addToFront:Boolean = false):void { + setListener(ClipEventType.CLIP_RESIZED, listener, null, false, addToFront); + } + + override protected function get cancellableEvents():Dictionary { + return ClipEventType.cancellable; + } + + override protected function get allEvents():Dictionary { + return ClipEventType.all; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipEventSupport.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipEventSupport.as new file mode 100644 index 0000000000000000000000000000000000000000..0349557b1a2c7fefbce3dcef04313cfaee20e2de --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipEventSupport.as @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import org.flowplayer.flow_internal; + use namespace flow_internal; + /** + * @author api + */ + public class ClipEventSupport extends ClipEventDispatcher { + private var _clips:Array; + private var _commonClip:Clip; + + public function ClipEventSupport(commonClip:Clip, clips:Array = null) { + _commonClip = commonClip; + _clips = clips; + } + + flow_internal function setClips(clips:Array):void { + _clips = clips; + } + + flow_internal function get allClips():Array { + return _clips; + } + + public function get clips():Array { + return _clips.filter(function (item:*, index:int, array:Array):Boolean { + return ! Clip(item).isInStream; + }); + } + + public static function typeFilter(type:ClipType):Function { + return function(clip:Clip):Boolean { return clip.type == type; }; + } + + override flow_internal function setListener(event:EventType, listener:Function, clipFilter:Function = null, beforePhase:Boolean = false, addToFront:Boolean = false):void { + var eventType:ClipEventType = event as ClipEventType; + if (eventType && eventType.playlistIsEventTarget) { + super.setListener(eventType, listener, clipFilter, beforePhase, addToFront); + } else { + _commonClip.setListener(eventType, listener, clipFilter, beforePhase, addToFront); + } + } + + override internal function removeListener(event:EventType, listener:Function, beforePhase:Boolean = false):void { + var eventType:ClipEventType = event as ClipEventType; + if (eventType.playlistIsEventTarget) { + super.removeListener(event, listener, beforePhase); + } else { + _commonClip.removeListener(event, listener, beforePhase); + } + } + + public function get childClips():Array { + var result:Array = new Array(); + for (var i:int = 0; i < _clips.length; i++) { + result = result.concat(Clip(_clips[i]).playlist); + } + return result; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipEventType.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipEventType.as new file mode 100644 index 0000000000000000000000000000000000000000..781553b133a88041c700ed4a05952ddcb31aef3b --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipEventType.as @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import flash.utils.Dictionary; + +import org.flowplayer.flow_internal; + + public class ClipEventType extends EventType { + + public static const CONNECT:ClipEventType = new ClipEventType("onConnect"); + public static const BEGIN:ClipEventType = new ClipEventType("onBegin"); + public static const METADATA:ClipEventType = new ClipEventType("onMetaData"); + public static const START:ClipEventType = new ClipEventType("onStart"); + public static const PAUSE:ClipEventType = new ClipEventType("onPause"); + public static const RESUME:ClipEventType = new ClipEventType("onResume"); + public static const STOP:ClipEventType = new ClipEventType("onStop"); + public static const FINISH:ClipEventType = new ClipEventType("onFinish"); + public static const CUEPOINT:ClipEventType = new ClipEventType("onCuepoint"); + public static const SEEK:ClipEventType = new ClipEventType("onSeek"); + public static const SWITCH:ClipEventType = new ClipEventType("onSwitch"); + + public static const BUFFER_EMPTY:ClipEventType = new ClipEventType("onBufferEmpty"); + public static const BUFFER_FULL:ClipEventType = new ClipEventType("onBufferFull"); + public static const BUFFER_STOP:ClipEventType = new ClipEventType("onBufferStop"); + public static const LAST_SECOND:ClipEventType = new ClipEventType("onLastSecond"); + public static const UPDATE:ClipEventType = new ClipEventType("onUpdate"); + public static const ERROR:ClipEventType = new ClipEventType("onError"); + public static const NETSTREAM_EVENT:ClipEventType = new ClipEventType("onNetStreamEvent"); + public static const CONNECTION_EVENT:ClipEventType = new ClipEventType("onConnectionEvent"); + + public static const PLAYLIST_REPLACE:ClipEventType = new ClipEventType("onPlaylistReplace"); + public static const CLIP_ADD:ClipEventType = new ClipEventType("onClipAdd"); + public static const CLIP_RESIZED:ClipEventType = new ClipEventType("onResized"); + + private static var _allValues:Dictionary; + private static var _cancellable:Dictionary = new Dictionary(); + { + _cancellable[BEGIN.name] = BEGIN; + _cancellable[SEEK.name] = SEEK; + _cancellable[PAUSE.name] = PAUSE; + _cancellable[RESUME.name] = RESUME; + _cancellable[STOP.name] = STOP; + _cancellable[FINISH.name] = FINISH; + } + + override public function get isCancellable():Boolean { + return _cancellable[this.name]; + } + + public static function get cancellable():Dictionary { + return _cancellable; + } + + public static function get all():Dictionary { + return _allValues; + } + + /** + * Creates a new type. + */ + public function ClipEventType(name:String, custom:Boolean = false) { + super(name, custom); + if (! _allValues) { + _allValues = new Dictionary(); + } + _allValues[name] = this; + } + + public static function forName(name:String):ClipEventType { + return _allValues[name]; + } + + public function toString():String { + return "[ClipEventType] '" + name + "'"; + } + + public function get playlistIsEventTarget():Boolean { + return this == PLAYLIST_REPLACE || this == CLIP_ADD; + } + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipType.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipType.as new file mode 100644 index 0000000000000000000000000000000000000000..8ab5bcf4bcdfca1a0720bc9bb3395e153b124244 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ClipType.as @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import org.flowplayer.util.URLUtil; + + public class ClipType { + + private static const FLASH_VIDEO_EXTENSIONS:Array = ['f4b', 'f4p', 'f4v', 'flv']; + //new clip prefix chromeless: denotes a chromeless url with a video id reference + private static const VIDEOAPI_PREFIX:String = 'api:'; + private static const VIDEO_EXTENSIONS:Array = ['3g2', '3gp', 'aac', 'm4a', 'm4v', 'mov', 'mp4', 'vp6', 'mpeg4', 'video']; + private static const IMAGE_EXTENSIONS:Array = ['png', 'jpg', 'jpeg', 'gif', 'swf', 'image']; + + public static const VIDEO:ClipType = new ClipType("video"); + public static const AUDIO:ClipType = new ClipType("audio"); + public static const IMAGE:ClipType = new ClipType("image"); + public static const API:ClipType = new ClipType("api:"); + + private static var MIME_TYPE_MAPPING:Object = { + 'application/x-fcs': VIDEO, + 'application/x-shockwave-flash': IMAGE, + 'audio/aac': VIDEO, + 'audio/m4a': VIDEO, + 'audio/mp4': VIDEO, + 'audio/mp3': AUDIO, + 'audio/mpeg': AUDIO, + 'audio/x-3gpp': VIDEO, + 'audio/x-m4a': VIDEO, + 'image/gif': IMAGE, + 'image/jpeg': IMAGE, + 'image/jpg': IMAGE, + 'image/png': IMAGE, + 'video/flv':VIDEO, + 'video/3gpp':VIDEO, + 'video/h264':VIDEO, + 'video/mp4':VIDEO, + 'video/x-3gpp':VIDEO, + 'video/x-flv':VIDEO, + 'video/x-m4v':VIDEO, + 'video/x-mp4':VIDEO + }; + + private static var enumCreated:Boolean; + { enumCreated = true; } + + private var _type:String; + + public function ClipType(type:String) { + if (enumCreated) + throw new Error("Cannot create ad-hoc ClipType instances"); + this._type = type; + } + + public function get type():String { + return _type; + } + + public static function fromMimeType(mime:String):ClipType { + return MIME_TYPE_MAPPING[mime]; + } + + public static function getExtension(name:String):String { + if (! name) return null; + + var extension:String = knownEndingExtension(name); + if (extension) return extension; + + var parts:Array = URLUtil.baseUrlAndRest(name); + var filename:String = parts[1]; + + var queryStart:int = filename.indexOf("?"); + if (queryStart > 0) { + filename = filename.substr(0, queryStart); + } + var dotPos:Number = filename.lastIndexOf("."); + var lcName:String = filename.toLowerCase(); + return lcName.substring(dotPos + 1, lcName.length); + } + + private static function knownEndingExtension(name:String):String { + var extensions:Array = VIDEO_EXTENSIONS.concat(IMAGE_EXTENSIONS).concat(FLASH_VIDEO_EXTENSIONS); + extensions.push("mp3"); + for (var i:int = 0; i < extensions.length; i++) { + var extension:String = extensions[i] as String; + if (name.lastIndexOf(extension) == name.length - extension.length) { + return extension; + } + } + return null; + } + + public static function fromFileExtension(name:String):ClipType { + return resolveType(getExtension(name)); + } + + public static function resolveType(type:String):ClipType { + if (type == ClipType.VIDEO.type) return ClipType.VIDEO; + if (type == ClipType.AUDIO.type) return ClipType.AUDIO; + if (type == ClipType.IMAGE.type) return ClipType.IMAGE; + if (type == ClipType.API.type) return ClipType.API; + + if (VIDEO_EXTENSIONS.concat(FLASH_VIDEO_EXTENSIONS).indexOf(type) >= 0) + return ClipType.VIDEO; + //add support for video api swf player video types with an api prefix and a video id as the url + if (type.indexOf(VIDEOAPI_PREFIX) >= 0) + return ClipType.API; + if (IMAGE_EXTENSIONS.indexOf(type) >= 0) + return ClipType.IMAGE; + if (type == 'mp3') + return ClipType.AUDIO; + return ClipType.VIDEO; + } + + public static function isFlashVideo(name:String):Boolean { + if (! name) return true; + return FLASH_VIDEO_EXTENSIONS.indexOf(getExtension(name)) >= 0; + } + + public function toString():String { + return "ClipType: '" + _type + "'"; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Cloneable.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Cloneable.as new file mode 100644 index 0000000000000000000000000000000000000000..4a7944d7dd100ef792edad54815c80d1e7c3dfaa --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Cloneable.as @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + + /** + * @author api + */ + public interface Cloneable { + function clone():Cloneable; + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Cuepoint.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Cuepoint.as new file mode 100644 index 0000000000000000000000000000000000000000..e33425acfaa1021d80260661fc687ae143d46379 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Cuepoint.as @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { +import flash.utils.Dictionary; + + import org.flowplayer.util.Log; + + /** + * @author api + */ + public class Cuepoint implements Cloneable { + protected var log:Log = new Log(this); + private var _time:int; + private var _callbackId:String; + private var _lastFireTime:int = -1; + private var _name:String; + + private var _parameters:Object = new Object(); + + /** + * Creates a new cuepoint. + * @param time + * @param callbackId + */ + public function Cuepoint(time:int, callbackId:String) { + _time = time; + _callbackId = callbackId; + } + + public static function createDynamic(time:int, callbackId:String):Cuepoint { + return new DynamicCuepoint(time, callbackId); + } + + [Value] + public function get name():String { + return _name; + } + + public function set name(name:String):void { + _name = name; + } + + [Value] + public function get time():int { + return _time; + } + + public function set time(time:int):void { + _time = time; + } + + public function toString():String { + return "[Cuepoint] time " + _time; + } + + public function get callbackId():String { + return _callbackId; + } + + public final function clone():Cloneable { + var clone:Cuepoint = new Cuepoint(_time, callbackId); + onClone(clone); + return clone; + } + + protected function onClone(clone:Cuepoint):void { + } + + [Value] + public function get lastFireTime():int { + return _lastFireTime; + } + + public function set lastFireTime(lastFireTime:int):void { + _lastFireTime = lastFireTime; + } + + + public function addParameter(name:String, value:Object):void { + _parameters[name] = value; + } + + [Value] + public function get parameters():Object { + return _parameters; + } + + public function set parameters(params:Object):void { + _parameters = params; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/DisplayPluginModel.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/DisplayPluginModel.as new file mode 100644 index 0000000000000000000000000000000000000000..a1be569605e9b1cdd86034bd94b894e0d56bd801 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/DisplayPluginModel.as @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import org.flowplayer.model.PluginModel; + import org.flowplayer.model.DisplayProperties; + + /** + * @author api + */ + public interface DisplayPluginModel extends PluginModel, DisplayProperties { + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/DisplayPluginModelImpl.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/DisplayPluginModelImpl.as new file mode 100644 index 0000000000000000000000000000000000000000..22ce80f6d7799fa301fa93ad07ef59b67a9c9648 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/DisplayPluginModelImpl.as @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import flash.display.DisplayObject; + + import org.flowplayer.model.Cloneable; + + /** + * @author api + */ + public class DisplayPluginModelImpl extends DisplayPropertiesImpl implements DisplayPluginModel { + private var _config:Object; + private var _methods:Array = new Array(); + private var _builtIn:Boolean; + private var _url:String; + + public function DisplayPluginModelImpl(disp:DisplayObject, name:String, setDefaults:Boolean = true):void { + super(disp, name, setDefaults); + } + + public function addMethod(method:PluginMethod):void { + _methods.push(method); + } + + public function getMethod(externalName:String):PluginMethod { + return PluginMethodHelper.getMethod(_methods, externalName); + } + + public function invokeMethod(externalName:String, args:Array = null):Object { + return PluginMethodHelper.invokePlugin(this, getDisplayObject(), externalName, args); + } + + public function get config():Object { + return _config; + } + + public function set config(config:Object):void { + _config = config; + } + + public function set visible(visible:Boolean):void { + super.display = visible ? "block" : "none"; + } + + override protected function copyFields(from:DisplayProperties, to:DisplayPropertiesImpl):void { + super.copyFields(from, to); + DisplayPluginModelImpl(to).config = DisplayPluginModelImpl(from).config; + DisplayPluginModelImpl(to).methods = DisplayPluginModelImpl(from).methods; + DisplayPluginModelImpl(to).isBuiltIn = DisplayPluginModelImpl(from).isBuiltIn; + } + + public override function clone():Cloneable { + var copy:DisplayPluginModelImpl = new DisplayPluginModelImpl(getDisplayObject(), name); + copyFields(this, copy); + return copy; + } + + public function get methods():Array { + return _methods; + } + + public function set methods(values:Array):void { + _methods = values; + } + + [Value(name="methods")] + public function get methodNames():Array { + return PluginMethodHelper.methodNames(_methods); + } + + public function get pluginObject():Object { + return getDisplayObject(); + } + + public function set pluginObject(pluginObject:Object):void { + setDisplayObject(pluginObject as DisplayObject); + } + + [Value(name="builtIn")] + public function get isBuiltIn():Boolean { + return _builtIn; + } + + public function set isBuiltIn(value:Boolean):void { + _builtIn = value; + } + + [Value] + public function get url():String { + return _url; + } + + public function set url(url:String):void { + _url = url; + } + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/DisplayProperties.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/DisplayProperties.as new file mode 100644 index 0000000000000000000000000000000000000000..1a0b6174f180a5a5355cabdf2152f898ae1e8d2d --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/DisplayProperties.as @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import flash.display.DisplayObject; + + import org.flowplayer.layout.Dimensions; + import org.flowplayer.layout.Position; + import org.flowplayer.model.Cloneable; + /** + * @author anssi + */ + public interface DisplayProperties extends Identifiable, Cloneable { + + /** + * Gets the associated DisplayObject. This is not implemented + * as an accessor since we don't want the display object to + * be serialized through ExternalInterface. + */ + function getDisplayObject():DisplayObject; + + function setDisplayObject(displayObject:DisplayObject):void; + + function set width(value:Object):void; + + function get widthPx():Number; + + function get widthPct():Number; + + function set height(value:Object):void; + + function get heightPx():Number; + + function get heightPct():Number; + + function get dimensions():Dimensions; + + function set alpha(value:Number):void; + + function get alpha():Number; + + function set opacity(value:Number):void; + + function get opacity():Number; + + function set zIndex(value:Number):void; + + function get zIndex():Number; + + function get display():String; + + function set display(value:String):void; + + function get visible():Boolean; + + function set top(top:Object):void; + + function set right(value:Object):void; + + function set bottom(value:Object):void; + + function set left(value:Object):void; + + function get position():Position; + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/DisplayPropertiesImpl.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/DisplayPropertiesImpl.as new file mode 100644 index 0000000000000000000000000000000000000000..97db38e02d075b1f17b07808b4743cbe05073264 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/DisplayPropertiesImpl.as @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import flash.display.DisplayObject; + + import org.flowplayer.layout.Dimensions; + import org.flowplayer.layout.Position; + import org.flowplayer.model.Cloneable; + + /** + * @author anssi + */ + public class DisplayPropertiesImpl extends PluginEventDispatcher implements DisplayProperties { + + private var _name:String; + private var _display:String = "block"; + private var _dimensions:Dimensions = new Dimensions(); + private var _alpha:Number = 1; + private var _zIndex:Number = -1; + private var _position:Position = new Position(); + private var _displayObject:DisplayObject; + + public function DisplayPropertiesImpl(disp:DisplayObject = null, name:String = null, setDefaults:Boolean = true) { + _displayObject = disp; + _name = name; + if (! setDefaults) return; + alpha = 1; + display = "block"; + left = "50%"; + top = "50%"; + if (disp) { + width = disp.width || "50%"; + height = disp.height || "50%"; + } + } + + public function clone():Cloneable { + var copy:DisplayPropertiesImpl = new DisplayPropertiesImpl(); + copyFields(this, copy); + return copy; + } + + protected function copyFields(from:DisplayProperties, to:DisplayPropertiesImpl):void { + to._dimensions = from.dimensions.clone() as Dimensions; + to._alpha = from.alpha; + to._zIndex = from.zIndex; + to._name = from.name; + to._display = from.display; + to._displayObject = from.getDisplayObject(); + to._position = from.position.clone(); + } + + public static function fullSize(name:String):DisplayPropertiesImpl { + var props:DisplayPropertiesImpl = new DisplayPropertiesImpl(); + props.name = name; + props.left = "50%"; + props.top = "50%"; + props.width = "100%"; + props.height = "100%"; + return props; + } + + public function getDisplayObject():DisplayObject { + return _displayObject; + } + + public function setDisplayObject(displayObject:DisplayObject):void { + _displayObject = displayObject; + } + + public function set width(value:Object):void { + _dimensions.widthValue = value; + } + + public function get widthPx():Number { + return _dimensions.width.px; + } + + public function get widthPct():Number { + return _dimensions.width.pct; + } + + public function set height(value:Object):void { + _dimensions.heightValue = value; + } + + public function get heightPx():Number { + return _dimensions.height.px; + } + + public function get heightPct():Number { + return _dimensions.height.pct; + } + + public function set alpha(value:Number):void { + _alpha = value; + } + + public function get alpha():Number { + return _alpha; + } + + public function set zIndex(value:Number):void { + _zIndex = value; + } + + [Value] + public function get zIndex():Number { + return _zIndex; + } + + [Value] + public function get display():String { + return _display; + } + + public function set display(value:String):void { + _display = value; + } + + public function get visible():Boolean { + return _display == "block"; + } + + public function toString():String { + return "[DisplayPropertiesImpl] '" + _name + "'"; + } + + [Value] + override public function get name():String { + return _name; + } + + public function set name(name:String):void { + _name = name; + } + + public function get position():Position { + return _position; + } + + public function set top(top:Object):void { + _position.topValue = top; + } + + public function set right(value:Object):void { + _position.rightValue = value; + } + + public function set bottom(value:Object):void { + _position.bottomValue = value; + } + + public function set left(value:Object):void { + _position.leftValue = value; + } + + public function hasValue(property:String):Boolean { + return _position.hasValue(property) || _dimensions.hasValue(property); + } + + public function set opacity(value:Number):void { + alpha = value; + } + + [Value] + public function get opacity():Number { + return alpha; + } + + public function get dimensions():Dimensions { + return _dimensions; + } + + [Value(name="width")] + public function get widthObj():Object { + return _dimensions.width.asObject(); + } + + [Value(name="height")] + public function get heightStr():Object { + return _dimensions.height.asObject(); + } + + [Value(name="top")] + public function get topStr():Object { + return _position.top.asObject(); + } + + [Value(name="right")] + public function get rightStr():Object { + return _position.right.asObject(); + } + + [Value(name="bottom")] + public function get bottomStr():Object { + return _position.bottom.asObject(); + } + + [Value(name="left")] + public function get leftStr():Object { + return _position.left.asObject(); + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/DynamicCuepoint.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/DynamicCuepoint.as new file mode 100644 index 0000000000000000000000000000000000000000..e1875369abe6ff85010bcf88c5db346c848b3311 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/DynamicCuepoint.as @@ -0,0 +1,42 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import org.flowplayer.model.Cuepoint; + + /** + * @author api + */ + internal dynamic class DynamicCuepoint extends Cuepoint { + public function DynamicCuepoint(time:int, callbackId:String) { + super(time, callbackId); + } + + override protected function onClone(clone:Cuepoint):void { + // copy dynamic properties + for (var prop:String in this) { + try { + clone[prop] = this[prop]; + } catch (e:Error) { + log.error("Error when cloning cuepoint " + e); + } + } + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ErrorCode.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ErrorCode.as new file mode 100644 index 0000000000000000000000000000000000000000..88e4394fac8b56bf49aaa19d0b95feb6c40989e5 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ErrorCode.as @@ -0,0 +1,47 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + + public class ErrorCode { + + + private var _eventType:EventType; + private var _code:int; + private var _message:String; + + public function ErrorCode(eventType:EventType, code:int, message:String) { + _eventType = eventType; + _code = code; + _message = message; + } + + public function get eventType():EventType { + return _eventType; + } + + public function get message():String { + return _message; + } + + public function get code():int { + return _code; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/EventDispatcher.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/EventDispatcher.as new file mode 100644 index 0000000000000000000000000000000000000000..8eb3cbd1e7b98c8989e493190f3d9b4c354d75d6 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/EventDispatcher.as @@ -0,0 +1,226 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import flash.utils.Dictionary; + + import org.flowplayer.flow_internal; + import org.flowplayer.util.Log; + use namespace flow_internal; + + /** + * @author api + */ + public class EventDispatcher { + protected var log:Log = new Log(this); + private var _beforeListeners:Dictionary = new Dictionary(); + private var _listeners:Dictionary = new Dictionary(); + protected static var _playerId:String; + + /** + * Unbinds the specified listener. + * + * @param listener the listener to unbind + * @param event the type of the event from which the listener is removed, if <code>null</code> it's removed from all event types + * @param beforePhase if <code>true</code> the listener is removed from the before phase, otherwise it's removed from the normal event phase + */ + public final function unbind(listener:Function, event:EventType = null, beforePhase:Boolean = false):void { + if (event) { + removeListener(event, listener, beforePhase); + } else { + removeAllEventsListener(listener, beforePhase); + } + } + + flow_internal function setListener(event:EventType, listener:Function, clipFilter:Function = null, beforePhase:Boolean = false, addToFront:Boolean = false):void { + if (event) { + addListener(event, new EventListener(listener, clipFilter), beforePhase, addToFront); + } else { + log.debug("adding listeners, beforePhase " + beforePhase); + addAllEventsListener(beforePhase ? cancellableEvents : allEvents, new EventListener(listener, clipFilter), beforePhase, addToFront); + } + } + + protected function get cancellableEvents():Dictionary { + throw new Error("cancellableEvents should be overridden the subclass"); + return null; + } + + protected function get allEvents():Dictionary { + throw new Error("allEvents should be overridden the subclass"); + return null; + } + + private function removeAllEventsListener(listener:Function, beforePhase:Boolean):void { + for each (var type:Object in (beforePhase ? cancellableEvents : allEvents)) { + removeListener(type as ClipEventType, listener, beforePhase); + } + } + + private function addAllEventsListener(events:Dictionary, listener:EventListener, beforePhase:Boolean, addToFront:Boolean = false):void { + log.debug("addAllEventsListener, beforePhase " + beforePhase); + for each (var type:Object in events) { + addListener(type as ClipEventType, listener, beforePhase, addToFront); + } + } + + private function dispatchExternalEvent(event:AbstractEvent, beforePhase:Boolean = false):void { + if (! _playerId) return; + var externalReturnVal:Boolean = event.fireExternal(_playerId, beforePhase); + if (! externalReturnVal) { + log.debug("preventing default"); + event.preventDefault(); + } + } + /** + * Dispatches an event to the before phase listeners. + * @param event the event to dispatch + * @param fireExternal dispatch also to external plugins + * @return false if event propagation was stopped + */ + flow_internal final function doDispatchBeforeEvent(event:AbstractEvent, fireExternal:Boolean):Boolean { + log.debug("doDispatchBeforeEvent, fireExternal " + fireExternal); + if (! event.isCancellable()) { + log.debug("event is not cancellable, will not fire event, propagation is allowed"); + return true; + } + if (event.target == null) { + event.target = this; + } + if (fireExternal) { + dispatchExternalEvent(event, true); + } + _dispatchEvent(event, _beforeListeners); + return ! event.isDefaultPrevented(); + } + + /** + * Dispatches the event to the action phase listeners. + */ + flow_internal final function doDispatchEvent(event:AbstractEvent, fireExternal:Boolean):void { + if (event.info is ErrorCode) { + doDispatchErrorEvent(event, fireExternal); + return; + } + if (event.target == null) { + event.target = this; + } + if (fireExternal) { + dispatchExternalEvent(event); + } + _dispatchEvent(event, _listeners); + } + + /** + * Dispatches an error event to the action phase listeners. + */ + flow_internal final function doDispatchErrorEvent(event:AbstractEvent, fireExternal:Boolean):void { + if (event.target == null) { + event.target = this; + } + if (fireExternal) { + event.fireErrorExternal(_playerId); + } + _dispatchEvent(event, _listeners); + } + + private function _dispatchEvent(event:AbstractEvent, listenerDict:Dictionary):void { + log.info(this + " dispatchEvent(), event " + event); + var listeners:Array = listenerDict[event.eventType]; + var notified:Array = []; + if (! listeners) { + log.debug(this + ": dispatchEvent(): no listeners for event " + event.eventType + (listenerDict == _beforeListeners ? " in before phase" : "")); + return; + } + for (var i : Number = 0; i < listeners.length; i++) { + var listener:EventListener = listeners[i]; + if (notified.indexOf(listener) < 0) { + if (listener == null) { + log.error("found null listener"); + } + + if ( CONFIG::debug ) { + try { + listener.notify(event); + } catch(e:Error) { + log.error("Got error while dispatching " + event.eventType.name, e); + } + } else { + listener.notify(event); + } + + + notified.push(listener); + if (event.isPropagationStopped()) { + return; + } + } + } + return; + } + + private function addListener(event:EventType, listener:EventListener, beforePhase:Boolean, addToFront:Boolean = false):void { + log.debug(this + ": adding listener for event " + event + (beforePhase ? " to before phase" : "")); + var listenerDict:Dictionary = beforePhase ? _beforeListeners : _listeners; + var listeners:Array = listenerDict[event]; + if (! listeners) { + listeners = new Array(); + listenerDict[event] = listeners; + } + if (! hasListener(event, listener)) { + if (addToFront) { + listeners.splice(0, 0, listener); + } else { + listeners.push(listener); + } + } + } + + internal function removeListener(event:EventType, listener:Function, beforePhase:Boolean = false):void { + doRemoveListener(beforePhase ? _beforeListeners : _listeners, event, listener); + } + + private function doRemoveListener(listenerDict:Dictionary, event:EventType, listener:Function):void { + var listeners:Array = listenerDict[event]; + if (! listeners) return; + for (var i : Number = 0; i < listeners.length; i++) { + var eventListener:EventListener = listeners[i]; + if (eventListener.listener == listener) { + listeners.splice(i, 1); + } + } + } + + private function hasListener(event:EventType, listener:EventListener):Boolean { + var listeners:Array = _listeners[event]; + if (! listeners) return false; + for (var i : Number = 0; i < listeners.length; i++) { + var eventListener:EventListener = listeners[i]; + if (eventListener.listener == listener.listener) { + return true; + } + } + return false; + } + + public static function set playerId(playerId:String):void { + _playerId = playerId; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/EventListener.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/EventListener.as new file mode 100644 index 0000000000000000000000000000000000000000..b7e3a48465aa7f6c2c2110bfff94670eee6f79ab --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/EventListener.as @@ -0,0 +1,56 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import org.flowplayer.util.Assert; + import org.flowplayer.util.Log; + + /** + * @author api + */ + internal class EventListener { + + private var log:Log = new Log(this); + private var _listener:Function; + private var _clipFilter:Function; + + public function EventListener(listener:Function, clipFilter:Function) { + _listener = listener; + _clipFilter = clipFilter; + } + + public function notify(event:AbstractEvent):Boolean { + Assert.notNull(event.target, "event target cannot be null"); + if (_clipFilter != null) { + log.debug("clip filter returns " + _clipFilter(event.target as Clip)); + } + if (_clipFilter != null && event.target && ! _clipFilter(event.target as Clip)) { + log.debug(event + " was filtered out for this listener"); + return false; + } + log.debug("notifying listener for event " + event); + _listener(event); + return true; + } + + public function get listener():Function { + return _listener; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/EventType.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/EventType.as new file mode 100644 index 0000000000000000000000000000000000000000..375987aaa41579eb3b95aee37bef2bc04df77877 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/EventType.as @@ -0,0 +1,29 @@ +package org.flowplayer.model { + import flash.utils.Dictionary; + + /** + * @author anssi + */ + public class EventType { + private var _name:String; + private var _custom:Boolean; + + public function EventType(name:String, custom:Boolean = false) { + _name = name; + _custom = custom; + } + + public function get isCancellable():Boolean { + throw new Error("isCancellable() not overridden"); + return false; + } + + public function get name():String { + return _name; + } + + public function get custom():Boolean { + return _custom; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/FontProvider.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/FontProvider.as new file mode 100644 index 0000000000000000000000000000000000000000..193f588de722857c0ee88daa09a7dda0a9e4bc2d --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/FontProvider.as @@ -0,0 +1,32 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + + /** + * Interface to be implemented by plugins that provide a font to be used by the player. + * FontProviders should only provide a font and do nothing else - they cannot be shown + * on player's Panel, for example. + */ + public interface FontProvider { + + function get fontFamily():String; + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Identifiable.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Identifiable.as new file mode 100644 index 0000000000000000000000000000000000000000..c345825468b438d922fe19c0c9ea9ea417a8630e --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Identifiable.as @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + + /** + * @author api + */ + public interface Identifiable { + + function get name():String; + + function set name(name:String):void; + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Loadable.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Loadable.as new file mode 100644 index 0000000000000000000000000000000000000000..332c1e152f324d64455ba137c91eb2746b170582 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Loadable.as @@ -0,0 +1,124 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import flash.utils.getDefinitionByName; + + import org.flowplayer.config.Config; + + import flash.display.DisplayObject; + + import org.flowplayer.util.PropertyBinder; + /** + * @author api + */ + public class Loadable extends PluginEventDispatcher { + + private var _name:String; + private var _url:String; + private var _type:String; + private var _config:Object; + private var _plugin:PluginModel; + private var _playerConfig:Config; + private var _loadFailed:Boolean; + + public function Loadable(name:String, playerConfig:Config, url:String = null) { + _name = name; + _playerConfig = playerConfig; + _url = url; + } + + public function createDisplayPlugin(disp:DisplayObject):DisplayPluginModel { + if (!_plugin) { + _plugin = _playerConfig.getPlugin(disp, _name, _config); + _plugin.url = _url; + } + return _plugin as DisplayPluginModel; + } + + public function createProvider(provider:Object):ProviderModel { + if (!_plugin) { + _plugin = (new PropertyBinder(new ProviderModel(provider, _name), "config")).copyProperties(_config) as PluginModel; + _plugin.url = _url; + } + return _plugin as ProviderModel; + } + + public function createPlugin(plugin:Object):PluginModel { + if (!_plugin) { + _plugin = (new PropertyBinder(new PluginModelImpl(plugin, _name), "config")).copyProperties(_config) as PluginModel; + _plugin.url = _url; + } + return _plugin as PluginModel; + } + + public function instantiate():Object { + var PluginClass:Class = Class(getDefinitionByName(_url)); + return new PluginClass(); + } + + public function get url():String { + return _url; + } + + public function set url(url:String):void { + _url = url; + } + + public function get config():Object { + return _config; + } + + public function set config(config:Object):void { + _config = config; + } + + override public function get name():String { + return _name; + } + + public function toString():String { + return "[Loadable] '" + _name + "', builtIn " + isBuiltIn; + } + + public function get plugin():PluginModel { + return _plugin; + } + + public function get loadFailed():Boolean { + return _loadFailed; + } + + public function set loadFailed(val:Boolean):void { + _loadFailed = val; + } + + public function get type():String { + return _type; + } + + public function set type(type:String):void { + _type = type; + } + + public function get isBuiltIn():Boolean { + return _url && _url.toLowerCase().indexOf(".swf") < 0; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Logo.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Logo.as new file mode 100644 index 0000000000000000000000000000000000000000..2824388cb762b1e378703d7ab3202871f0ade9c0 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Logo.as @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import flash.display.DisplayObject; + + import org.flowplayer.model.DisplayPropertiesImpl; + + /** + * @author api + */ + public class Logo extends DisplayPluginModelImpl { + + private var _fullscreenOnly:Boolean = true; + private var _fadeSpeed:Number; + private var _displayTime:int = 0; + private var _linkUrl:String; + private var _linkWindow:String; + + public function Logo(disp:DisplayObject, name:String):void { + super(disp, name, false); + name = "logo"; + top = "20"; + right = "20"; + alpha = 1; + + _linkWindow = "_self"; + } + + override public function clone():Cloneable { + var copy:Logo = new Logo(getDisplayObject(), name); + copyFields(this, copy); + copy.url = url; + copy.fullscreenOnly = _fullscreenOnly; + copy.fadeSpeed = _fadeSpeed; + copy.displayTime = _displayTime; + copy.linkUrl = _linkUrl; + copy.linkWindow = _linkWindow; + return copy; + } + + [Value] + public function get fullscreenOnly():Boolean { + return _fullscreenOnly; + } + + public function set fullscreenOnly(fullscreenOnly:Boolean):void { + _fullscreenOnly = fullscreenOnly; + } + [Value] + public function get fadeSpeed():Number { + return _fadeSpeed; + } + + public function set fadeSpeed(fadeSpeed:Number):void { + _fadeSpeed = fadeSpeed; + } + + [Value] + public function get displayTime():int { + return _displayTime; + } + + public function set displayTime(displayTime:int):void { + _displayTime = displayTime; + } + + [Value] + public function get linkUrl():String { + return _linkUrl; + } + + public function set linkUrl(linkUrl:String):void { + _linkUrl = linkUrl; + } + + [Value] + public function get linkWindow():String { + return _linkWindow; + } + + public function set linkWindow(linkWindow:String):void { + _linkWindow = linkWindow; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/MediaSize.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/MediaSize.as new file mode 100644 index 0000000000000000000000000000000000000000..c354dbbb30cc45f5d315c8111cea936f60f24ecc --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/MediaSize.as @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import flash.utils.Dictionary; + + /** + * @author api + */ + public class MediaSize { + + public static const FITTED_PRESERVING_ASPECT_RATIO:MediaSize = new MediaSize("fit"); + public static const HALF_FROM_ORIGINAL:MediaSize = new MediaSize("half"); + public static const ORIGINAL:MediaSize = new MediaSize("orig"); + public static const FILLED_TO_AVAILABLE_SPACE:MediaSize = new MediaSize("scale"); + public static const CROP_TO_AVAILABLE_SPACE:MediaSize = new MediaSize("crop"); + + public static var ALL_VALUES:Dictionary = new Dictionary(); + { + ALL_VALUES[FITTED_PRESERVING_ASPECT_RATIO._value] = FITTED_PRESERVING_ASPECT_RATIO; + ALL_VALUES[HALF_FROM_ORIGINAL._value] = HALF_FROM_ORIGINAL; + ALL_VALUES[ORIGINAL._value] = ORIGINAL; + ALL_VALUES[FILLED_TO_AVAILABLE_SPACE._value] = FILLED_TO_AVAILABLE_SPACE; + ALL_VALUES[CROP_TO_AVAILABLE_SPACE._value] = CROP_TO_AVAILABLE_SPACE; + } + + private static var enumCreated:Boolean; + { enumCreated = true; + } + + private var _value:String; + + public function MediaSize(value:String) { + if (enumCreated) + throw new Error("Cannot create ad-hoc MediaSize instances"); + this._value = value; + } + + public static function forName(name:String):MediaSize { + return ALL_VALUES[name]; + } + + public function toString():String { + return "[MediaSize] '" + _value + "'"; + } + + public function get value():String { + return _value; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/NullClip.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/NullClip.as new file mode 100644 index 0000000000000000000000000000000000000000..f8be40b0fa00ac43abd1c22e48807636ebbe20d8 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/NullClip.as @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + /** + * @author api + */ + internal class NullClip extends Clip { + + public function NullClip() { + url = "null clip"; + autoPlay = false; + autoBuffering = false; + type = ClipType.VIDEO; + } + + override public function get isNullClip():Boolean { + return true; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PlayButtonOverlay.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PlayButtonOverlay.as new file mode 100644 index 0000000000000000000000000000000000000000..f75e97e3d992938feb754cf0297f50a942609a47 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PlayButtonOverlay.as @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import org.flowplayer.model.DisplayPropertiesImpl; + + /** + * @author api + */ + public class PlayButtonOverlay extends DisplayPluginModelImpl { + + private var _fadeSpeed:int; + private var _rotateSpeed:int; + private var _label:String; + private var _replayLabel:String; + private var _buffering:Boolean; + + public function PlayButtonOverlay() { + super(null, "play", false); + // these are used initially before screen is arranged + // once screen is availabe, these will be overridden + top = "50%"; + left = "50%"; + width = "22%"; + height = "22%"; + display = "block"; + _buffering = true; + _rotateSpeed = 50; + _fadeSpeed = 500; + _replayLabel = "Play again"; + } + + override public function clone():Cloneable { + var copy:PlayButtonOverlay = new PlayButtonOverlay(); + copyFields(this, copy); + copy.fadeSpeed = this.fadeSpeed; + copy.rotateSpeed = this.rotateSpeed; + copy.url = this.url; + copy.label = this.label; + copy.replayLabel = this.replayLabel; + copy.buffering = this.buffering; + return copy; + } + + [Value] + public function get fadeSpeed():int { + return _fadeSpeed; + } + + public function set fadeSpeed(fadeSpeed:int):void { + _fadeSpeed = fadeSpeed; + } + + [Value] + public function get rotateSpeed():int { + if (_rotateSpeed > 100) return 100; + return _rotateSpeed; + } + + public function set rotateSpeed(rotateSpeed:int):void { + _rotateSpeed = rotateSpeed; + } + + [Value] + public function get label():String { + return _label; + } + + public function set label(label:String):void { + _label = label; + } + + [Value] + public function get replayLabel():String { + return _replayLabel; + } + + public function set replayLabel(replayLabel:String):void { + _replayLabel = replayLabel; + } + + [Value] + public function get buffering():Boolean { + return _buffering; + } + + public function set buffering(buffering:Boolean):void { + _buffering = buffering; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PlayerError.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PlayerError.as new file mode 100644 index 0000000000000000000000000000000000000000..599541966e63eaf7f07b8e506836f7668c9dba8c --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PlayerError.as @@ -0,0 +1,38 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import org.flowplayer.model.ErrorCode; + + /** + * @author api + */ + public class PlayerError extends ErrorCode { + + public static const INIT_FAILED:PlayerError = new PlayerError(PlayerEventType.ERROR, 300, "Player initialization failed"); + public static const PLUGIN_LOAD_FAILED:PlayerError = new PlayerError(PlayerEventType.ERROR, 301, "Unable to load plugin"); + public static const PLUGIN_INVOKE_FAILED:PlayerError = new PlayerError(PlayerEventType.ERROR, 302, "Error when invoking plugin external method"); + public static const RESOURCE_LOAD_FAILED:PlayerError = new PlayerError(PlayerEventType.ERROR, 303, "Failed to load a resource"); + public static const INSTREAM_PLAY_NOTPLAYING:PlayerError = new PlayerError(PlayerEventType.ERROR, 304, "Cannot start instream playback, when not playing currently"); + + public function PlayerError(eventType:EventType, code:int, message:String) { + super(eventType, code, message); + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PlayerEvent.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PlayerEvent.as new file mode 100644 index 0000000000000000000000000000000000000000..ecc0e735154bca370be886929a15e82747bd0550 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PlayerEvent.as @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import flash.events.Event; + + /** + * Event related to the whole player. + * @author api + */ + public class PlayerEvent extends AbstractEvent { + + public function PlayerEvent(eventType:EventType, info:Object = null, info2:Object = null, info3:Object = null) { + super(eventType, info, info2, info3); + } + + public static function load(eventObject:Object = null):PlayerEvent { + return new PlayerEvent(PlayerEventType.LOAD, eventObject); + } + + public static function keyPress(eventObject:Object = null):PlayerEvent { + return new PlayerEvent(PlayerEventType.KEYPRESS, eventObject); + } + + public static function mute(eventObject:Object = null):PlayerEvent { + return new PlayerEvent(PlayerEventType.MUTE, eventObject); + } + + public static function unMute(eventObject:Object = null):PlayerEvent { + return new PlayerEvent(PlayerEventType.UNMUTE, eventObject); + } + + public static function volume(eventObject:Object = null):PlayerEvent { + return new PlayerEvent(PlayerEventType.VOLUME, eventObject); + } + + public static function fullscreen(eventObject:Object = null):PlayerEvent { + return new PlayerEvent(PlayerEventType.FULLSCREEN, eventObject); + } + + public static function fullscreenExit(eventObject:Object = null):PlayerEvent { + return new PlayerEvent(PlayerEventType.FULLSCREEN_EXIT, eventObject); + } + + public static function mouseOver(eventObject:Object = null):PlayerEvent { + return new PlayerEvent(PlayerEventType.MOUSE_OVER, eventObject); + } + + public static function mouseOut(eventObject:Object = null):PlayerEvent { + return new PlayerEvent(PlayerEventType.MOUSE_OUT, eventObject); + } + + public override function clone():Event { + return new PlayerEvent(eventType, info); + } + + public override function toString():String { + return formatToString("PlayerEvent", "type", "info"); + } + + protected override function get externalEventArgument():Object { + return info; + } + + protected override function get externalEventArgument2():Object { + return info2; + } + + protected override function get externalEventArgument3():Object { + return info3; + } + + protected override function get externalEventArgument4():Object { + return null; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PlayerEventType.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PlayerEventType.as new file mode 100644 index 0000000000000000000000000000000000000000..7d1f0eedd6e48f29598680e6ab67c0e07bd38ca2 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PlayerEventType.as @@ -0,0 +1,56 @@ +package org.flowplayer.model { + import flash.utils.Dictionary; + + import org.flowplayer.model.EventType; + /** + * @author anssi + */ + public class PlayerEventType extends EventType { + public static const LOAD:PlayerEventType = new PlayerEventType("onLoad"); + public static const UNLOAD:PlayerEventType = new PlayerEventType("onUnload"); + public static const KEYPRESS:PlayerEventType = new PlayerEventType("onKeyPress"); + + public static const MUTE:PlayerEventType = new PlayerEventType("onMute"); + public static const UNMUTE:PlayerEventType = new PlayerEventType("onUnmute"); + public static const VOLUME:PlayerEventType = new PlayerEventType("onVolume"); + public static const FULLSCREEN:PlayerEventType = new PlayerEventType("onFullscreen"); + public static const FULLSCREEN_EXIT:PlayerEventType = new PlayerEventType("onFullscreenExit"); + public static const MOUSE_OVER:PlayerEventType = new PlayerEventType("onMouseOver"); + public static const MOUSE_OUT:PlayerEventType = new PlayerEventType("onMouseOut"); + public static const ERROR:PlayerEventType = new PlayerEventType("onError"); + + private static var _allValues:Dictionary; + private static var _cancellable:Dictionary = new Dictionary(); + { + _cancellable[KEYPRESS.name] = KEYPRESS; + _cancellable[MUTE.name] = MUTE; + _cancellable[UNMUTE.name] = UNMUTE; + _cancellable[VOLUME.name] = VOLUME; + _cancellable[FULLSCREEN.name] = FULLSCREEN; + } + + public function PlayerEventType(name:String) { + super(name); + if (! _allValues) { + _allValues = new Dictionary(); + } + _allValues[name] = this; + } + + override public function get isCancellable():Boolean { + return _cancellable[this.name]; + } + + public static function get cancellable():Dictionary { + return _cancellable; + } + + public static function get all():Dictionary { + return _allValues; + } + + public function toString():String { + return "[PlayerEventType] '" + name + "'"; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Playlist.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Playlist.as new file mode 100644 index 0000000000000000000000000000000000000000..2b416620685b7afd6369d801a3f89102e72284c9 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Playlist.as @@ -0,0 +1,312 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import org.flowplayer.flow_internal; + + use namespace flow_internal; + /** + * @author anssi + */ + public class Playlist extends ClipEventSupport { + + private var _currentPos:Number; + private var _inStreamClip:Clip; + private var _commonClip:Clip; + private var _clips:Array; + + public function Playlist(commonClip:Clip = null) { + if (commonClip == null) { + commonClip = new NullClip(); + } + super(commonClip); + _commonClip = commonClip; + _commonClip.setParentPlaylist(this); + initialize(); + } + + private function initialize(newClips:Array = null):void { + _clips = new Array(); + _inStreamClip = null; + if (newClips) { + for (var i:Number = 0; i < newClips.length; i++) { + doAddClip(newClips[i]); + } + } + super.setClips(_clips); + _currentPos = 0; + log.debug("initialized, current clip is " + current); + } + + // doc: PlayEventType.PLAYLIST_CHANGED + + /** + * Discards all clips and adds the specified clip to the list. + */ + public function replaceClips(clip:Clip):void { + doReplace([clip]); + } + + /** + * Discards all clips and addes the specified clips to the list. + */ + public function replaceClips2(clips:Array):void { + doReplace(clips); + } + + override flow_internal function setClips(clips:Array):void { + for (var i:Number = 0; i < clips.length; i++) { + doAddClip(clips[i], -1, false); + } + super.setClips(_clips); + } + + private function doReplace(newClips:Array, silent:Boolean = false):void { + var oldClips:Array = _clips.concat([]); + initialize(newClips); + if (! silent) { + dispatchPlaylistReplace(oldClips); + } + } + + flow_internal function dispatchPlaylistReplace(oldClips:Array = null):void { + log.debug("dispatchPlaylistReplace"); + var oldClipsEventHelper:ClipEventSupport = new ClipEventSupport(_commonClip, oldClips || []); + doDispatchEvent(new ClipEvent(ClipEventType.PLAYLIST_REPLACE, oldClipsEventHelper), true); } + + + /** + * Adds a new clip into the playlist. Insertion of clips does not change the current clip. + * @param clip + * @param pos optional insertion point, if not given the clip is added to the end of the list. + * @param silent if true does not dispatch the CLIP_ADD event + * @see ClipEventType#CLIP_ADD + */ + public function addClip(clip:Clip, pos:int = -1, silent:Boolean = false):void { + var index:Number = positionOf(pos); + if (clip.position >= 0 || clip.position == -1 || clip.position == -2) { + addChildClip(clip, pos); + return; + } + log.debug("current clip " + current); + if (current.isNullClip || current == commonClip) { + log.debug("replacing common/null clip"); + // we only have the common clip or a common clip, perform a playlist replace! + doReplace([clip], true); + } else { + doAddClip(clip, pos); + if (pos >= 0 && pos <= currentIndex && hasNext()) { + log.debug("addClip(), moving to next clip"); + next(); + } + super.setClips(_clips); + } + if (! silent) { + doDispatchEvent(new ClipEvent(ClipEventType.CLIP_ADD, pos >= 0 ? pos : clips.length - 1), true); + } + } + + /** + * Removes the specified child clip. + * @param clip + * @return + */ + public function removeChildClip(clip:Clip):void { + clip.unbindEventListeners(); + clip.parent.removeChild(clip); + } + + private function addChildClip(clip:Clip, pos:int, dispatchEvent:Boolean = true):void { + log.debug("addChildClip " + clip + ", index " + pos + ", dispatchEvenbt " + dispatchEvent); + if (pos == -1) { + pos = clips.length - 1; + } + var parent:Clip = clips[pos]; + parent.addChild(clip); + if (clip.position == 0) { + _clips.splice(_clips.indexOf(parent), 0, clip); + } else if (clip.position == -1) { + _clips.splice(_clips.indexOf(parent) + 1, 0, clip); + } + clip.setParentPlaylist(this); + clip.setEventListeners(this); + if (dispatchEvent) { + doDispatchEvent(new ClipEvent(ClipEventType.CLIP_ADD, pos, clip), true); + } + } + + private function doAddClip(clip:Clip, pos:int = -1, dispatchEvents:Boolean = true):void { + log.debug("doAddClip() " + clip); + clip.setParentPlaylist(this); + var currentInPos:Clip; + if (pos == -1) { + _clips.push(clip); + } else { + currentInPos = clips[pos]; + _clips.splice(_clips.indexOf(currentInPos.preroll || currentInPos), 0, clip); + } + var nested:Array = clip.playlist; + for (var i:int = 0; i < nested.length; i++) { + var nestedClip:Clip = nested[i] as Clip; + addChildClip(nestedClip, pos, dispatchEvents); + } + + log.debug("clips now " + _clips); + + if (clip != _commonClip) { + clip.onAll(_commonClip.onClipEvent); + log.debug("adding listener to all before events, common clip listens to other clips"); + clip.onBeforeAll(_commonClip.onBeforeClipEvent); + } + } + + /** + * Gets the clip with the specified index. + * @param index of the clip to retrieve, if -1 returns the common clip + */ + public function getClip(index:Number):Clip { + if (index == -1) return _commonClip; + if (clips.length == 0) return new NullClip(); + return clips[index]; + } + + public function get length():Number { + return clips.length; + } + + public function hasNext(skipPreAndPostRolls:Boolean = true):Boolean { + if (skipPreAndPostRolls) { + return current.index < length - 1; + } + return _currentPos < _clips.length - 1; + } + + public function hasPrevious(skipPreAndPostRolls:Boolean = true):Boolean { + return (skipPreAndPostRolls ? current.index : _currentPos) > 0; + } + + public function get current():Clip { + if (_inStreamClip) return _inStreamClip; + if (_currentPos == -1) return null; + if (_clips.length == 0) return new NullClip(); + return _clips[_currentPos]; + } + + public function get currentPreroll():Clip { + if (_currentPos == -1 ) return null; + if (_clips.length == 0) return null; + if (_inStreamClip) return null; + var parent:Clip = _clips[_currentPos]; + return parent.preroll; + } + + public function setInStreamClip(clip:Clip):void { + log.debug("setInstremClip to " + clip); + if (clip && _inStreamClip) throw new Error("Already playing an instream clip"); + _inStreamClip = clip; + } + + public function set current(clip:Clip):void { + toIndex(indexOf(clip)); + } + + public function get currentIndex():Number { + return current.index; + } + + public function next(skipPreAndPostRolls:Boolean = true):Clip { + if (skipPreAndPostRolls) { + log.debug("skipping pre and post rolls"); + var pos:int = current.index; + if (pos+1 > length) return null; + var clip:Clip = clips[pos+1]; + _currentPos = _clips.indexOf(clip.preroll || clip); + return clip.preroll || clip; + } + if (_currentPos+1 >= _clips.length) return null; + return _clips[++_currentPos]; + } + + public function get nextClip():Clip { + log.debug("nextClip()"); + if (_currentPos == _clips.length - 1) return null; + return _clips[_currentPos + 1]; + } + + public function get previousClip():Clip { + if (_currentPos == 0) return null; + return _clips[_currentPos - 1]; + } + + public function previous(skipPreAndPostRolls:Boolean = true):Clip { + if (skipPreAndPostRolls) { + log.debug("skipping pre and post rolls"); + var pos:int = current.index; + if (pos+1 < 0) return null; + var clip:Clip = clips[pos-1]; + _currentPos = _clips.indexOf(clip.preroll || clip); + return clip.preroll || clip; + } + if (_currentPos - 1 < 0) return null; + return _clips[--_currentPos]; + } + + public function toIndex(index:Number):Clip { + if (index < 0) return null; + var parentClips:Array = clips; + if (index >= parentClips.length) return null; + var clip:Clip = parentClips[index]; + _inStreamClip = null; + _currentPos = _clips.indexOf(clip.preroll || clip); + return clip.preroll || clip; + } + + private function positionOf(index:Number):Number { + var parentClips:Array = clips; + var clip:Clip = parentClips[index]; + return clip ? _clips.indexOf(clip.preroll || clip) : 0; + } + + public function indexOf(clip:Clip):Number { + return clips.indexOf(clip); + } + + public function toString():String { + return "[playList] length " + _clips.length + ", clips " + _clips; + } + + public function get commonClip():Clip { + return _commonClip; + } + + /** + * Does this playlist have a clip with the specified type? + */ + public function hasType(type:ClipType):Boolean { + var clips:Array = _clips.concat(childClips); + for (var i:Number = 0; i < clips.length; i++) { + var clip:Clip = Clip(clips[i]); + + if (clip.type == type) { + return true; + } + } + return false; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Plugin.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Plugin.as new file mode 100644 index 0000000000000000000000000000000000000000..1e0a879eb75c2c85348378285abc5d0717a264c0 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Plugin.as @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import org.flowplayer.view.Flowplayer; + + /** + * Plugin lifecycle interface that can be optionally implemented by plugins. + * This interface provides plugins with: + * <ul> + * <li>The ability to interact with Flowplaeyr API.</li> + * <li>Optain the configuration specified for the plugin in the player's configuration.</li> + * <li>The plugin can provide a default configuration object.</li> + * </ul> + * + * Lifecycle methods are invokek in following order: 1) onConfig(), 2) onLoad(), 3) getDefaultConfig(). + */ + public interface Plugin { + + /** + * Provided plugins configuration properties. + * This happens when the plugin SWF has been loaded but + * before it is added to the display list. + */ + function onConfig(configProps:PluginModel):void; + + /** + * Called when the player has been initialized. The interface is immediately ready to use, all + * other plugins have been loaded and initialized when this gets called. + * + * After this method has been called the plugin will be placed on the stage (on + * player's Panel). + */ + function onLoad(player:Flowplayer):void; + + /** + * Gets the default configuration to be used for this plugin. Called after onConfig() but + * before onLoad() + * @return default configuration object, <code>null</code> if no defaults are available + */ + function getDefaultConfig():Object; + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginError.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginError.as new file mode 100644 index 0000000000000000000000000000000000000000..85244ab00ac830e9a6414b932b0bbc4457697c6f --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginError.as @@ -0,0 +1,34 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + + /** + * Plugin error codes. + */ + public class PluginError extends ErrorCode { + + public static const INIT_FAILED:PluginError = new PluginError(100, "Plugin initialization failed"); + public static const ERROR:PluginError = new PluginError(200, "Error occurred in a plugin"); + + public function PluginError(code:int, message:String) { + super(PluginEventType.ERROR, code, message); + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginEvent.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginEvent.as new file mode 100644 index 0000000000000000000000000000000000000000..932a8a32910a831d40d0f127699d9d11b673f782 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginEvent.as @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import flash.events.Event; + import org.flowplayer.flow_internal; + import flash.external.ExternalInterface; + + use namespace flow_internal; + /** + * @author anssi + */ + public class PluginEvent extends AbstractEvent { + + public static const PLUGIN_EVENT:String = "onPluginEvent"; + private var _id:Object; + + public function PluginEvent(eventType:PluginEventType, pluginName:String, id:Object = null, info:Object = null, info2:Object = null, info3:Object = null) { + super(eventType, pluginName, info, info2, info3); + _id = id; + } + + override flow_internal function fireErrorExternal(playerId:String):void { + try { + ExternalInterface.call( + "flowplayer.fireEvent", + playerId || ExternalInterface.objectID, getExternalName(eventType.name, false), error.code, error.message + info2 ? ": " + info2 : ""); + } catch (e:Error) { + log.error("Error in fireErrorExternal() "+ e); + } + } + + override public function get error():ErrorCode { + return _id as ErrorCode; + } +// +// public override function clone():Event { +// return new PluginEvent(eventType as PluginEventType, info.toString(), _id, info2); +// } + + public override function toString():String { + return formatToString("PluginEvent", "id", "info", "info2", "info3", "info4", "info5"); + } + + /** + * Gets the event Id. + */ + public function get id():Object { + return _id; + } + + protected override function get externalEventArgument():Object { + return info; + } + + protected override function get externalEventArgument2():Object { + return _id; + } + + protected override function get externalEventArgument3():Object { + return info2; + } + + protected override function get externalEventArgument4():Object { + return info3; + } + + protected override function get externalEventArgument5():Object { + return info4; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginEventDispatcher.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginEventDispatcher.as new file mode 100644 index 0000000000000000000000000000000000000000..654e6ff91496d7cdfe636675fea273a5c30ec95a --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginEventDispatcher.as @@ -0,0 +1,90 @@ +package org.flowplayer.model { + import flash.utils.Dictionary; + + import org.flowplayer.flow_internal; + import org.flowplayer.model.EventDispatcher; + + use namespace flow_internal; + /** + * @author anssi + */ + public class PluginEventDispatcher extends EventDispatcher { + + /** + * Dispatches a plugin event. + * @param eventType the type of the event to dispatch + * @param eventId the ID for the event, this the ID used to distinguis between diferent generic plugin events + * @param info optional info object, will be passed to JavaScript + * @param info2 optional info object, will be passed to JavaScript + * @see PluginEvent#id + */ + public function dispatch(eventType:PluginEventType, eventId:Object = null, info:Object = null, info2:Object = null, info3:Object = null):void { + doDispatchEvent(new PluginEvent(eventType, name, eventId, info, info2, info3), true); + } + + /** + * Dispatches an event of type PluginEventType.LOAD + * @see PluginEventType#LOAD + */ + public function dispatchOnLoad():void { + dispatch(PluginEventType.LOAD); + } + + + /** + * Dispatches a plugin error event. + * @param error + * @param info optional info object, will be passed to JavaScript + * @see PluginEventType#ERROR + */ + public function dispatchError(error:PluginError, info:Object = null):void { + doDispatchErrorEvent(new PluginEvent(error.eventType as PluginEventType, name, error, info), true); + } + + /** + * Dispatches a plugin event in the before phase. + * + * @param eventType the type of the event to dispatch + * @param eventId the ID for the event, this the ID used to distinguis between diferent generic plugin events + * @param info optional info object, will be passed to JavaScript + * @param info2 optional info object, will be passed to JavaScript + * @return true if the event can continue, false if it was prevented + * @see PluginEvent#id + */ + public function dispatchBeforeEvent(eventType:PluginEventType, eventId:Object = null, info:Object = null, info2:Object = null, info3:Object = null):Boolean { + return doDispatchBeforeEvent(new PluginEvent(eventType, name, eventId, info, info2, info3), true); + } + + public function dispatchEvent(event:PluginEvent):void { + doDispatchEvent(event, true); + } + + public function onPluginEvent(listener:Function):void { + setListener(PluginEventType.PLUGIN_EVENT, listener); + } + + public function onBeforePluginEvent(listener:Function):void { + setListener(PluginEventType.PLUGIN_EVENT, listener, null, true); + } + + public function onLoad(listener:Function):void { + setListener(PluginEventType.LOAD, listener); + } + + public function onError(listener:Function):void { + setListener(PluginEventType.ERROR, listener); + } + + override protected function get cancellableEvents():Dictionary { + return PluginEventType.cancellable; + } + + override protected function get allEvents():Dictionary { + return PluginEventType.all; + } + + public function get name():String { + return null; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginEventType.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginEventType.as new file mode 100644 index 0000000000000000000000000000000000000000..b9a1e5919783cf4ef803d77220c37d4b399ee382 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginEventType.as @@ -0,0 +1,45 @@ +package org.flowplayer.model { + import flash.utils.Dictionary; + + import org.flowplayer.model.EventType; + + /** + * @author anssi + */ + public class PluginEventType extends EventType { + + public static const PLUGIN_EVENT:PluginEventType = new PluginEventType("onPluginEvent"); + public static const LOAD:PluginEventType = new PluginEventType("onLoad"); + public static const ERROR:PluginEventType = new PluginEventType("onError"); + + private static var _allValues:Dictionary; + private static var _cancellable:Dictionary = new Dictionary(); + { + _cancellable[PLUGIN_EVENT.name] = PLUGIN_EVENT; + } + + public function PluginEventType(name:String) { + super(name); + if (! _allValues) { + _allValues = new Dictionary(); + } + _allValues[name] = this; + } + + override public function get isCancellable():Boolean { + return _cancellable[this.name]; + } + + public static function get cancellable():Dictionary { + return _cancellable; + } + + public static function get all():Dictionary { + return _allValues; + } + + public function toString():String { + return "[PluginEventType] '" + name + "'"; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginFactory.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginFactory.as new file mode 100644 index 0000000000000000000000000000000000000000..96340319f5aa00ca6386719375bdd0e1bd248901 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginFactory.as @@ -0,0 +1,39 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + + /** + * An inteface for objects that create plugins. This is used when the plugin SWFs main class + * itself is not used as a plugin class. This is the case when the plugin is not a DisplayObject. + * The SWF main class is required to extend DisplayObject or any of it's subclasses and therefore + * it is not suitable for non-visual plugins that just implement logic. Providers are an example of + * non-visual plugins. + * + * The SWF main class can implement this interface. + */ + public interface PluginFactory { + + /** + * A factory method to create the plugin. Player uses the plugin object returned by this method, instead + * of the factory object itself. + */ + function newPlugin():Object; + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginMethod.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginMethod.as new file mode 100644 index 0000000000000000000000000000000000000000..d62d55244c385e3586962c0b0d91d07db18a96e6 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginMethod.as @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + + /** + * @author api + */ + public class PluginMethod { + private var _externalName:String; + private var _internalName:String; + private var _isGetter:Boolean; + private var _isSetter:Boolean; + private var _hasReturnValue:Boolean; + private var _convertResult:Boolean; + + public static function method(externalName:String, pluginFunctionName:String, hasReturnValue:Boolean, convertResult:Boolean):PluginMethod { + return new PluginMethod(externalName, pluginFunctionName, false, false, hasReturnValue, convertResult); + } + + public static function setter(externalName:String, pluginFunctionName:String):PluginMethod { + return new PluginMethod(externalName, pluginFunctionName, false, true); + } + + public static function getter(externalName:String, pluginFunctionName:String, convertResult:Boolean):PluginMethod { + return new PluginMethod(externalName, pluginFunctionName, true, false, true, convertResult); + } + + public function PluginMethod(externalName:String, pluginFunctionName:String, isGetter:Boolean = false, + isSetter:Boolean = false, hasReturnValue:Boolean = false, convertResult:Boolean = false) { + _externalName = externalName; + _internalName = pluginFunctionName; + if (_isGetter && isSetter) { + throw new Error("PluginMethod cannot be a setter and a getter at the same time"); + } + _isGetter = isGetter; + _isSetter = isSetter; + _hasReturnValue = hasReturnValue; + _convertResult = convertResult; + } + + public function get externalName():String { + return _externalName; + } + + public function get internalName():String { + return _internalName; + } + + public function get isGetter():Boolean { + return _isGetter; + } + + public function get isSetter():Boolean { + return _isSetter; + } + + public function get hasReturnValue():Boolean { + return _hasReturnValue; + } + + public function set hasReturnValue(hasReturnValue:Boolean):void { + _hasReturnValue = hasReturnValue; + } + + public function get convertResult():Boolean { + return _convertResult; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginMethodHelper.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginMethodHelper.as new file mode 100644 index 0000000000000000000000000000000000000000..e8f1d7efb1542e7553414ad92cb1eea3c7c3e901 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginMethodHelper.as @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import org.flowplayer.util.Log; + import org.flowplayer.util.ObjectConverter; + + /** + * @author api + */ + internal class PluginMethodHelper { + + private static var log:Log = new Log("org.flowplayer.model::PluginMethodHelper"); + + public static function getMethod(_methods:Array, externalName:String):PluginMethod { + for (var i : Number = 0; i < _methods.length; i++) { + var method:PluginMethod = _methods[i]; + if (method.externalName == externalName) { + return method; + } + } + return null; + } + + public static function invokePlugin(callable:Callable, plugin:Object, methodName:String, args:Array):Object { + var method:PluginMethod = callable.getMethod(methodName); + if (! method) { + throw new Error("Plugin does not have the specified method '" + methodName + "'"); + } + if (method.isGetter) { + log.debug("calling getter '" + method.internalName + "', of callable object " + callable); + return convert(method, plugin[method.internalName]); + } + if (method.isSetter) { + log.debug("calling setter '" + method.internalName + "', of callable object " + callable); + plugin[method.internalName] = args[0]; + return undefined; + } + log.debug("calling method '" + method.internalName + "', of callable object " + callable); + return convert(method, plugin[method.internalName].apply(plugin, args)); + } + + private static function convert(method:PluginMethod, param:Object):Object { + log.debug(method.internalName + ", convertResult " + method.convertResult); + return method.convertResult ? new ObjectConverter(param).convert() : param; + } + + public static function methodNames(_methods:Array):Array { + var result:Array = new Array(); + for (var i:Number = 0; i < _methods.length; i++) { + result.push(PluginMethod(_methods[i]).externalName); + } + return result; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginModel.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginModel.as new file mode 100644 index 0000000000000000000000000000000000000000..3b861fecac73a531823616a35d0820112128c05c --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginModel.as @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import org.flowplayer.model.Callable; + import org.flowplayer.model.Cloneable; + + /** + * @author api + */ + public interface PluginModel extends Identifiable, Callable, Cloneable { + + function get url():String; + + function set url(url:String):void; + + function get isBuiltIn():Boolean; + + function set isBuiltIn(value:Boolean):void; + + function dispatchOnLoad():void; + + function dispatchError(code:PluginError, info:Object = null):void; + + function dispatch(eventType:PluginEventType, eventId:Object = null, info:Object = null, info2:Object = null, info3:Object = null):void; + + function dispatchEvent(event:PluginEvent):void; + + function dispatchBeforeEvent(eventType:PluginEventType, eventId:Object = null, info:Object = null, info2:Object = null, info3:Object = null):Boolean; + + function onPluginEvent(listener:Function):void; + + function onBeforePluginEvent(listener:Function):void; + + function onLoad(listener:Function):void; + + function onError(listener:Function):void; + + function unbind(listener:Function, event:EventType = null, beforePhase:Boolean = false):void; + + function get config():Object; + + function set config(config:Object):void; + + function get pluginObject():Object; + + function set pluginObject(pluginObject:Object):void; + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginModelImpl.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginModelImpl.as new file mode 100644 index 0000000000000000000000000000000000000000..b717b6738e784943abf9cf65507cd8af7a65643e --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/PluginModelImpl.as @@ -0,0 +1,117 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import org.flowplayer.model.PluginEventDispatcher; + import org.flowplayer.model.PluginModel; + + /** + * @author api + */ + public class PluginModelImpl extends PluginEventDispatcher implements PluginModel { + + private var _methods:Array = new Array(); + private var _pluginObject:Object; + private var _name:String; + private var _config:Object; + private var _builtIn:Boolean; + private var _url:String; + + public function PluginModelImpl(pluginObject:Object, name:String) { + _pluginObject = pluginObject; + _name = name; + } + + public function clone():Cloneable { + var clone:PluginModelImpl = new PluginModelImpl(_pluginObject, name); + clone.config = config; + clone.methods = _methods; + return clone; + } + + public function get pluginObject():Object { + return _pluginObject; + } + + public function set pluginObject(pluginObject:Object):void { + _pluginObject = pluginObject; + } + + [Value] + override public function get name():String { + return _name; + } + + public function set name(name:String):void { + _name = name; + } + + [Value] + public function get config():Object { + return _config; + } + + public function set config(config:Object):void { + _config = config; + } + + public function addMethod(method:PluginMethod):void { + _methods.push(method); + } + + public function getMethod(externalName:String):PluginMethod { + return PluginMethodHelper.getMethod(_methods, externalName); + } + + public function invokeMethod(externalName:String, args:Array = null):Object { + return PluginMethodHelper.invokePlugin(this, _pluginObject, externalName, args); + } + + [Value(name="methods")] + public function get methodNames():Array { + return PluginMethodHelper.methodNames(_methods); + } + + public function set methods(methods:Array):void { + _methods = methods; + } + + public function toString():String { + return "[PluginModelImpl] '" + name + "'"; + } + + [Value(name="builtIn")] + public function get isBuiltIn():Boolean { + return _builtIn; + } + + public function set isBuiltIn(value:Boolean):void { + _builtIn = value; + } + + [Value] + public function get url():String { + return _url; + } + + public function set url(url:String):void { + _url = url; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ProviderModel.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ProviderModel.as new file mode 100644 index 0000000000000000000000000000000000000000..5853889266fc5689127f75f62d4e610aa4012787 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/ProviderModel.as @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import flash.net.ObjectEncoding; + + /** + * @author api + */ + public class ProviderModel extends PluginModelImpl implements PluginModel { + private var _connectionProvider:String; + private var _urlResolver:String; + private var _objectEncoding:uint = ObjectEncoding.DEFAULT; + + public function ProviderModel(providerObject:Object, name:String) { + super(providerObject, name); + } + + public function get connectionProvider():String { + return _connectionProvider; + } + + public function set connectionProvider(connectionProvider:String):void { + _connectionProvider = connectionProvider; + } + + public function get urlResolver():String { + return _urlResolver; + } + + public function set urlResolver(val:String):void { + _urlResolver = val; + } + + public function get objectEncoding():uint { + return _objectEncoding; + } + + public function set objectEncoding(val:uint):void { + _objectEncoding = val; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/State.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/State.as new file mode 100644 index 0000000000000000000000000000000000000000..83ffad50781f2d934b2dbacafb488177654879f1 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/State.as @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + + public class State { + public static const WAITING:State = new State(1, "Waiting"); + public static const BUFFERING:State = new State(2, "Buffering"); + public static const PLAYING:State = new State(3, "Playing"); + public static const PAUSED:State = new State(4, "Paused"); + public static const ENDED:State = new State(5, "Ended"); + + private static var enumCreated:Boolean; + { enumCreated = true; + } + private var _name:String; + private var _code:Number; + + public function State(code:Number, name:String) { + if (enumCreated) + throw new Error("Cannot create ad-hoc State instances"); + _code = code; + _name = name; + } + + public function toString():String { + return "State: " + _code + ", '" + _name + "'"; + } + + public function get code():Number { + return _code; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Status.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Status.as new file mode 100644 index 0000000000000000000000000000000000000000..2c787791550dc13e4595e5f7c45982db6522204d --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/Status.as @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + + /** + * @author api + */ + public class Status { + private var _state:State; + private var _clip:Clip; + private var _time:Number; + private var _bufferStart:Number; + private var _bufferEnd:Number; + private var _bytesTotal:Number; + private var _allowRandomSeek:Boolean; + private var _muted:Boolean; + private var _volume:Number; + + public function Status(state:State, clip:Clip, time:Number, bufferStart:Number, bufferEnd:Number, fileSize:Number, muted:Boolean, volume:Number, allowRandomSeek:Boolean = false) { + _state = state; + _clip = clip + _time = time || 0; + _bufferStart = bufferStart || 0; + _bufferEnd = bufferEnd || 0; + _bytesTotal = fileSize || 0; + _allowRandomSeek = allowRandomSeek; + _muted = muted; + _volume = volume; + } + + /** + * Has the clip been played dompletely? + * @return <code>true</code if the clip has been played, + */ + public function get ended():Boolean { + return (_clip.type == ClipType.IMAGE && _clip.duration == 0) || (_clip.played && (_clip.duration - _time <= 1)); + } + + public function get clip():Clip { + return _clip; + } + + [Value] + public function get time():Number { + return _time; + } + + [Value] + public function get bufferStart():Number { + return _bufferStart; + } + + [Value] + public function get bufferEnd():Number { + return _bufferEnd; + } + + public function get bytesTotal():Number { + return _bytesTotal; + } + + public function toString():String { + return "[PlayStatus] time " + _time + ", buffer: [" + _bufferStart + ", " + _bufferEnd + "]"; + } + + public function get allowRandomSeek():Boolean { + return _allowRandomSeek; + } + + [Value] + public function get muted():Boolean { + return _muted; + } + + [Value] + public function get volume():Number { + return _volume; + } + + [Value] + public function get state():int { + return _state.code; + } + + public function getState():State { + return _state; + } + + public function set clip(clip:Clip):void { + _clip = clip; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/TimedPlaylist.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/TimedPlaylist.as new file mode 100644 index 0000000000000000000000000000000000000000..7bf60ff9f2096086991f9ec5b6322701c664d7e9 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/model/TimedPlaylist.as @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.model { + import flash.net.SharedObject; +import flash.utils.Dictionary; + import org.flowplayer.util.Assert; + + internal class TimedPlaylist { + + private var _clips:Array; + private var _clipsByTime:Dictionary; + + public function TimedPlaylist() { + _clips = []; + _clipsByTime = new Dictionary(); + } + + public function addClip(clip:Clip):void { + Assert.notNull(clip, "addClip(), clip cannot be null"); + if (clip.position < 0 && ! clip.isOneShot) { + throw new Error("clip's childStart time must be greater than zero!"); + } + _clips.push(clip); + _clipsByTime[clip.position] = clip; + } + + public function indexOf(clip:Clip):int { + return _clips.indexOf(clip); + } + + public function getClipAt(time:Number):Clip { + return _clipsByTime[Math.round(time)]; + } + + public function get length():int { + return _clips.length; + } + + public function get clips():Array { + return _clips.concat(); + } + + public function removeClip(clip:Clip):void { + _clips.splice(_clips.indexOf(clip), 1); + delete _clipsByTime[clip.position]; + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/Arrange.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/Arrange.as new file mode 100644 index 0000000000000000000000000000000000000000..5b6cc171c082a558cbc6aa0b6b21b6bcfc7eaca7 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/Arrange.as @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.util { + import flash.display.DisplayObject; + import flash.display.Stage; + import flash.display.StageDisplayState; + import org.flowplayer.model.DisplayProperties; + + /** + * @author api + */ + public class Arrange { + public static var parentHeight:Number=0; + public static var parentWidth:Number=0; + public static var hasParent:Boolean=false; + public static var set:Boolean=false; + public static var localWidth:Number=0; + public static var localHeight:Number=0; + /** + * Centers the specified display object to the specified area. + * @param disp the object to center + * @param the width of the centering area + * @param the height of the centering area + */ + public static function center(disp:DisplayObject, areaWidth:Number = 0, areaHeight:Number = 0):void { + if (areaWidth > 0) + disp.x = int((areaWidth / 2) - (disp.width / 2)); + if (areaHeight > 0) + disp.y = int((areaHeight / 2) - (disp.height / 2)); + } + + /** + * Resize the specified display object to have the same size as the other specified display object. + * @param disp the object to resize + * @param other the object where the size is taken from + */ + public static function sameSize(disp:DisplayObject, other:DisplayObject):void { + if (! disp) return; + if (! other) return; + if (other is Stage) { + disp.width = Stage(other).stageWidth; + disp.height = Stage(other).stageHeight; + } else { + disp.width = other.width; + disp.height = other.height; + } + } + + /** + * Returns a string the describes the specified display object's position and dimensions. + * @param disp the object to describe + */ + public static function describeBounds(disp:DisplayObject):String { + return "x: " + disp.x + ", y: " + disp.y + ", width: " + disp.width + ", height: " + disp.height; + } + + /** + * Gets the position of the specified display object relative to another object. + * The position is measured from one specified edge of the container object to the center + * of the queried object. The result can be used in CSS style percentage positioning - to + * position the specified display object inside the container. + * + * @param disp the display object whose position is queried + * @param container the display object relative to which the position is calculated + * @param edge the edge from which the position is calculated from: 0 means that the + * position is measured from the top, 1 from right, 2 from bottom, and 3 from left + */ + public static function positionPercentage(disp:DisplayObject, container:DisplayObject, edge:int):int { + if (edge == 0 || edge == 2) { + var topPct:int = ((disp.y + disp.height / 2) / container.height) * 100; + return edge == 0 ? topPct : 100 - topPct; + } + if (edge == 1 || edge == 3) { + var leftPct:int = ((disp.x + disp.width / 2) / container.width) * 100; + return edge == 3 ? leftPct : 100 - leftPct; + } + return 0; + } + + public static function getWidth(disp:DisplayObject):Number { + if (disp is Stage) { + return getStageWidth(disp as Stage); + } else { + return disp.width; + } + } + + public static function getHeight(disp:DisplayObject):Number { + if (disp is Stage) { + return getStageHeight(disp as Stage); + } else { + return disp.height; + } + } + + public static function getStageWidth(stage:Stage):Number { + return getStageDimension(stage, "width"); + } + + public static function getStageHeight(stage:Stage):Number { + return getStageDimension(stage, "height"); + } + + protected static function getStageDimension(stage:Stage, dimensionName:String):Number { + if (stage.displayState == StageDisplayState.FULL_SCREEN) { + return dimensionName == "height" ? stage.stageHeight : stage.stageWidth; + } + return dimensionName == "height" ? parentHeight : parentWidth; + } + + public static function fixPositionSettings(props:DisplayProperties, defaults:Object):void { + clearOpposite("bottom", "top", props, defaults); + clearOpposite("left", "right", props, defaults); + } + + private static function clearOpposite(prop1:String, prop2:String, props:DisplayProperties, defaults:Object):void { + if (props.position[prop1].hasValue() && defaults.hasOwnProperty(prop2)) { + delete defaults[prop2]; + } else if (props.position[prop2].hasValue() && defaults.hasOwnProperty(prop1)) { + delete defaults[prop1]; + } + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/ArrayUtil.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/ArrayUtil.as new file mode 100644 index 0000000000000000000000000000000000000000..1c3ee436af526c64eee06ec1ebe6f02a7585094c --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/ArrayUtil.as @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.util { + import org.flowplayer.flow_internal; + + /** + * @author anssi + */ + public class ArrayUtil { + flow_internal static function nonNulls(from:Array):Array { + var result:Array = new Array(); + for (var i:Number = 0; i < from.length; i++) { + if (from[i] != null) + result.push(from[i]); + } + return result; + } + + public static function concat(result:Array, addIfAvailable:Array):Array { + if (addIfAvailable) { + return result.concat(addIfAvailable); + } + return result; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/Assert.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/Assert.as new file mode 100644 index 0000000000000000000000000000000000000000..8d70d218e368f464cd462e8f329d90a202c8928c --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/Assert.as @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.util { + + public class Assert { + + public static function notNull(obj:Object, message:String = "object cannot be null"):void { + if (obj == null) + throw new Error(message); + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/GraphicsUtil.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/GraphicsUtil.as new file mode 100644 index 0000000000000000000000000000000000000000..adf3d98686dcfd78c9c62963c12ef77837f47f6a --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/GraphicsUtil.as @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.util { + import flash.display.DisplayObject; + import flash.display.DisplayObjectContainer; + import flash.display.GradientType; + import flash.display.Graphics; + import flash.display.*; + import flash.geom.Matrix; + + /** + * @author api + */ + public class GraphicsUtil { + + public static function beginGradientFill(graphics:Graphics, width:Number, height:Number, color1:Number, color2:Number, alpha:Number = 1):void { + var colors:Array = [color1, color2, color1]; + var matrix:Matrix = new Matrix(); + matrix.createGradientBox(width, height, Math.PI/2); + + graphics.beginGradientFill(GradientType.LINEAR, colors, + [alpha, alpha, alpha], [0, 127, 255], matrix); + } + + public static function beginLinearGradientFill(graphics:Graphics, width:Number, height:Number, colors:Array, alphas:Array, x:int, y:int):void { + var matrix:Matrix = new Matrix(); + matrix.createGradientBox(width, height, Math.PI/2, x, y); + var ratios:Array = new Array(); + var gap:Number = 255/(colors.length-1) + for (var i:Number = 0; i < colors.length; i++) { + ratios.push(i*gap); + } + + graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix); + } + + public static function drawRoundRectangle(graphics:Graphics, x:Number, y:Number, width:Number, height:Number, borderRadius:Number):void { + if (borderRadius > 0) { + graphics.drawRoundRect(x, y, width, height, borderRadius, borderRadius); + } else { + graphics.drawRect(x, y, width, height); + } + } + + public static function addGradient(parent:DisplayObjectContainer, index:int, gradientAlphas:Array, borderRadius:Number, x:Number = 0, y:Number = 0, height:Number = 0):void { + removeGradient(parent); + var gradientHolder:Shape = new Shape(); + gradientHolder.name = "_gradient"; + parent.addChildAt(gradientHolder, index); + + gradientHolder.graphics.clear(); + + beginFill(gradientHolder.graphics, gradientAlphas, parent.width, (height != 0 ? height : parent.height), x, y); + GraphicsUtil.drawRoundRectangle(gradientHolder.graphics, x, y, parent.width, (height != 0 ? height : parent.height), borderRadius); + gradientHolder.graphics.endFill(); + } + + public static function removeGradient(parent:DisplayObjectContainer):void { + var gradientHolder:DisplayObject = parent.getChildByName("_gradient"); + if (gradientHolder) { + parent.removeChild(gradientHolder); + } + } + + private static function beginFill(graph:Graphics, alphas:Array, width:Number, height:Number, x:int, y:int):void { + var color:Array = new Array(); + for (var i:Number = 0; i < alphas.length; i++) { + color.push(0xffffff); + } + beginLinearGradientFill(graph, width, height, color, alphas, x, y); + } + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/Log.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/Log.as new file mode 100644 index 0000000000000000000000000000000000000000..c3c5da7730edddeb119d83e62aad85eb31051188 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/Log.as @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.util { + import org.osflash.thunderbolt.Logger; + import flash.utils.getQualifiedClassName; + + /** + * @author anssi + */ + public class Log { + + private static const LEVEL_DEBUG:int = 0; + private static const LEVEL_WARN:int = 1; + private static const LEVEL_INFO:int = 2; + private static const LEVEL_ERROR:int = 3; + private static const LEVEL_SUPPRESS:int = 4; + + private static var _level:int = LEVEL_ERROR; + private static var _filter:String = "*"; + private static var _instances:Array = new Array(); + public static var traceEnabled:Boolean = false; + + private var _owner:String; + private var _enabled:Boolean = true; + + public function Log(owner:Object) { + _owner = owner is String ? owner as String : getQualifiedClassName(owner); + _instances.push(this); + enable(); + } + + private function enable():void { + _enabled = checkFilterEnables(_owner); + } + + private function checkFilterEnables(owner:String):Boolean { + if (_filter == "*") return true; + var className:String; + var parts:Array = owner.split("."); + var last:String = parts[parts.length - 1]; + var classDelimPos:int = last.indexOf("::"); + if (classDelimPos > 0) { + className = last.substr(classDelimPos + 2); + parts[parts.length -1] = last.substr(0, classDelimPos); + } + var packageName:String = ""; + for (var i:Number = 0; i < parts.length; i++) { + packageName = i > 0 ? packageName + "." + parts[i] : parts[i]; + if (_filter.indexOf(parts[i] + ".*") >= 0) { + return true; + } + } + var result:Boolean = _filter.indexOf(packageName + "." + className) >= 0; + return result; + } + + public static function configure(config:LogConfiguration):void { + level = config.level; + filter = config.filter; + traceEnabled = config.trace; + for (var i:Number = 0; i < _instances.length; i++) { + Log(_instances[i]).enable(); + } + } + + public static function set level(level:String):void { + if (level == "debug") + _level = LEVEL_DEBUG; + else if (level == "warn") + _level = LEVEL_WARN; + else if (level == "info") + _level = LEVEL_INFO; + else if (level == "suppress") + _level = LEVEL_SUPPRESS; + else + _level = LEVEL_ERROR; + } + + public static function set filter(filterValue:String):void { + _filter = filterValue; + } + + public function debug(msg:String = null, ...rest):void { + if (!_enabled) return; + if (_level <= LEVEL_DEBUG) + write(Logger.debug, msg, "DEBUG", rest); + } + + public function error(msg:String = null, ...rest):void { + if (!_enabled) return; + if (_level <= LEVEL_ERROR) + write(Logger.error, msg, "ERROR", rest); + } + + public function info(msg:String = null, ...rest):void { + if (!_enabled) return; + if (_level <= LEVEL_INFO) + write(Logger.info, msg, "INFO", rest); + } + + public function warn(msg:String = null, ...rest):void { + if (!_enabled) return; + if (_level <= LEVEL_WARN) + write(Logger.warn, msg, "WARN", rest); + } + + private function write(writeFunc:Function, msg:String, levelStr:String, rest:Array):void { + if (traceEnabled) { + doTrace(msg, levelStr, rest); + } + try { + if (rest.length > 0) + writeFunc(_owner + " : " + msg, rest); + else + writeFunc(_owner + " : " + msg); + } catch (e:Error) { + trace(msg); + trace(e.message); + } + } + + private function doTrace(msg:String, levelStr:String, rest:Array):void { + trace(_owner + ":: " + levelStr + ": " + msg); + } + + public function get enabled():Boolean { + return _enabled; + } + + public function set enabled(enabled:Boolean):void { + _enabled = enabled; + } + + public function debugStackTrace(msg:String = null):void{ + if (!_enabled) return; + if (_level <= LEVEL_DEBUG) + try { throw new Error("StackTrace"); } catch (e:Error) { debug(msg, e.getStackTrace()); } + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/LogConfiguration.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/LogConfiguration.as new file mode 100644 index 0000000000000000000000000000000000000000..20b6281ae4772b0507d4bb68b791e4e81f872cc5 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/LogConfiguration.as @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.util { + /** + * @author api + */ + public class LogConfiguration { + private var _level:String = "error"; + private var _filter:String = "*"; + private var _trace:Boolean = false; + + public function get level():String { + return _level; + } + + public function set level(level:String):void { + _level = level; + } + + public function get filter():String { + return _filter; + } + + public function set filter(filter:String):void { + _filter = filter; + } + + public function get trace():Boolean { + return _trace; + } + + public function set trace(val:Boolean):void { + _trace = val; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/NumberUtil.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/NumberUtil.as new file mode 100644 index 0000000000000000000000000000000000000000..abcb5bd40d10d72a93c4e53bc0729febd34e0079 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/NumberUtil.as @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.util { + + /** + * @author anssi + */ + public class NumberUtil { + + public static function decodeNonNumbers(number:Number, toValue:Number = 0):Number { + if (isNaN(number)) return toValue; + return number; + } + + public static function decodePercentage(percentageStr:String):Number { + var result:Number = evaluate("pct", percentageStr); + if (! isNaN(result)) return result; + return evaluate("%", percentageStr); + } + + public static function decodePixels(pixelsStr:String):Number { + if (pixelsStr.indexOf("px") < 0) { + pixelsStr += "px"; + } + var result:Number = evaluate("px", pixelsStr); + if (! isNaN(result)) return result; + + result = decodePercentage(pixelsStr); + if (! isNaN(result)) { + // was a percentage value! + return NaN; + } + return pixelsStr.substr(0) as Number; + } + + private static function evaluate(sequence:String, valStr:String):Number { + if (valStr.indexOf(sequence) <= 0) return NaN; + return Number(valStr.substring(0, valStr.indexOf(sequence))); + } + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/ObjectConverter.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/ObjectConverter.as new file mode 100644 index 0000000000000000000000000000000000000000..a714638da81e39385dc1c6da94222587f7015b01 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/ObjectConverter.as @@ -0,0 +1,79 @@ +package org.flowplayer.util { + import flash.utils.describeType; +import flash.utils.getQualifiedClassName; + import org.flowplayer.model.Clip; + + public class ObjectConverter { + private var _input:Object; + + public function ObjectConverter(value:*) { + _input = value; + } + + public function convert():Object { + return process(_input); + } + + public static function copyProps(source:Object, target:Object):Object { + var value:*; + for (var key:String in source) { + value = source[key]; + if (value != null && !(value is Function)) { + target[key] = value; + } + } + return target; + } + + private function process(value:*):Object { + if (value is String) { + return value; + } else if ( value is Number ) { + return value; + } else if ( value is Boolean ) { + return value; + } else if ( value is Array ) { + return convertArray(value as Array); + } else if ( value is Object && value != null ) { + return convertObject(value); + } + return value; + } + + private function convertArray(a:Array):Array { + var arr:Array = new Array(); + for (var i:int = 0; i < a.length; i++) { + arr.push(process(a[i])); + } + return arr; + } + + private function convertObject(o:Object):Object { + var obj:Object = new Object(); + var classInfo:XML = describeType(o); + + if (classInfo.@name.toString() == "Object") { + copyProps(o, obj); + } else { // o is a class instance + // Loop over all of the *annotated* variables and accessors in the class and convert + var exposed:XMLList = classInfo.*.(hasOwnProperty("metadata") && metadata.@name=="Value"); + for each (var v:XML in exposed) { + if (o[v.@name] != null) { + var key2:String = v.metadata.arg.@key == "name" ? v.metadata.arg.@value : v.@name.toString(); + obj[key2] = process(o[v.@name]); + } + } + if (o is Clip) { + copyProps(Clip(o).customProperties, obj); +// if (obj.hasOwnProperty("bitrates")) { +// delete obj.bitrates; +// } + } + } + return obj; + } + + + } + +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/PropertyBinder.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/PropertyBinder.as new file mode 100644 index 0000000000000000000000000000000000000000..68e3e21d7ec6498710268090e421d3b426f89669 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/PropertyBinder.as @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.util { + import flash.utils.describeType; + import flash.utils.getQualifiedClassName; + + import org.flowplayer.util.Log; + + /** + * PropertyBinder is used to populate object's properties by copying values + * from other objects. The target object should be an instance of a class that contains + * accessor or setter functions for the properties that are found in the source. + * + * @author api + */ + public class PropertyBinder { + + private var log:Log = new Log(this); + private var _object:Object; + private var _objectDesc:XML; + private var _extraProps:String; + + /** + * Creates a new property binder for the specified target object. + * @param object the target object into which the properties will be copid to + * @param extraProps a property name for all properties for which the target does not provide an accessor or a setter function + */ + public function PropertyBinder(object:Object, extraProps:String = null) { + log.info("created for " + getQualifiedClassName(object)); + _object = object; + _extraProps = extraProps; + _objectDesc = describeType(_object); + } + + public function copyProperties(source:Object, overwrite:Boolean = true):Object { + if (! source) return _object; + log.debug("copyProperties, overwrite = " + overwrite + (_extraProps ? ", extraprops will be set to " + _extraProps : "")); + for (var prop:String in source) { + if (overwrite || ! hasValue(_object, prop)) { + copyProperty(prop, source[prop]); + } + } + log.debug("done with " + getQualifiedClassName(_object)); + return _object; + } + + public function copyProperty(prop:String, value:Object, convertType:Boolean = false):void { + log.debug("copyProperty() " + prop + ": " + value); + var setter:String = "set" + prop.charAt(0).toUpperCase() + prop.substring(1); + var method:XMLList = _objectDesc.method.(@name == setter); + if (method.length() == 1) { + try { + _object[setter](convertType ? toType(value, method.@type) : value); + log.debug("successfully initialized property '" + prop + "' to value '" + value +"'"); + return; + } catch (e:Error) { + log.debug("unable to initialize using " + setter); + } + } + + var property:XMLList = _objectDesc.*.(hasOwnProperty("@name") && @name == prop); + if (property.length() == 1) { + try { + log.debug("trying to set property '" + prop + "' directly"); + _object[prop] = convertType ? toType(value, property.@type) : value; + log.debug("successfully initialized property '" + prop + "' to value '" + value + "'"); + return; + } catch (e:Error) { + log.debug("unable to set to field / using accessor"); + } + } + + if (_extraProps) { + log.debug("setting to extraprops " + _extraProps + ", prop " + prop + " value " + value); + configure(_object, _extraProps || "customProperties", prop, value); + } else { + log.debug("skipping property '" + prop + "', value " + value); + } + } + + private function toType(value:Object, type:String):Object { + log.debug("toType() " + type); + if (type == "Boolean") return value == "true"; + if (type == "Number") return Number(value); + return value; + } + + private function hasValue(obj:Object, prop:String):Boolean { + if (objHasValue(obj, prop)) { + return true; + } else if (_extraProps) { + return objHasValue(obj[_extraProps], prop); + } + return false; + } + + private function objHasValue(obj:Object, prop:String):Boolean { + try { + var value:Object = obj[prop]; + if (value is Number) { + return value >= 0; + } + if (value is Boolean) { + return true; + } + + return value != null; + } catch (ignore:Error) { } + + // some flowplayer classes implement hasValue() (for example DisplayPropertiesImpl) + try { + return obj.hasValue(prop); + } catch (ignore:Error) { } + + return false; + } + + private function configure(configurable:Object, configProperty:String, prop:String, value:Object):void { + var config:Object = configurable[configProperty] || new Object(); + config[prop] = value; + configurable[configProperty] = config; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/StyleSheetUtil.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/StyleSheetUtil.as new file mode 100644 index 0000000000000000000000000000000000000000..9811be34804646c0e6deceb74b053ee8e5efd116 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/StyleSheetUtil.as @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.util { + + import com.adobe.utils.StringUtil; + /** + * @author api + */ + public class StyleSheetUtil { + + public static function colorValue(color:Object, defVal:Number = 0xffffff):Number { + if (! color) return defVal; + if (color is Number) return color as Number; + if (color is String) { + var colorStr:String = StringUtil.trim(color as String); + if (colorStr.indexOf("#") == 0) { + return parseInt("0x" + colorStr.substr(1)); + } + if (colorStr.indexOf("0x") == 0) { + return parseInt(colorStr); + } + if (colorStr == "transparent") { + return -1; + } + if (color.indexOf("rgb") == 0) { + var input:String = stripSpaces(color as String); + var start:int = input.indexOf("(") + 1; + input = input.substr(start, input.indexOf(")") - start); + var rgb:Array = input.split(","); + return rgb[0] << 16 ^ rgb[1] << 8 ^ rgb[2]; + } + } + + return defVal; + } + + public static function rgbValue(color:Number):Array { + return [ (color >> 16) & 0xFF, (color >> 8) & 0xFF, color & 0xFF ]; + } + + public static function colorAlpha(color:Object, defVal:Number = 1):Number { + if (! color) return defVal; + if (color is String && color.indexOf("rgb") == 0) { + var rgb:Array = parseRGBAValues(color as String); + if (rgb.length == 4) { + return rgb[3]; + } + } + else if (color is String && color == "transparent") { + return 0; + } + return defVal; + } + + public static function parseRGBAValues(color:String):Array { + var input:String = stripSpaces(color); + var start:int = input.indexOf("(") + 1; + input = input.substr(start, input.indexOf(")") - start); + return input.split(","); + } + + public static function stripSpaces(input:String):String { + var result:String = ""; + for (var j:int = 0; j < input.length; j++) { + if (input.charAt(j) != " ") { + result += input.charAt(j); + } + } + return result; + } + + public static function borderWidth(prefix:String, style:Object, defVal:Number = 1):Number + { + if (! hasProperty(prefix, style) ) return defVal; + if ( hasProperty(prefix+'Width', style) ) { + return NumberUtil.decodePixels(style[prefix+'Width']); + } + return NumberUtil.decodePixels(parseShorthand(prefix, style)[0]); + } + + /** + * Border color value of the root style. + */ + public static function borderColor(prefix:String, style:Object, defVal:Number = 0xffffff):uint { + if (hasProperty(prefix + "Color", style)) + return colorValue(style[prefix + "Color"]); + + if (hasProperty(prefix, style)) { + return StyleSheetUtil.colorValue(parseShorthand(prefix, style)[2]); + } + + return defVal; + } + + /** + * Border alpha of the root style. + * @return + */ + public static function borderAlpha(prefix:String, style:Object, defVal:Number = 1):Number { + if (hasProperty(prefix + "Color", style)) + return colorAlpha(style[prefix + "Color"]); + + if (hasProperty(prefix, style)) { + return StyleSheetUtil.colorAlpha(parseShorthand(prefix, style)[2]); + } + + return defVal; + } + + public static function parseShorthand(property:String, style:Object):Array { + var str:String = style[property]; + + // if we are between (), remove spaces + if ( str.indexOf('(') != -1 ) + { + var firstPart:String = str.substr(0, str.indexOf('(')+1); + var secondPart:String = str.substr(str.indexOf('(')+1, str.indexOf(')')-str.indexOf('(')-1); + var thirdPart:String = str.substr(str.indexOf(')')) + secondPart = secondPart.split(' ').join(''); + str = firstPart + secondPart + thirdPart; + } + + return str.split(" "); + } + + public static function hasProperty(prop:String, style:Object):Boolean { + return style && style[prop] != undefined; + } + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/TextUtil.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/TextUtil.as new file mode 100644 index 0000000000000000000000000000000000000000..206753e603e418f2f49b645a9a74bc94a438516a --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/TextUtil.as @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.util { + import flash.display.BlendMode; + import flash.system.Capabilities; + import flash.text.AntiAliasType; + import flash.text.Font; + import flash.text.TextField; + import flash.text.TextFormat; + /** + * @author api + */ + public class TextUtil { + + private static var log:Log = new Log("org.flowplayer.util::TextUtil"); + public static function createTextField(embedded:Boolean, font:String = null, fontSize:int = 12, bold:Boolean = false):TextField { + var field:TextField = new TextField(); + field.blendMode = BlendMode.LAYER; + field.embedFonts = embedded; + var format:TextFormat = new TextFormat(); + if (font) { + log.debug("Creating text field with font: " + font); + format.font = font; + field.antiAliasType = AntiAliasType.ADVANCED; + } else { + if (Capabilities.os.indexOf("Windows") == 0) { + format.font = getFont(["Lucida Grande", "Lucida Sans Unicode", "Bitstream Vera", "Verdana", "Arial", "_sans", "_serif"]); + format.font = "_sans"; + } else { + format.font = "Lucida Grande, Lucida Sans Unicode, Bitstream Vera, Verdana, Arial, _sans, _serif"; + field.antiAliasType = AntiAliasType.ADVANCED; + } + } + format.size = fontSize; + format.bold = bold; + format.color = 0xffffff; + field.defaultTextFormat = format; + return field; + } + + private static function getFont(fontList:Array):String { + var available:Array = Font.enumerateFonts(true); + for (var i:Number = 0; i < fontList.length; i++) { + for (var j:Number = 0; j < available.length; j++) { + if (fontList[i] == Font(available[j]).fontName) { + return fontList[i]; + } + } + } + return null; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/TimeUtil.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/TimeUtil.as new file mode 100644 index 0000000000000000000000000000000000000000..942c63b4a34d307dbfcef82ea4ffec90fc138e71 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/TimeUtil.as @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ +package org.flowplayer.util { + + public class TimeUtil { + public static function seconds(str:String, timeMultiplier:Number = 1000):Number { + return Math.round(toSeconds(str) * timeMultiplier / 100) * 100; + } + + private static function toSeconds(str:String):Number { + str = str.replace(",", "."); + var arr:Array = str.split(':'); + var sec:Number = 0; + if (str.substr(-1) == 's') { + return Number(str.substr(0, str.length - 1)); + } + if (str.substr(-1) == 'm') { + return Number(str.substr(0, str.length - 1)) * 60; + } + if(str.substr(-1) == 'h') { + return Number(str.substr(0, str.length - 1)) * 3600; + } + if(arr.length > 1) { + sec = Number(arr[arr.length - 1]); + sec += Number(arr[arr.length - 2]) * 60; + if(arr.length == 3) { + sec += Number(arr[arr.length - 3]) * 3600; + } + return sec; + } + return Number(str); + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/URLUtil.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/URLUtil.as new file mode 100644 index 0000000000000000000000000000000000000000..2750f2613d01f0b9f3e78236e6f0d97c16bfbc94 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/URLUtil.as @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.util { + import com.adobe.utils.StringUtil; +import flash.display.LoaderInfo; + import flash.external.ExternalInterface; + import flash.net.URLRequest; + import flash.net.navigateToURL; + + /** + * @author anssi + */ + public class URLUtil { + private static var _log:Log = new Log("org.flowplayer.util::URLUtil"); + private static var _loaderInfo:LoaderInfo; + + + public static function completeURL(baseURL:String, fileName:String):String { + return addBaseURL(baseURL || pageLocation || playerBaseUrl, fileName); + } + + public static function addBaseURL(baseURL:String, fileName:String):String { + if (fileName == null) return null; + + if (isCompleteURLWithProtocol(fileName)) return fileName; + if (fileName.indexOf("/") == 0) return fileName; + + if (baseURL == '' || baseURL == null || baseURL == 'null') { + return fileName; + } + if (baseURL != null) { + if (baseURL.lastIndexOf("/") == baseURL.length - 1) + return baseURL + fileName; + return baseURL + "/" + fileName; + } + return fileName; + } + + public static function appendToPath(base:String, postFix:String):String { + if (StringUtil.endsWith(base, "/")) return base + postFix; + return base + "/" + postFix; + } + + public static function isCompleteURLWithProtocol(fileName:String):Boolean { + if (! fileName) return false; + return fileName.indexOf("://") > 0; + } + + + private static function detectPageUrl(functionName:String):String { + _log.debug("detectPageUrl() " + functionName); + try { + return ExternalInterface.call(functionName); + } catch (e:Error) { + _log.debug("Error in detectPageUrl() " + e); + } + return null; + } + + public static function get pageUrl():String { + if (!ExternalInterface.available) return null; + + var href:String = detectPageUrl("window.location.href.toString"); + if (! href || href == "") { + href = detectPageUrl("document.location.href.toString"); + } + if (! href || href == "") { + href = detectPageUrl("document.URL.toString"); + } + return href; + } + + public static function get pageLocation():String { + var url:String = pageUrl; + return url ? baseUrlAndRest(url)[0] : null; + } + + public static function baseUrlAndRest(url:String):Array { + var endPos:int = url.indexOf("?"); + if (endPos > 0) { + endPos = url.substring(0, endPos).lastIndexOf("/"); + } else if ( url.indexOf('#') != -1 ) { // #112, when you have a / afer a # + endPos = url.substring(0, url.indexOf('#')).lastIndexOf("/"); + } else { + endPos = url.lastIndexOf("/"); + } + if (endPos > 0) { + return [url.substring(0, endPos), url.substring(endPos + 1)]; + } else { + return [null, url]; + } + } + + public static function get playerBaseUrl():String { + var url:String = _loaderInfo.url; + var firstSwf:Number = url.indexOf(".swf"); + url = url.substring(0, firstSwf); + var lastSlashBeforeSwf:Number = url.lastIndexOf("/"); + return url.substring(0, lastSlashBeforeSwf); + } + + public static function localDomain(url:String):Boolean { + if (url.indexOf("http://localhost/") == 0) return true; + if (url.indexOf("file://") == 0) return true; + if (url.indexOf("chrome://") == 0) return true; + if (url.indexOf("http://127.0.0.1") == 0) return true; + if (url.indexOf("http://") == 0) return false; + if (url.indexOf("/") == 0) return true; + return false; + } + + public static function set loaderInfo(value:LoaderInfo):void { + _loaderInfo = value; + } + + public static function openPage(url:String, linkWindow:String = "_blank", popUpDimensions:Array = null):void { + if (linkWindow == "_popup" && ExternalInterface.available) { + _log.debug("openPage(), opening popup"); + var dimensions:Array = popUpDimensions || [800,600]; + ExternalInterface.call("window.open('" + url + "','PopUpWindow','width=" + dimensions[0] + ",height=" + dimensions[1] + ",toolbar=yes,scrollbars=yes')"); + } else { + // Use JS to bypass popup blockers if ExternalInterface is available + var window:String = linkWindow == "_popup" ? "_blank" : linkWindow; + if (ExternalInterface.available) { + ExternalInterface.call('window.open("' + url + '","' + window + '")'); + } else { + //request a blank page + navigateToURL(new URLRequest(url), window); + } + } + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/VersionUtil.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/VersionUtil.as new file mode 100644 index 0000000000000000000000000000000000000000..fb722cdd81cd5e776b2004cfa9ec88ae694aa49c --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/util/VersionUtil.as @@ -0,0 +1,49 @@ +package org.flowplayer.util { + + import flash.system.Capabilities; + + public class VersionUtil { + + public static function majorVersion():Number { + return getVersion().majorVersion; + } + + public static function minorVersion():Number { + return getVersion().minorVersion; + } + + public static function platform():String { + return getVersion().platform; + } + + public static function buildNumber():Number { + return getVersion().buildNumber; + } + + public static function getVersion():Object { + var versionNumber:String = Capabilities.version; + var versionArray:Array = versionNumber.split(","); + + var versionObj:Object = {}; + + var platformAndVersion:Array = versionArray[0].split(" "); + + versionObj.platform = platformAndVersion[0]; + versionObj.majorVersion = parseInt(platformAndVersion[1]); + versionObj.minorVersion = parseInt(versionArray[1]); + versionObj.buildNumber = parseInt(versionArray[2]); + + return versionObj; + } + + public static function isFlash10():Boolean { + return VersionUtil.majorVersion() == 10; + } + + public static function isFlash9():Boolean { + return VersionUtil.majorVersion() == 9; + } + + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/AbstractSprite.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/AbstractSprite.as new file mode 100644 index 0000000000000000000000000000000000000000..5b3064bf6bc8b2980b2bf72efc661e75428b2ffa --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/AbstractSprite.as @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import flash.display.Sprite; + import flash.geom.Rectangle; + + import org.flowplayer.layout.LayoutEvent; + import org.flowplayer.util.Log; + + /** + * @author api + */ + public class AbstractSprite extends Sprite { + + protected var log:Log = new Log(this); + + /** + * The managed width value. + */ + protected var _width:Number = 0; + + /** + * The managed height value. + */ + protected var _height:Number = 0; + + public function setSize(width:Number, height:Number):void { + _width = width; + _height = height; + onResize(); + } + + public override function get width():Number { + if (scaleX != 1) return _width * scaleX; + return _width || super.width; + } + + public override function set width(value:Number):void { + setSize(value, height); + } + + public override function get height():Number { + if (scaleY != 1) return _height * scaleY; + return _height || super.height; + } + + public override function set height(value:Number):void { + setSize(width, value); + } + + // TODO: make it possible to resize using scaleX and scaleY +// public override function set scaleX(value:Number):void { +// } +// +// public override function set scaleY(value:Number):void { +// } + + protected function get managedWidth():Number { + return _width; + } + + protected function get managedHeight():Number { + return _height; + } + + protected function onResize():void { + } + + public function draw(event:LayoutEvent):void { + var bounds:Rectangle = event.layout.getBounds(this); + setSize(bounds.width, bounds.height); + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Animation.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Animation.as new file mode 100644 index 0000000000000000000000000000000000000000..6a185556c734588f13bb658668fbd914025cb43f --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Animation.as @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import flash.display.DisplayObject; + + import org.flowplayer.util.Log; + import org.goasap.items.LinearGo; + /** + * @author api + */ + public class Animation extends LinearGo { + + protected var log:Log = new Log(this); + private var _target:DisplayObject; + private var _targetValue:Number; + private var _startValue:Number; + private var _tweenProperty:String; + private var _canceled:Boolean; + + public function Animation(target:DisplayObject, tweenProperty:String, targetValue:Number, durationMillis:Number = 500) { + super(0, durationMillis/1000); + _target = target; + _targetValue = targetValue; + _tweenProperty = tweenProperty; + useRounding = true; + } + + public function cancel():Boolean { + _canceled = true; + return stop(); + } + + protected function startFrom(value:Number):Boolean { + log.debug("starting with start value " + value); + _startValue = value; + _target[_tweenProperty] = value; + _change = _targetValue - _startValue; + return super.start(); + } + + override public function start():Boolean { + _startValue = _target[_tweenProperty]; + log.debug("starting with start value " + _startValue); + _change = _targetValue - _startValue; + return super.start(); + } + + override protected function onUpdate(type:String):void { + // Basic tween implementation using the formula Value=Start+(Change*Position). + // Position is a 0-1 multiplier run by LinearGo. + var newValue:Number = _startValue + (_targetValue - _startValue) * _position; + _target[_tweenProperty] = _tweenProperty == "alpha" ? newValue : correctValue(newValue); + + if (_target[_tweenProperty] == _targetValue) { + log.debug("completed for target "+ target + ", property " + _tweenProperty + ", target value was " + _targetValue); + } + } + + public override function toString():String { + return "[Animation] of property '" + _tweenProperty + "', start " + _startValue + ", target " + _targetValue; + } + + protected function get target():DisplayObject { + return _target; + } + + public function get canceled():Boolean { + return _canceled; + } + + public function get tweenProperty():String { + return _tweenProperty; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/AnimationEngine.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/AnimationEngine.as new file mode 100644 index 0000000000000000000000000000000000000000..1dceec22231cbe7ac97633834c98613f50c10d27 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/AnimationEngine.as @@ -0,0 +1,365 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import org.flowplayer.flow_internal; + import org.flowplayer.layout.LengthMath; + import org.flowplayer.model.DisplayProperties; + import org.flowplayer.util.Assert; + import org.flowplayer.util.Log; + import org.flowplayer.view.Animation; + import org.flowplayer.view.Panel; + import org.goasap.events.GoEvent; + import org.goasap.interfaces.IPlayable; + import org.goasap.utils.PlayableGroup; + + import flash.display.DisplayObject; + import flash.geom.Rectangle; + import flash.utils.Dictionary; + + use namespace flow_internal; + + /** + * AnimationAngine is used to animate DisplayProperties. + * + */ + public class AnimationEngine { + + private var log:Log = new Log(this); + private var _panel:Panel; + private var _pluginRegistry:PluginRegistry; + private var _runningPlayablesByView:Dictionary = new Dictionary(); + private var _canceledByPlayable:Dictionary = new Dictionary(); + + public function AnimationEngine(panel:Panel, pluginRegistry:PluginRegistry) { + _panel = panel; + _pluginRegistry = pluginRegistry; + } + + /** + * Animates a DisplayObject according to supplied properties. + * + * If the supplied display object is a plugin, the properties can contain relative values and percentage values. + * A relative value specifies a new position relative + * to the plugin's current position. For example: + * <code> + * animations.animate("content", { top: "+20px", left: "-20%", width: 90 }); + * </code> + * Here we animate the content plugin so that the top position is increased by 20 pixels, left position is decreased by 20%, + * and the width is set to 90 pixels. Following display properties can be animated with relative and absolute, pixel based + * and percentage values: + * <ul> + * <li>left</li> + * <li>right</li> + * <li>top</li> + * <li>bottom</li> + * <li>width</li> + * <li>height</li> + * </ul> + * <p> + * The <code>opacity</code> property only supports absolute numeric values. + * </p> + * <p> + * All changes made to the plugin's display propertites are stored into the PluginRegistry + * </p> + * + * @param pluginName the name of the plugin to animate, the plugin is looked up from the PluginRegistry using this name + * @param props an object containing display properties + * @param durationMillis the duration it takes for the animation to complete + * @param endCallback a function to be called when the animation is complete + * @see #animate() + * @see PluginRegistry + */ + public function animate(disp:DisplayObject, props:Object, durationMillis:int = 400, endCallback:Function = null, updateCallback:Function = null, easeFunc:Function = null):DisplayProperties { + var currentProps:DisplayProperties = _pluginRegistry.getPluginByDisplay(disp); + var isPlugin:Boolean = currentProps != null; + if (isPlugin) { + log.debug("animating plugin " + currentProps); + } else { + log.debug("animating non-plugin displayObject " + disp); + } + + + if (isPlugin) { + var newProps:DisplayProperties = props is DisplayProperties ? props as DisplayProperties : LengthMath.sum(currentProps, props, _panel.stage); + log.debug("current dimensions " + currentProps.dimensions); + disp.visible = newProps.visible; + if (disp.visible) { + panelAnimate(currentProps.getDisplayObject(), newProps, durationMillis, endCallback, easeFunc); + } else { + _panel.removeChild(disp); + } + _pluginRegistry.updateDisplayProperties(newProps); + } else { + startTweens(disp, alpha(props), props.width, props.height, props.x, props.y, durationMillis, endCallback, updateCallback, easeFunc); + } + return newProps; + } + + flow_internal function animateNonPanel(parent:DisplayObject, disp:DisplayObject, props:Object, durationMillis:int = 400, endCallback:Function = null, updateCallback:Function = null):DisplayProperties { + log.debug("animateNonPanel", props); + var currentProps:DisplayProperties = _pluginRegistry.getPluginByDisplay(disp); + var newProps:DisplayProperties = props is DisplayProperties ? props as DisplayProperties : LengthMath.sum(currentProps, props, parent); + startTweens(disp, alpha(props), props.width, props.height, props.x, props.y, durationMillis, endCallback, updateCallback); + return newProps; + } + + private function alpha(props:Object):Number { + if (props.hasOwnProperty("alpha")) return props["alpha"]; + if (props.hasOwnProperty("opacity")) return props["opacity"]; + return NaN; + } + + /** + * Animates a single DisplayObject property. + * @param view the display object to animate + * @param propertyName the property to animate + * @param target property target value + * @durationMillis the duration of the animation + * @easeFunc the easing function to use, the default is mx.effects.easing.Quadratic.easeOut + */ + public function animateProperty(view:DisplayObject, propertyName:String, target:Number, durationMillis:int = 500, completeCallback:Function = null, updateCallback:Function = null, easeFunc:Function = null):void { + var props:Object = new Object(); + props[propertyName] = target; + animate(view, props, durationMillis, completeCallback, updateCallback, easeFunc); + } + + /** + * Fades in a DisplayObject. + */ + public function fadeIn(view:DisplayObject, durationMillis:Number = 500, completeCallback:Function = null, updatePanel:Boolean = true):Animation { + return animateAlpha(view, 1, durationMillis, completeCallback, updatePanel); + } + + /** + * Fades a DisplayObject to a specified alpha value. + */ + public function fadeTo(view:DisplayObject, alpha:Number, durationMillis:Number = 500, completeCallback:Function = null, updatePanel:Boolean = true):Animation { + return animateAlpha(view, alpha, durationMillis, completeCallback, updatePanel); + } + + /** + * Fades out a DisplayObject. + */ + public function fadeOut(view:DisplayObject, durationMillis:Number = 500, completeCallback:Function = null, updatePanel:Boolean = true):Animation { + return animateAlpha(view, 0, durationMillis, completeCallback, updatePanel); + } + + /** + * Cancels all animations that are currently running for the specified view. The callbacks specified in animation calls + * are not invoked for canceled animations. + * @param currentAnimation if specified all other animations except the specified one will be canceled + */ + public function cancel(view:DisplayObject, currentAnimation:Animation = null):void { + log.debug("cancel() cancelling animation for " + view); + var action:Function = function(myAnim:Animation):void { + _canceledByPlayable[myAnim] = true; + delete _runningPlayablesByView[view]; + myAnim.stop(); + log.info("tween for property " + myAnim.tweenProperty + " was canceled on view " + view); + }; + processAction(action, view, currentAnimation); + } + + + public function pause(view:DisplayObject, currentAnimation:Animation = null):void { + log.debug("pause() pausing animation for " + view); + var action:Function = function(myAnim:Animation):void { + myAnim.pause(); + log.info("tween for property " + myAnim.tweenProperty + " was paused on view " + view); + }; + processAction(action, view, currentAnimation); + } + + public function resume(view:DisplayObject, currentAnimation:Animation = null):void { + log.debug("resume() resuming animation for " + view); + var action:Function = function(myAnim:Animation):void { + myAnim.resume(); + log.info("tween for property " + myAnim.tweenProperty + " was resumed on view " + view); + }; + processAction(action, view, currentAnimation); + } + + private function processAction(action:Function, view:DisplayObject, currentAnimation:Animation = null):void { + for (var viewObj:Object in _runningPlayablesByView) { + log.debug("cancel(), currently running animation for " + viewObj); + var viewWithRunningAnimation:DisplayObject = viewObj as DisplayObject; + if (viewWithRunningAnimation == view) { + var anim:Animation = _runningPlayablesByView[viewWithRunningAnimation] as Animation; + + if (anim && (currentAnimation && anim != currentAnimation || ! currentAnimation)) { + if (currentAnimation && currentAnimation.tweenProperty == anim.tweenProperty || ! currentAnimation) { + action(anim); + } + } + } + } + } + + public function hasAnimationRunning(view:DisplayObject):Boolean { + for (var viewObj:Object in _runningPlayablesByView) { + log.debug("cancel(), currently running animation for " + viewObj); + var viewWithRunningAnimation:DisplayObject = viewObj as DisplayObject; + if (viewWithRunningAnimation == view) { + return true; + } + } + return false; + } + + private function logRunningAnimations(phase:String, view:DisplayObject):void { + for (var viewObj:Object in _runningPlayablesByView) { + log.debug(phase + ": found running animation for " + view + ", " + _runningPlayablesByView[viewObj]); + } + } + + private function animateAlpha(view:DisplayObject, target:Number, durationMillis:Number = 500, completeCallback:Function = null, updatePanel:Boolean = true):Animation { + Assert.notNull(view, "animateAlpha: view cannot be null"); + var playable:Animation = createTween("alpha", view, target, durationMillis); + if (! playable) { + if (completeCallback != null) { + completeCallback(); + } + return null; + } + + // cancel previous alpha animations + cancel(view, playable); + + var plugin:DisplayProperties = _pluginRegistry.getPluginByDisplay(view); + if (updatePanel && plugin) { + log.debug("animateAlpha(): will add/remove from panel"); + // this is a plugin, add/remove it from a panel + if (target == 0) { + playable.addEventListener(GoEvent.COMPLETE, + function(event:GoEvent):void { + if (!_canceledByPlayable[playable]) { + log.debug("removing " + view + " from panel"); + view.parent.removeChild(view); + } else { + log.info("previous fadeout was canceled, will not remove " + view + " from panel"); + } + }); + } else if (view.parent != _panel) { + _panel.addView(view, null, plugin); + } + } else { + log.debug("animateAlpha, view is not added/removed from panel"); + } + + var tween:Animation = start(view, playable, completeCallback) as Animation; + if (tween) { + _pluginRegistry.updateDisplayPropertiesForDisplay(view, { alpha: target, display: (target == 0 ? "none" : "block") }); + } + return tween; + } + + private function panelAnimate(view:DisplayObject, props:DisplayProperties, durationMillis:int = 500, callback:Function = null, easeFunc:Function = null):void { + Assert.notNull(props.name, "displayProperties.name must be specified"); + log.debug("animate " + view); + if (view.parent != _panel) { + _panel.addView(view); + } + var target:Rectangle = _panel.update(view, props); + startTweens(view, props.alpha, target.width, target.height, target.x, target.y, durationMillis, callback, easeFunc); + if (durationMillis == 0) { + if (props.alpha >= 0) { + view.alpha = props.alpha; + } + _panel.draw(view); + } + } + + private function startTweens(view:DisplayObject, alpha: Number, width:Number, height:Number, x:Number, y:Number, durationMillis:int, completeCallback:Function, updateCallback:Function, easeFunc:Function = null):Array { + var tweens:Array = new Array(); + + var alphaTween:Animation = createTween("alpha", view, alpha, durationMillis); + if (alphaTween) { + cancel(view, alphaTween); + addTween(tweens, alphaTween); + } + + addTween(tweens, createTween("width", view, width, durationMillis, easeFunc)); + addTween(tweens, createTween("height", view, height, durationMillis, easeFunc)); + addTween(tweens, createTween("x", view, x, durationMillis, easeFunc)); + addTween(tweens, createTween("y", view, y, durationMillis, easeFunc)); + if (tweens.length == 0) { + // call the callback also when not animating anything + if (completeCallback != null) { + completeCallback(); + } + return tweens; + } + var playable:IPlayable = tweens.length > 1 ? new PlayableGroup(tweens) : tweens[0]; + start(view, playable, completeCallback, updateCallback); + return tweens; + } + + private function addTween(tweens:Array, tween:IPlayable):void { + if (! tween) return; + log.debug("will animate " + tween); + tweens.push(tween); + } + + private function start(view:DisplayObject, playable:IPlayable, completeCallback:Function = null, updateCallback:Function = null):IPlayable { + if (playable == null) return null; + logRunningAnimations("start", view); + + _runningPlayablesByView[view] = playable; + log.debug("start() staring animation for view " + view); + + playable.addEventListener(GoEvent.COMPLETE, + function(event:GoEvent):void { + onComplete(view, playable, completeCallback); + }); + if (updateCallback != null) { + playable.addEventListener(GoEvent.UPDATE, + function(event:GoEvent):void { + updateCallback(view); + }); + } + + playable.start(); + return playable; + } + + private function onComplete(view:DisplayObject, playable:IPlayable, callback:Function = null):void { + log.debug("onComplete, view " + view); + delete _canceledByPlayable[playable]; + delete _runningPlayablesByView[view]; + + if (callback != null && !_canceledByPlayable[playable]) { + callback(); + } + } + + private function createTween(property:String, view:DisplayObject, targetValue:Number, durationMillis:int, easeFunc:Function = null):Animation { + if (isNaN(targetValue)) return null; + if (view[property] == targetValue) { + log.debug("view property " + property + " already in target value " + targetValue + ", will not animate"); + return null; + } + log.debug("creating tween for property " + property + ", target value is " + targetValue + ", current value is " + view[property]); + var animation:Animation = new Animation(view, property, targetValue, durationMillis); + if (easeFunc != null) { + animation.easing = easeFunc; + } + return animation; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/BuiltInAssetHelper.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/BuiltInAssetHelper.as new file mode 100644 index 0000000000000000000000000000000000000000..4ef84e53c93b3de21cd75109f2467e92e286bcd5 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/BuiltInAssetHelper.as @@ -0,0 +1,45 @@ +/* + * Author: Anssi Piirainen, <api@iki.fi> + * + * Copyright (c) 2010 Flowplayer Oy + * + * This file is part of Flowplayer. + * + * Flowplayer is licensed under the GPL v3 license with an + * Additional Term, see http://flowplayer.org/license_gpl.html + */ +package org.flowplayer.view { + import flash.display.DisplayObject; + + + public class BuiltInAssetHelper { + private static var _config:BuiltInConfig = new BuiltInConfig(); + private static const PLAY:String = "PlayButton"; + private static const LOGO:String = "Logo"; + + public static function get hasPlayButton():Boolean { + return _config.hasOwnProperty(PLAY); + } + + public static function createPlayButton():DisplayObject { + return createAsset(PLAY); + } + + public static function get hasLogo():Boolean { + return _config.hasOwnProperty(LOGO); + } + + public static function createLogo():DisplayObject { + return createAsset(LOGO); + } + + private static function createAsset(name:String):* { + if (_config.hasOwnProperty(name)) { + var clazz:Class = _config[name] as Class; + return new clazz(); + } + return null; + } + } + +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/ClipResizer.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/ClipResizer.as new file mode 100644 index 0000000000000000000000000000000000000000..397ca7ff6a8263ebcae18bf00dd05792f712497e --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/ClipResizer.as @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import flash.utils.Dictionary; + import flash.events.TimerEvent; + import flash.utils.Timer; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipType; + import org.flowplayer.model.MediaSize; + import org.flowplayer.model.ClipEvent; + import org.flowplayer.model.ClipEventSupport; + import org.flowplayer.model.Playlist; + import org.flowplayer.util.Log; + + /** + * @author api + */ + internal class ClipResizer { + + private var log:Log = new Log(this); + private var resizers:Dictionary; + private var screen:Screen; + private var _playlist:Playlist; + private var _resizerTimer:Timer; + + public function ClipResizer(playList:Playlist, screen:Screen) { + resizers = new Dictionary(); + _playlist = playList; + this.screen = screen; + createResizers(playList.clips.concat(playList.childClips)); + addListeners(playList); + } + + + private function createResizers(clips:Array):void { + clips.forEach(function(clip:Clip, index:int, clips:Array):void { + log.debug("creating resizer for clip " + clip); + resizers[clip] = new MediaResizer(clip, screen.width, screen.height); + }); + } + + public function setMaxSize(width:int, height:int):void { + log.debug("setMaxSize: " + width + " x " + height); + for each (var resizer:MediaResizer in resizers) { + resizer.setMaxSize(width, height); + } + resizeClip(_playlist.current); + } + + public function resizeClip(clip:Clip, force:Boolean = false):void { + resizeClipTo(clip, clip.scaling, force); + } + + public function resizeClipTo(clip:Clip, mediaSize:MediaSize, force:Boolean = false):void { + log.debug("resizeClipTo, clip " + clip); + if ( _resizerTimer ) { + log.debug("Killing old resize timer"); + _resizerTimer.reset(); + _resizerTimer = null; + } + + var resizer:MediaResizer = resizers[clip]; + if (! resizer) { + log.warn("no resizer defined for " + clip); + return; + } + + var resizingFunc:Function = function(event:TimerEvent = null):void { + + if ( event && ! resizer.hasOrigSize() && Timer(event.target).currentCount < Timer(event.target).repeatCount ) { + log.debug("we don't have a size yet.. waiting for the video object to have a size"); + return; + } + + if (resizer.resizeTo(mediaSize, force)) { + screen.resized(clip); + } + }; + + if ( resizer.hasOrigSize() ) { + log.debug("we have a size, resizing now !"); + resizingFunc(); + } else { + // delayed one + log.warn("we don't have a size now, delaying the resize"); + _resizerTimer = new Timer(500, 5); + _resizerTimer.addEventListener(TimerEvent.TIMER, resizingFunc); + _resizerTimer.start(); + + } + } + + private function error(errorMsg:String):void { + log.error(errorMsg); + throw new Error(errorMsg); + } + + private function onResize(event:ClipEvent = null):void { + log.debug("received event " + event.target); + var clip:Clip = Clip(event.target); + if (clip.type == ClipType.IMAGE && clip.getContent() == null) { + log.warn("image content not available yet, will not resize: " + clip); + return; + } + resizeClip(clip); + } + + private function addListeners(eventSupport:ClipEventSupport):void { + eventSupport.onStart(onResize); + eventSupport.onBufferFull(onResize); + eventSupport.onPlaylistReplace(onPlaylistChange); + eventSupport.onClipAdd(onPlaylistChange); + } + + private function onPlaylistChange(event:ClipEvent):void { + log.info("Received onPlaylistChanged"); + createResizers(ClipEventSupport(event.target).clips.concat(ClipEventSupport(event.target).childClips)); + } + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/ErrorHandler.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/ErrorHandler.as new file mode 100644 index 0000000000000000000000000000000000000000..cd3667936e87428438e1367764163e6c70417593 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/ErrorHandler.as @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import org.flowplayer.model.ErrorCode; + + public interface ErrorHandler { + + function showError(message:String):void; + + function handleError(error:ErrorCode, info:Object = null, throwError:Boolean = true):void; + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/FlowStyleSheet.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/FlowStyleSheet.as new file mode 100644 index 0000000000000000000000000000000000000000..0770877338cd9fa9ea38f341bf32bbc89dd86495 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/FlowStyleSheet.as @@ -0,0 +1,329 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import org.flowplayer.layout.Length; + import org.flowplayer.util.GraphicsUtil; + import org.flowplayer.util.NumberUtil; + + import flash.text.StyleSheet; + + import org.flowplayer.util.Log; + import org.flowplayer.util.StyleSheetUtil; + import org.flowplayer.view.FlowStyleSheet; + + import com.adobe.utils.StringUtil; + + /** + * An extension of the Flash's StyleSheet class. It adds a possibility to + * specify a border and a background image. The style properties of the + * border and backgound image are exposed by the methods of this class. + * + * @author api + */ + public class FlowStyleSheet { + private var log:Log = new Log(this); + internal static const ROOT_STYLE_PROPS:Array = [ + "padding", "backgroundColor", "backgroundGradient", "border", "borderColor", "borderRadius", "borderWidth", + "backgroundImage", "backgroundRepeat", "background", "linkUrl", "linkWindow", "textDecoration"]; + private var _styleSheet:flash.text.StyleSheet; + private var _styleName:String; + /** + * Creates a new stylesheet. + * @param rootStyleName the style name that holds the border and backgound image and other extensions + * @param CSS stylesheet as a string, this styleshoot should contain the style properties for the specified styleName. It + * can also contain additional properties and those can be accessed via the styleSheet property + */ + public function FlowStyleSheet(rootStyleName:String, cssText:String = null) { + _styleName = rootStyleName; + _styleSheet = new flash.text.StyleSheet(); + if (cssText) { + parseCSS(cssText); + } + } + + public static function isRootStyleProperty(prop:String):Boolean { + return ROOT_STYLE_PROPS.indexOf(prop) >= 0; + } + + /** + * Gets the root style name. + */ + public function get rootStyleName():String { + return _styleName; + } + + /** + * Gets the root style object. + */ + public function get rootStyle():Object { + return _styleSheet.getStyle(_styleName); + } + + /** + * Sets the root style. + */ + public function set rootStyle(styleObj:Object):void { + setStyle(_styleName, styleObj); + } + + /** + * Sets the style with the specified name. + */ + public function setStyle(styleName:String, styleObj:Object):void { + _styleSheet.setStyle(styleName, styleObj); + } + + /** + * Sets the style with the specified name. + */ + public function getStyle(styleName:String):Object { + return _styleSheet.getStyle(styleName); + } + /** + * Adds style proeperties to the root style. + */ + public function addToRootStyle(style:Object):void { + addStyleRules(_styleName, style); + } + + /** + * Adds the specified style properties to the specified style. + */ + public function addStyleRules(styleName:String, style:Object):void { + var current:Object = _styleSheet.getStyle(styleName); + for (var prop:String in style) { + current[prop] = style[prop]; + } + _styleSheet.setStyle(styleName, null); + _styleSheet.setStyle(styleName, current); + } + + /** + * The underlying stylesheet. + */ + public function get styleSheet():StyleSheet { + return _styleSheet; + } + + + /** + * The padding of the root style. + */ + public function get padding():Array { + if (! StyleSheetUtil.hasProperty("padding", rootStyle)) return [5, 5, 5, 5]; + var paddingStr:String = rootStyle["padding"]; + + if (paddingStr.indexOf(" ") > 0) { + var pads:Array = new Array(); + var values:Array = paddingStr.split(" "); + for (var i:Number = 0; i < values.length; i++) { + var value:String = values[i]; + pads[i] = NumberUtil.decodePixels(value); + } + return pads; + } + else { + var pxVal:int = NumberUtil.decodePixels(paddingStr); + var result:Array = new Array(); + // we cannot just return [ pxVal, pxVal, pxVal, pxVal ] because that gives a stack overflow error??? why?? + result.push(pxVal); + result.push(pxVal); + result.push(pxVal); + result.push(pxVal); + return result; + } + } + + /** + * Background color of the root style. + */ + public function get backgroundColor():uint { + if (StyleSheetUtil.hasProperty("background", rootStyle)) { + return StyleSheetUtil.colorValue(StyleSheetUtil.parseShorthand("background", rootStyle)[0]); + } + if (StyleSheetUtil.hasProperty("backgroundColor", rootStyle)) { + return parseColorValue("backgroundColor"); + } + return 0x333333; + } + + /** + * Background aplpa. + * @return + */ + public function get backgroundAlpha():Number { + if (StyleSheetUtil.hasProperty("background", rootStyle)) { + return StyleSheetUtil.colorAlpha(StyleSheetUtil.parseShorthand("background", rootStyle)[0]); + } + if (StyleSheetUtil.hasProperty("backgroundColor", rootStyle)) { + return parseColorAlpha("backgroundColor"); + } + return 1; + } + + /** + * Background gradient of the root style. + */ + public function get backgroundGradient():Array { + if (! StyleSheetUtil.hasProperty("backgroundGradient", rootStyle)) return null; + if (rootStyle["backgroundGradient"] is String) { + return decodeGradient(rootStyle["backgroundGradient"] as String); + } + return rootStyle["backgroundGradient"]; + } + + public static function decodeGradient(value:String):Array { + if (value == "none") return null; + if (value == "high") return [1, 0.5, 0, 0.1, .3]; + if (value == "medium") return [.6, .21, .21]; + return [.4, .15, .15]; + } + + /** + * Is the background transparent in the root style? + */ + public function get backgroundTransparent():Boolean { + if (! StyleSheetUtil.hasProperty("backgroundColor", rootStyle)) return false; + + return rootStyle["backgroundColor"] == "transparent" || backgroundAlpha == 0; + } + + /** + * Border weight value of the root style. + */ + public function get borderWidth():Number { + return StyleSheetUtil.borderWidth('border', rootStyle); + } + + /** + * Border color value of the root style. + */ + public function get borderColor():uint { + return StyleSheetUtil.borderColor('border', rootStyle); + } + + /** + * Border alpha of the root style. + * @return + */ + public function get borderAlpha():Number { + return StyleSheetUtil.borderAlpha('border', rootStyle); + } + + /** + * Border radius of the root style. + */ + public function get borderRadius():int { + if (! StyleSheetUtil.hasProperty("borderRadius", rootStyle)) return 5; + return NumberUtil.decodePixels(rootStyle["borderRadius"]); + } + + /** + * Backround image of the rot style. + */ + public function get backgroundImage():String { + if (StyleSheetUtil.hasProperty("backgroundImage", rootStyle)) { + var image:String = rootStyle["backgroundImage"]; + if (image.indexOf("url(") == 0) { + return image.substring(4, image.indexOf(")")); + } + return rootStyle["backgroundImage"] as String; + } + if (StyleSheetUtil.hasProperty("background", rootStyle)) { + return find(StyleSheetUtil.parseShorthand("background", rootStyle), "url("); + } + return null; + } + + /** + * Gets the link URL associated with this sprite. + * @return + */ + public function get linkUrl():String { + return rootStyle["linkUrl"] as String; + } + + /** + * Gets the linkWindow that specifies how the link is opened. + * @return + * @see #linkUrl + */ + public function get linkWindow():String { + if (! StyleSheetUtil.hasProperty("linkWindow", rootStyle)) return "_self"; + return rootStyle["linkWindow"] as String; + } + + private function find(background:Array, prefix:String):String { + for (var i:Number = 0; i < background.length; i++) { + if (background[i] is String && String(background[i]).indexOf(prefix) == 0) { + return background[i] as String; + } + } + return null; + } + + public function get backgroundImageX():Length { + if (! StyleSheetUtil.hasProperty("background", rootStyle)) return new Length(0); + var props:Array = StyleSheetUtil.parseShorthand("background", rootStyle); + if (props.length < 2) return null; + return new Length(props[props.length - 2]); + } + + public function get backgroundImageY():Length { + if (! StyleSheetUtil.hasProperty("background", rootStyle)) return new Length(0); + var props:Array = StyleSheetUtil.parseShorthand("background", rootStyle); + if (props.length < 1) return null; + return new Length(props[props.length - 1]); + } + + /** + * Is the background repeated in the root style? + */ + public function get backgroundRepeat():Boolean { + if (StyleSheetUtil.hasProperty("backgroundRepeat", rootStyle)) { + return rootStyle["backgroundRepeat"] == "repeat"; + } + if (StyleSheetUtil.hasProperty("background", rootStyle)) { + return StyleSheetUtil.parseShorthand("background", rootStyle).indexOf("no-repeat") < 0; + } + return false; + } + + public function get textDecoration():String { + return rootStyle["textDecoration"]; + } + + private function parseCSS(cssText:String):void { + _styleSheet.parseCSS(cssText); + rootStyle = _styleSheet.getStyle(_styleName); + } + + private function parseColorValue(colorProperty:String):uint { + return StyleSheetUtil.colorValue(rootStyle[colorProperty]); + } + + private function parseColorAlpha(colorProperty:String):Number { + return StyleSheetUtil.colorAlpha(rootStyle[colorProperty]); + } + + + + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Flowplayer.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Flowplayer.as new file mode 100644 index 0000000000000000000000000000000000000000..300835ad3209141776c84e82ca724fa851c6b4b6 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Flowplayer.as @@ -0,0 +1,374 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import flash.display.Stage; + import flash.external.ExternalInterface; + import flash.utils.*; + + import org.flowplayer.config.Config; + import org.flowplayer.config.ExternalInterfaceHelper; + import org.flowplayer.controller.ResourceLoader; + import org.flowplayer.flow_internal; + import org.flowplayer.model.Callable; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipEventType; + import org.flowplayer.model.DisplayPluginModel; + import org.flowplayer.model.DisplayProperties; + import org.flowplayer.model.PlayerError; + import org.flowplayer.model.PluginEvent; + import org.flowplayer.model.PluginEventType; + import org.flowplayer.model.PluginModel; + import org.flowplayer.util.NumberUtil; + import org.flowplayer.util.ObjectConverter; + import org.flowplayer.util.PropertyBinder; + + use namespace flow_internal; + + /** + * @author api + */ + public class Flowplayer extends FlowplayerBase { + + private var _keyHandler:KeyboardHandler; + private var _canvas:StyleableSprite; + + public function Flowplayer( + stage:Stage, + pluginRegistry:PluginRegistry, + panel:Panel, + animationEngine:AnimationEngine, + canvas:StyleableSprite, + errorHandler:ErrorHandler, + config:Config, + playerSWFBaseURl:String) { + + super(stage, pluginRegistry, panel, animationEngine, errorHandler, config, playerSWFBaseURl); + _canvas = canvas; + } + + public function initExternalInterface():void { + if (!ExternalInterface.available) + log.info("ExternalInteface is not available in this runtime. JavaScript access will be disabled."); + try { + addCallback("getVersion", function():Array { + return version; + }); + addCallback("getPlaylist", function():Array { + return convert(playlist.clips) as Array; + }); + + addCallback("getId", function():String { + return id; + }); + addCallback("play", genericPlay); + addCallback("playFeed", playFeed); + addCallback("startBuffering", function():void { + startBuffering(); + }); + addCallback("stopBuffering", function():void { + stopBuffering(); + }); + addCallback("isFullscreen", isFullscreen); + addCallback("toggleFullscreen", toggleFullscreen); + + addCallback("toggle", toggle); + addCallback("getState", function():Number { + return state.code; + }); + addCallback("getStatus", function():Object { + return convert(status); + }); + addCallback("isPlaying", isPlaying); + addCallback("isPaused", isPaused); + + var wrapper:WrapperForIE = new WrapperForIE(this); + addCallback("stop", wrapper.fp_stop); + addCallback("pause", wrapper.fp_pause); + addCallback("resume", wrapper.fp_resume); + addCallback("close", wrapper.fp_close); + + addCallback("getTime", function():Number { + return status.time; + }); + addCallback("mute", function():void { + muted = true; + }); + addCallback("unmute", function():void { + muted = false; + }); + addCallback("isMuted", function():Boolean { + return muted; + }); + addCallback("setVolume", function(value:Number):void { + volume = value; + }); + addCallback("getVolume", function():Number { + return volume; + }); + addCallback("seek", genericSeek); + addCallback("getCurrentClip", function():Object { + return new ObjectConverter(currentClip).convert(); + }); + addCallback("getClip", function(index:Number):Object { + return convert(playlist.getClip(index)); + }); + addCallback("setPlaylist", function(playlist:Object):void { + if (playlist is String) loadPlaylistFeed(playlist as String, _playListController.setPlaylist) else setPlaylist(_config.createClips(playlist)); + }); + addCallback("addClip", function(clip:Object, index:int = -1):void { + addClip(_config.createClip(clip), index); + }); + addCallback("showError", showError); + + addCallback("loadPlugin", pluginLoad); + addCallback("showPlugin", showPlugin); + addCallback("hidePlugin", hidePlugin); + addCallback("togglePlugin", togglePlugin); + addCallback("animate", animate); + addCallback("css", css); + // return; + addCallback("reset", reset); + addCallback("fadeIn", fadeIn); + addCallback("fadeOut", fadeOut); + addCallback("fadeTo", fadeTo); + addCallback("getPlugin", function(pluginName:String):Object { + return new ObjectConverter(_pluginRegistry.getPlugin(pluginName)).convert(); + }); + addCallback("getRawPlugin", function(pluginName:String):Object { + return _pluginRegistry.getPlugin(pluginName); + }); + addCallback("invoke", invoke); + addCallback("addCuepoints", addCuepoints); + addCallback("updateClip", updateClip); + addCallback("logging", logging); + + addCallback("setKeyboardShortcutsEnabled", setKeyboardShortcutsEnabled); + addCallback("isKeyboardShortcutsEnabled", isKeyboardShortcutsEnabled); + addCallback("validateKey", validateKey); + + } catch (e:Error) { + handleError(PlayerError.INIT_FAILED, "Unable to add callback to ExternalInterface"); + } + } + + private function loadPlaylistFeed(feedName:String, clipHandler:Function):void { + var feedLoader:ResourceLoader = createLoader(); + feedLoader.addTextResourceUrl(feedName); + feedLoader.load(null, + function(loader:ResourceLoader):void { + log.info("received playlist feed"); + clipHandler(_config.createClips(loader.getContent())); + }); + } + + private function pluginLoad(name:String, url:String, properties:Object = null, callbackId:String = null):void { + loadPluginWithConfig(name, url, properties, callbackId != null ? createCallback(callbackId) : null); + } + + private static function addCallback(methodName:String, func:Function):void { + ExternalInterfaceHelper.addCallback("fp_" + methodName, func); + } + + private function genericPlay(param:Object = null, instream:Boolean = false):void { + if (param == null) { + play(); + return; + } + if (param is Number) { + _playListController.play(null, param as Number); + return; + } + if (param is Array) { + _playListController.playClips(_config.createClips(param as Array)); + return; + } + var clip:Clip = _config.createClip(param); + if (! clip) { + showError("cannot convert " + param + " to a clip"); + return; + } + if (instream) { + playInstream(clip); + return; + } + play(clip); + } + + private function playFeed(feed:String):void { + loadPlaylistFeed(feed, _playListController.playClips); + } + + private function genericSeek(target:Object):void { + var percentage:Number = target is String ? NumberUtil.decodePercentage(target as String) : NaN; + if (isNaN(percentage)) { + seek(target is String ? parseInt(target as String) : target as Number); + } else { + seekRelative(percentage); + } + } + + public function css(pluginName:String, props:Object = null):Object { + log.debug("css, plugin " + pluginName); + if (pluginName == "canvas") { + _canvas.css(props); + return props; + } + return style(pluginName, props, false, 0); + } + + private function convert(objToConvert:Object):Object { + return new ObjectConverter(objToConvert).convert(); + } + + private function collectDisplayProps(props:Object, animatable:Boolean):Object { + var result:Object = new Object(); + var coreDisplayProps:Array = [ "width", "height", "left", "top", "bottom", "right", "opacity" ]; + if (!animatable) { + coreDisplayProps = coreDisplayProps.concat("display", "zIndex"); + } + for (var propName:String in props) { + if (coreDisplayProps.indexOf(propName) >= 0) { + result[propName] = props[propName]; + // delete props[propName]; + } + } + return result; + } + + private function animate(pluginName:String, props:Object, durationMillis:Number = 400, listenerId:String = null):Object { + return style(pluginName, props, true, durationMillis, listenerId); + } + + private function style(pluginName:String, props:Object, animate:Boolean, durationMillis:Number = 400, listenerId:String = null):Object { + var plugin:Object = _pluginRegistry.getPlugin(pluginName); + checkPlugin(plugin, pluginName, DisplayPluginModel); + log.debug("going to animate plugin " + pluginName); + + if (plugin is DisplayProperties && DisplayProperties(plugin).getDisplayObject() is Styleable) + Styleable(DisplayProperties(plugin).getDisplayObject())[animate ? "onBeforeAnimate" : "onBeforeCss"](props); + + var result:Object; + if (props) { + if (pluginName == 'play') { + result = convert(_animationEngine.animateNonPanel(DisplayProperties(_pluginRegistry.getPlugin("screen")).getDisplayObject(), DisplayProperties(plugin).getDisplayObject(), collectDisplayProps(props, animate), durationMillis, createCallback(listenerId, plugin))); + } else { + result = convert(_animationEngine.animate(DisplayProperties(plugin).getDisplayObject(), collectDisplayProps(props, animate), durationMillis, createCallback(listenerId, plugin))); + } + } else { + result = convert(plugin); + } + + // check if plugin is Styleable and delegate to it + if (plugin is DisplayProperties && DisplayProperties(plugin).getDisplayObject() is Styleable) { + var newPluginProps:Object = Styleable(DisplayProperties(plugin).getDisplayObject())[animate ? "animate" : "css"](props); + for (var prop:String in newPluginProps) { + result[prop] = newPluginProps[prop]; + } + } + return result; + } + + private function fadeOut(pluginName:String, durationMillis:Number = 400, listenerId:String = null):void { + var props:DisplayProperties = prepareFade(pluginName, false); + _animationEngine.fadeOut(props.getDisplayObject(), durationMillis, createCallback(listenerId, props)); + } + + private function fadeIn(pluginName:String, durationMillis:Number = 400, listenerId:String = null):void { + var props:DisplayProperties = prepareFade(pluginName, true); + if (pluginName == "play") { + Screen(screen.getDisplayObject()).showPlay(); + } + _animationEngine.fadeIn(props.getDisplayObject(), durationMillis, createCallback(listenerId, props), pluginName != "play"); + } + + private function fadeTo(pluginName:String, alpha:Number, durationMillis:Number = 400, listenerId:String = null):void { + var props:DisplayProperties = prepareFade(pluginName, true); + if (pluginName == "play") { + Screen(screen.getDisplayObject()).showPlay(); + } + _animationEngine.fadeTo(props.getDisplayObject(), alpha, durationMillis, createCallback(listenerId, props), pluginName != "play"); + } + + private function prepareFade(pluginName:String, show:Boolean):DisplayProperties { + var plugin:Object = _pluginRegistry.getPlugin(pluginName); + checkPlugin(plugin, pluginName, DisplayProperties); + if (show) { + var props:DisplayProperties = plugin as DisplayProperties; + if (! props.getDisplayObject().parent || props.getDisplayObject().parent != _panel) { + props.alpha = 0; + } + doShowPlugin(props.getDisplayObject(), props); + } + return plugin as DisplayProperties; + } + + private function invoke(pluginName:String, methodName:String, args:Object = null):Object { + var plugin:Callable = _pluginRegistry.getPlugin(pluginName) as Callable; + checkPlugin(plugin, pluginName, Callable); + try { + // log.debug("invoke() on " + plugin + "." + methodName); + if (plugin.getMethod(methodName).hasReturnValue) { + log.debug("method has a return value"); + return plugin.invokeMethod(methodName, args is Array ? args as Array : [ args ]); + } else { + log.debug("method does not have a return value"); + plugin.invokeMethod(methodName, args is Array ? args as Array : [ args ]); + } + } catch (e:Error) { + throw e; + // handleError(PlayerError.PLUGIN_INVOKE_FAILED, "Error when invoking method '" + methodName + "', on plugin '" + pluginName + "'"); + } + return "undefined"; + } + + private function addCuepoints(cuepoints:Array, clipIndex:int, callbackId:String):void { + var clip:Clip = _playListController.playlist.getClip(clipIndex); + var points:Array = _config.createCuepoints(cuepoints, callbackId, 1); + if (! points || points.length == 0) { + showError("unable to create cuepoints from " + cuepoints); + } + clip.addCuepoints(points); + log.debug("clip has now cuepoints " + clip.cuepoints); + } + + private function updateClip(clipObj:Object, clipIndex:int):void { + log.debug("updateClip()", clipObj); + var clip:Clip = _playListController.playlist.getClip(clipIndex); + new PropertyBinder(clip, "customProperties").copyProperties(clipObj); + clip.dispatch(ClipEventType.UPDATE); + } + + private function createCallback(listenerId:String, pluginArg:Object = null):Function { + if (! listenerId) return null; + return function(plugin:PluginModel = null):void { + if (plugin || pluginArg is PluginModel) { + PluginModel(pluginArg || plugin).dispatch(PluginEventType.PLUGIN_EVENT, listenerId); + } else { + new PluginEvent(PluginEventType.PLUGIN_EVENT, pluginArg is DisplayProperties ? DisplayProperties(pluginArg).name : pluginArg.toString(), listenerId).fireExternal(_playerId); + } + }; + } + + private function validateKey(key:Object, pageDomain:Boolean):Boolean { + var LicenseKey:Class = Class(getDefinitionByName("org.flowplayer.view.LicenseKey")); + return LicenseKey["validate"](_canvas.loaderInfo.url, version, key, pageDomain); + } + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/FlowplayerBase.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/FlowplayerBase.as new file mode 100644 index 0000000000000000000000000000000000000000..83a404cb88ed04f262738927d782c600b292c124 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/FlowplayerBase.as @@ -0,0 +1,761 @@ +/** + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + + +package org.flowplayer.view { + import flash.display.DisplayObject; + import flash.display.Stage; + import flash.text.TextField; + import flash.utils.getDefinitionByName; + + import org.flowplayer.config.Config; + import org.flowplayer.controller.NetConnectionClient; + import org.flowplayer.controller.PlayListController; + import org.flowplayer.controller.ResourceLoader; + import org.flowplayer.controller.ResourceLoaderImpl; + import org.flowplayer.controller.StreamProvider; + import org.flowplayer.flow_internal; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipEventType; + import org.flowplayer.model.Cuepoint; + import org.flowplayer.model.DisplayPluginModel; + import org.flowplayer.model.DisplayProperties; + import org.flowplayer.model.DisplayPropertiesImpl; + import org.flowplayer.model.ErrorCode; + import org.flowplayer.model.Loadable; + import org.flowplayer.model.PlayerError; + import org.flowplayer.model.PlayerEvent; + import org.flowplayer.model.PlayerEventType; + import org.flowplayer.model.Playlist; + import org.flowplayer.model.Plugin; + import org.flowplayer.model.PluginFactory; + import org.flowplayer.model.PluginModel; + import org.flowplayer.model.ProviderModel; + import org.flowplayer.model.State; + import org.flowplayer.model.Status; + import org.flowplayer.util.Assert; + import org.flowplayer.util.Log; + import org.flowplayer.util.LogConfiguration; + import org.flowplayer.util.PropertyBinder; + import org.flowplayer.util.TextUtil; + import org.flowplayer.util.VersionUtil; + import org.flowplayer.util.URLUtil; + import org.flowplayer.view.KeyboardHandler; + + use namespace flow_internal; + + /** + * @author anssi + */ + public class FlowplayerBase extends PlayerEventDispatcher implements ErrorHandler { + + protected var _playListController:PlayListController; + protected var _pluginRegistry:PluginRegistry; + protected var _config:Config; + protected var _animationEngine:AnimationEngine; + protected var _panel:Panel; + + private static var _instance:FlowplayerBase = null; + private var _stage:Stage; + private var _errorHandler:ErrorHandler; + private var _fullscreenManager:FullscreenManager; + private var _pluginLoader:PluginLoader; + private var _playerSWFBaseURL:String; + + + private var _keyHandler:KeyboardHandler; + + public function FlowplayerBase( + stage:Stage, + pluginRegistry:PluginRegistry, + panel:Panel, + animationEngine:AnimationEngine, + errorHandler:ErrorHandler, + config:Config, + playerSWFBaseURL:String) { + + // dummy references to get stuff included in the lib + Assert.notNull(1); + URLUtil.isCompleteURLWithProtocol("foo"); + + var plug:Plugin; + var plugFac:PluginFactory; + var style:FlowStyleSheet; + var styleable:StyleableSprite; + var animation:Animation; + var version:VersionUtil; + var client:NetConnectionClient; + + if (_instance) { + log.error("Flowplayer already instantiated"); + throw new Error("Flowplayer already instantiated"); + } + _stage = stage; +// registerCallbacks(); + _pluginRegistry = pluginRegistry; + _panel = panel; + _animationEngine = animationEngine; + _errorHandler = errorHandler; + _config = config; + _playerSWFBaseURL = playerSWFBaseURL; + _instance = this; + + } + + internal function set playlistController(control:PlayListController):void { + _playListController = control; + addStreamAndConnectionCallbacks(); + } + + internal function set fullscreenManager(value:FullscreenManager):void { + _fullscreenManager = value; + _fullscreenManager.playerEventDispatcher = this; + } + + /** + * Plays the current clip in playList or the specified clip. + * @param clip an optional clip to play. If specified it will replace the player's + * playlist. + */ + public function play(clip:Clip = null):FlowplayerBase { + log.debug("play(" + clip + ")"); + _playListController.play(clip); + return this; + } + + /** + * Starts playing the specified clip "in stream". The clip currently playing is paused + * and the specified clip is started. When the instream clip is finished the original clip + * is resumed. + * @param clip + * @return + */ + public function playInstream(clip:Clip):void { + if (! (isPlaying() || isPaused())) { + handleError(PlayerError.INSTREAM_PLAY_NOTPLAYING); + return; + } + // mark this clip to be "one shot" that will be removed once played + clip.position = -2; + addClip(clip, playlist.currentIndex); + _playListController.playInstream(clip); + } + + public function switchStream(clip:Clip, netStreamPlayOptions:Object = null):void { + log.debug("playSwitchStream(" + clip + ")"); + _playListController.switchStream(clip, netStreamPlayOptions); + } + + /** + * Starts buffering the current clip in playList. + */ + public function startBuffering():FlowplayerBase { + log.debug("startBuffering()"); + _playListController.startBuffering(); + return this; + } + + /** + * Stops buffering. + */ + public function stopBuffering():FlowplayerBase { + log.debug("stopBuffering()"); + _playListController.stopBuffering(); + return this; + } + + /** + * Pauses the current clip. + */ + public function pause():FlowplayerBase { + log.debug("pause()"); + _playListController.pause(); + return this; + } + + /** + * Resumes playback of the current clip. + */ + public function resume():FlowplayerBase { + log.debug("resume()"); + _playListController.resume(); + return this; + } + + /** + * Toggles between paused and resumed states. + * @return true if the player is playing after the call, false if it's paused + */ + public function toggle():Boolean { + log.debug("toggle()"); + if (state == State.PAUSED) { + resume(); + return true; + } else if (state == State.PLAYING) { + pause(); + return false; + } else if (state == State.WAITING) { + play(); + return true; + } + return false; + } + + /** + * Is the player currently paused? + * @return true if the player is currently in the paused state + * @see #state + */ + public function isPaused():Boolean { + return state == State.PAUSED; + } + + /** + * Is the player currently playing? + * @return true if the player is currently in the playing or buffering state + * @see #state + */ + public function isPlaying():Boolean { + return state == State.PLAYING || state == State.BUFFERING; + } + + /** + * Stops the player and rewinds to the beginning of the playList. + */ + public function stop():FlowplayerBase { + log.debug("stop()"); + _playListController.stop(); + return this; + } + + /** + * Stops the player and closes the stream and connection. + * Does not dispatch any events. + */ + public function close():FlowplayerBase { + log.debug("close()"); + dispatch(PlayerEventType.UNLOAD, null, false); + _playListController.close(true); + return this; + } + + /** + * Moves to next clip in playList. + */ + public function next():Clip { + log.debug("next()"); + return _playListController.next(false); + } + + /** + * Moves to previous clip in playList. + */ + public function previous():Clip { + log.debug("previous()"); + return _playListController.previous(); + } + + /** + * Toggles between the full-screen and normal display modeds. + */ + public function toggleFullscreen():Boolean { + log.debug("toggleFullscreen"); + if (dispatchBeforeEvent(PlayerEvent.fullscreen())) { + _fullscreenManager.toggleFullscreen(); + } + return _fullscreenManager.isFullscreen; + } + + /** + * Is the volume muted? + */ + public function get muted():Boolean { + return _playListController.muted; + } + + /** + * Sets the volume muted/unmuted. + */ + public function set muted(value:Boolean):void { + _playListController.muted = value; + } + + /** + * Sets the volume to the specified level. + * @param volume the new volume value, must be between 0 and 100 + */ + public function set volume(volume:Number):void { + _playListController.volume = volume; + } + + /** + * Gets the current volume level. + * @return the volume level percentage (0-100) + */ + public function get volume():Number { + log.debug("get volume"); + return _playListController.volume; + } + + public function hidePlugin(pluginName:String):void { + var plugin:Object = _pluginRegistry.getPlugin(pluginName); + checkPlugin(plugin, pluginName, DisplayProperties); + doHidePlugin(DisplayProperties(plugin).getDisplayObject()); + } + + public function showPlugin(pluginName:String, props:Object = null):void { + pluginPanelOp(doShowPlugin, pluginName, props); + } + + public function togglePlugin(pluginName:String, props:Object = null):Boolean { + return pluginPanelOp(doTogglePlugin, pluginName, props) as Boolean; + } + + private function pluginPanelOp(func:Function, pluginName:String, props:Object = null):Object { + var plugin:Object = _pluginRegistry.getPlugin(pluginName); + checkPlugin(plugin, pluginName, DisplayProperties); + return func(DisplayProperties(plugin).getDisplayObject(), + (props ? new PropertyBinder(new DisplayPropertiesImpl(), null).copyProperties(props) : plugin) as DisplayProperties) ; + } + + protected function doShowPlugin(disp:DisplayObject, displayProps:Object):void { + var props:DisplayProperties; + if (! (displayProps is DisplayProperties)) { + props = new PropertyBinder(new DisplayPropertiesImpl(), null).copyProperties(displayProps) as DisplayProperties; + } else { + props = displayProps as DisplayProperties; + } + disp.alpha = props ? props.alpha : 1; + disp.visible = true; + props.display = "block"; + if (props.zIndex == -1) { + props.zIndex = newPluginZIndex; + } + log.debug("showPlugin, zIndex is " + props.zIndex); + if (playButtonOverlay && disp == playButtonOverlay.getDisplayObject()) { + playButtonOverlay.getDisplayObject()["showButton"](); + } else { + _panel.addView(disp, null, props); + } + var pluginProps:DisplayProperties = _pluginRegistry.getPluginByDisplay(disp); + if (pluginProps) { + _pluginRegistry.updateDisplayProperties(props); + } + } + + private function doHidePlugin(disp:DisplayObject):void { + if (disp.parent == screen && disp == playButtonOverlay.getDisplayObject()) { + playButtonOverlay.getDisplayObject()["hideButton"](); + } else if (disp.parent) { + disp.parent.removeChild(disp); + } + var props:DisplayProperties = _pluginRegistry.getPluginByDisplay(disp); + if (props) { + props.display = "none"; + _pluginRegistry.updateDisplayProperties(props); + } + } + + public function doTogglePlugin(disp:DisplayObject, props:DisplayProperties = null):Boolean { + if (disp.parent == _panel) { + doHidePlugin(disp); + return false; + } else { + doShowPlugin(disp, props); + return true; + } + } + + + /** + * Gets the animation engine. + */ + public function get animationEngine():AnimationEngine { + return _animationEngine; + } + + /** + * Gets the plugin registry. + */ + public function get pluginRegistry():PluginRegistry { + return _pluginRegistry; + } + + /** + * Seeks to the specified target second value in the clip's timeline. + */ + public function seek(seconds:Number):FlowplayerBase { + log.debug("seek to " + seconds + " seconds"); + _playListController.seekTo(seconds); + return this; + } + + /** + * Seeks to the specified point. + * @param the point in the timeline, between 0 and 100 + */ + public function seekRelative(value:Number):FlowplayerBase { + log.debug("seekRelative " + value + "%, clip is " + playlist.current); + seek(playlist.current.duration * (value/100)); + return this; + } + + /** + * Gets the current status {@link PlayStatus} + */ + public function get status():Status { + return _playListController.status; + } + + /** + * Gets the player state. + */ + public function get state():State { + return _playListController.getState(); + } + + /** + * Gets the playList. + */ + public function get playlist():Playlist { + return _playListController.playlist; + } + + /** + * Gets the current clip (the clip currently playing or the next one to be played when playback is started). + */ + public function get currentClip():Clip { + return playlist.current; + } + + /** + * Shows the specified error message in the player area. + */ + public function showError(message:String):void { + _errorHandler.showError(message); + } + + /** + * Handles the specified error. + */ + public function handleError(error:ErrorCode, info:Object = null, throwError:Boolean = true):void { + _errorHandler.handleError(error, info); + } + + /** + * Gets the Flowplayer version number. + * @return for example [3, 0, 0, "free", "release"] - the 4th element + * tells if this is the "free" version or "commercial", the 5th + * element specifies if this is an official "release" or a "development" version. + */ + public function get version():Array { + // this is hacked like this because we cannot have imports to classes + // that are conditionally compiled - otherwise this class cannot by compiled by compc + // library compiler + var VersionInfo:Class = Class(getDefinitionByName("org.flowplayer.config.VersionInfo")); + return VersionInfo.version; + } + + /** + * Gets the player's id. + */ + public function get id():String { + return _config.playerId; + } + + /** + * Loads the specified plugin. + * @param plugin the plugin to load + * @param callback a function to call when the loading is complete + */ + public function loadPlugin(pluginName:String, url:String, callback:Function):void { + loadPluginLoadable(new Loadable(pluginName, _config, url), callback); + } + + public function loadPluginWithConfig(name:String, url:String, properties:Object = null, callback:Function = null):void + { + var loadable:Loadable = new Loadable(name, _config, url); + if (properties) { + new PropertyBinder(loadable, "config").copyProperties(properties); + } + loadPluginLoadable(loadable, callback); + } + + /** + * Creates a text field with default font. If the player configuration has a FontProvider + * plugin configured, we'll use that. Otherwise platform fonts are used, the platform font + * search string used to specify the font is: + * "Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Bitstream Vera, Verdana, Arial, _sans, _serif" + */ + public function createTextField(fontSize:int = 12, bold:Boolean = false):TextField { + if (fonts && fonts.length > 0) { + return TextUtil.createTextField(true, fonts[0], fontSize, bold); + } + return TextUtil.createTextField(false, null, fontSize, bold); + } + + /** + * Adds the specified display object to the panel. + * @param displayObject + * @param props + */ + public function addToPanel(displayObject:DisplayObject, props:Object, resizeListener:Function = null):void { + var properties:DisplayProperties = props is DisplayProperties ? props as DisplayProperties : new PropertyBinder(new DisplayPropertiesImpl(), null).copyProperties(props) as DisplayProperties; + _panel.addView(displayObject, resizeListener, properties); + } + + protected function loadPluginLoadable(loadable:Loadable, callback:Function = null):void { + var loaderCallback:Function = function():void { + log.debug("plugin loaded"); + _pluginRegistry.setPlayerToPlugin(loadable.plugin); + if (loadable.plugin is DisplayPluginModel) { + var displayPlugin:DisplayPluginModel = loadable.plugin as DisplayPluginModel; + if (displayPlugin.visible) { + log.debug("adding plugin to panel"); + if (displayPlugin.zIndex < 0) { + displayPlugin.zIndex = newPluginZIndex; + } + _panel.addView(displayPlugin.getDisplayObject(), null, displayPlugin); + } + } else if (loadable.plugin is ProviderModel){ + _playListController.addProvider(loadable.plugin as ProviderModel); + } + + if (callback != null && loadable.plugin != null ) { + callback(loadable.plugin); + } + }; + _pluginLoader.loadPlugin(loadable, loaderCallback); + } + + private function get newPluginZIndex():Number { + var play:DisplayProperties = _pluginRegistry.getPlugin("play") as DisplayProperties; + if (! play) return 100; + return play.zIndex; + } + + /** + * Gets the fonts that have been loaded as plugins. + */ + public function get fonts():Array { + return _pluginRegistry.fonts; + } + + /** + * Is the player in fullscreen mode? + */ + public function isFullscreen():Boolean { + return _fullscreenManager.isFullscreen; + } + + /** + * Resets the screen and the controls to their orginal display properties + */ + public function reset(pluginNames:Array = null, speed:Number = 500):void { + if (! pluginNames) { + pluginNames = [ "controls", "screen" ]; + } + for (var i:Number = 0; i < pluginNames.length; i++) { + resetPlugin(pluginNames[i], speed); + } + } + + /** + * Configures logging. + */ + public function logging(level:String, filter:String = "*"):void { + var config:LogConfiguration = new LogConfiguration(); + config.level = level; + config.filter = filter; + Log.configure(config); + } + + /** + * Flowplayer configuration. + */ + public function get config():Config { + return _config; + } + + /** + * Creates a new resource loader. + */ + public function createLoader():ResourceLoader { + return new ResourceLoaderImpl(_config.playerId ? null : _playerSWFBaseURL, this); + } + + /** + * Sets a new playlist. + * @param playlist an array of Clip instances + * @see ClipEventType#PLAYLIST_REPLACE + */ + public function setPlaylist(playlist:Array):void { + _playListController.setPlaylist(playlist); + log.debug("setPlaylist, currentIndex is " + this.playlist.currentIndex); + } + + /** + * Adds a new clip into the playlist. Insertion of clips does not change the current clip. + * You can also add instream clips like so: + * <ul> + * <li>position == 0, the clip is added as a preroll</li> + * <li>position == -1, the clip is added as a postroll</li> + * <li>position > 0, the clip is added as a midroll (linear instream)</li> + * </ul> + * @param clip + * @param index optional insertion point, if not given the clip is added to the end of the list. + */ + public function addClip(clip:Clip, index:int = -1):void { + _playListController.playlist.addClip(clip, index); + } + + + /** + * Creates Clip objects from the specified array of objects + * @param clips + * @return + * @see Clip + */ + public function createClips(clips:Array):Array { + return _config.createClips(clips); + } + + private function resetPlugin(pluginName:String, speed:Number = 500):void { + var props:DisplayProperties = _pluginRegistry.getOriginalProperties(pluginName) as DisplayProperties; + if (props) { + _animationEngine.animate(props.getDisplayObject(), props, speed); + } + } + + protected function checkPlugin(plugin:Object, pluginName:String, RequiredClass:Class = null):void { + if (! plugin) { + showError("There is no plugin called '" + pluginName + "'"); + return; + } + if (RequiredClass && ! plugin is RequiredClass) { + showError("Specifiec plugin '" + pluginName + "' is not an instance of " + RequiredClass); + } + } + + /** + * Gets the Screen. + * @return + */ + public function get screen():DisplayProperties { + return _pluginRegistry.getPlugin("screen") as DisplayProperties; + } + + public function get playButtonOverlay():DisplayProperties { + return DisplayProperties(_pluginRegistry.getPlugin("play")) as DisplayProperties; + } + + private function addStreamAndConnectionCallbacks():void { + createCallbacks(_config.connectionCallbacks, addConnectionCallback, ClipEventType.CONNECTION_EVENT); + createCallbacks(_config.streamCallbacks, addStreamCallback, ClipEventType.NETSTREAM_EVENT); + } + + private function addConnectionCallback(name:String, listener:Function):void { + _playListController.addConnectionCallback(name, listener); + } + + private function addStreamCallback(name:String, listener:Function):void { + _playListController.addStreamCallback(name, listener); + } + + private function createCallbacks(callbacks:Array, registerFunc:Function, type:ClipEventType):void { + if (! callbacks) return; + log.debug("registering "+callbacks.length+" callbakcs"); + for (var i:int = 0; i < callbacks.length; i++) { + var name:String = callbacks[i]; + registerFunc(name, createCallbackListener(type, name)); + } + } + + private function createCallbackListener(type:ClipEventType, name:String):Function { + return function(infoObj:Object):void { + log.debug("received callback " + type.name + " forwarding it " + (typeof infoObj)); + + if (name == "onCuePoint") { + var cuepoint:Cuepoint = Cuepoint.createDynamic(infoObj["time"], "embedded"); + for (var prop:String in infoObj) { + log.debug(prop + ": " + infoObj[prop]); + if (prop == "parameters") { + for (var param:String in infoObj.parameters) { + log.debug(param + ": " + infoObj.parameters[param]); + cuepoint.addParameter(param, infoObj.parameters[param]); + } + } else { + cuepoint[prop] = infoObj[prop]; + } + } + playlist.current.dispatch(ClipEventType.forName(name), cuepoint); + return; + } + playlist.current.dispatch(ClipEventType.forName(name), createInfo(infoObj)); + }; + } + + private function createInfo(infoObj:Object):Object { + if (infoObj is Number || infoObj is String || infoObj is Boolean) { + return infoObj; + } + var result:Object = {}; + for (var prop:String in infoObj) { + result[prop] = infoObj[prop]; + } + return result; + } + + public function set pluginLoader(val:PluginLoader):void { + _pluginLoader = val; + } + + public function set keyboardHandler(val:KeyboardHandler):void { + _keyHandler = val; + _keyHandler.player = this as Flowplayer; + } + + public function isKeyboardShortcutsEnabled():Boolean { + return _keyHandler.isKeyboardShortcutsEnabled(); + } + + public function setKeyboardShortcutsEnabled(enabled:Boolean):void { + _keyHandler.setKeyboardShortcutsEnabled(enabled); + } + + public function addKeyListener(keyCode:uint, func:Function):void { + _keyHandler.addKeyListener(keyCode, func); + } + + public function removeKeyListener(keyCode:uint, func:Function):void { + _keyHandler.removeKeyListener(keyCode, func); + } + + /** + * Gets the StreamProvider of the current clip. + * @return + */ + public function get streamProvider():StreamProvider { + return _playListController.streamProvider; + } + + public function get panel():Panel { + return _panel; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/FlowplayerComponent.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/FlowplayerComponent.as new file mode 100644 index 0000000000000000000000000000000000000000..e0b1b3bb7e614cb2cfdc144b19592487d926357b --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/FlowplayerComponent.as @@ -0,0 +1,16 @@ +package org.flowplayer.view { + import mx.core.UIComponent; + + public class FlowplayerComponent extends UIComponent { + private var _launcher:Launcher; + + public function FlowplayerComponent() { + } + + override protected function createChildren():void { + _launcher = new Launcher(); + addChild(_launcher); + } + + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/FullscreenManager.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/FullscreenManager.as new file mode 100644 index 0000000000000000000000000000000000000000..d9d2a063689ac1a08aa43b7486a002de7b772291 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/FullscreenManager.as @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import flash.display.DisplayObject; + + import org.flowplayer.model.Clip; + import org.flowplayer.model.Cloneable; + import org.flowplayer.model.DisplayPluginModel; + import org.flowplayer.model.DisplayProperties; + import org.flowplayer.model.DisplayPropertiesImpl; + import org.flowplayer.model.PlayerEvent; + import org.flowplayer.model.Playlist; + import org.flowplayer.model.PluginModel; + import org.flowplayer.util.Assert; + import org.flowplayer.util.Log; + + import flash.display.Stage; + import flash.display.StageDisplayState; + import flash.events.FullScreenEvent; + import flash.geom.Rectangle; + + /** + * @author api + */ + internal class FullscreenManager { + private var log:Log = new Log(this); + private var _stage:Stage; + private var _playlist:Playlist; + private var _panel:Panel; + private var _pluginRegistry:PluginRegistry; + private var _animations:AnimationEngine; + private var _screen:Screen; + private var _screenNormalProperties:DisplayProperties; + private var _playerEventDispatcher:PlayerEventDispatcher; + + public function FullscreenManager(stage:Stage, playlist:Playlist, panel:Panel, pluginRegistry:PluginRegistry, animations:AnimationEngine) { + Assert.notNull(stage, "stage cannot be null"); + _stage = stage; + _stage.addEventListener(FullScreenEvent.FULL_SCREEN, onFullScreen); + _playlist = playlist; + _panel = panel; + _pluginRegistry = pluginRegistry; + _screen = (pluginRegistry.getPlugin("screen") as DisplayProperties).getDisplayObject() as Screen; + Assert.notNull(_screen, "got null screen from pluginRegistry"); + _screen.fullscreenManager = this; + _animations = animations; + } + + private function getFullscreenProperties():DisplayProperties { + var model:DisplayPluginModel = _pluginRegistry.getPlugin("controls") as DisplayPluginModel; + if (! model) return DisplayPropertiesImpl.fullSize("screen"); + + var controls:DisplayObject = model.getDisplayObject(); + log.debug("controls.auotoHide " + controls["getAutoHide"]()); + + if ( controls && ! controls["getAutoHide"]().enabled ) { + log.debug("autoHiding disabled in fullscreen, calculating fullscreen display properties"); + var controlsHeight:Number = controls.height; + var props:DisplayProperties = DisplayPropertiesImpl.fullSize("screen"); + props.bottom = controlsHeight; + props.height = ((_stage.stageHeight - controlsHeight) / _stage.stageHeight) * 100 + "%"; + return props; + } + return DisplayPropertiesImpl.fullSize("screen"); + } + + public function toggleFullscreen():void { + log.debug("toggleFullsreen"); + if (isFullscreen) { + exitFullscreen(); + } else { + goFullscreen(); + } + } + + private function exitFullscreen():void { + log.info("exiting fullscreen"); + _stage.displayState = StageDisplayState.NORMAL; + } + + private function goFullscreen():void { + log.info("entering fullscreen"); + var clip:Clip = _playlist.current; + initializeHwScaling(clip); + _stage.displayState = StageDisplayState.FULL_SCREEN; + } + + public function get isFullscreen():Boolean { + log.debug("currently in fulscreen? " + (_stage.displayState == StageDisplayState.FULL_SCREEN)); + return _stage.displayState == StageDisplayState.FULL_SCREEN; + } + + private function initializeHwScaling(clip:Clip):void { + if (! _stage.hasOwnProperty("fullScreenSourceRect")) { + log.info("hardware scaling not supported by this Flash version"); + return; + } + if (clip.accelerated) { + _stage.fullScreenSourceRect = new Rectangle(0, 0,clip.originalWidth, clip.originalHeight); + log.info("harware scaled fullscreen initialized with rectangle " + _stage.fullScreenSourceRect); + } else { + _stage.fullScreenSourceRect = null; + } + } + + private function onFullScreen(event:FullScreenEvent):void { + // store the normal screen properties just prior to entering fullscreen so that the user's screen animations can be restored + if (event.fullScreen) { + _screenNormalProperties = Cloneable(_pluginRegistry.getPlugin("screen")).clone() as DisplayProperties; + } + _animations.animate(_screen, event.fullScreen ? getFullscreenProperties() : _screenNormalProperties, 0, function():void {_playerEventDispatcher.dispatchEvent(event.fullScreen ? PlayerEvent.fullscreen() : PlayerEvent.fullscreenExit());}); + } + + public function set playerEventDispatcher(playerEventDispatcher:PlayerEventDispatcher):void { + _playerEventDispatcher = playerEventDispatcher; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/ImageDisplay.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/ImageDisplay.as new file mode 100644 index 0000000000000000000000000000000000000000..b2e0e968e0ac8a7b42b3914f3251e41cb6bd2cf7 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/ImageDisplay.as @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import org.flowplayer.model.Clip; + import org.flowplayer.view.MediaDisplay; + + import flash.display.DisplayObject; + + /** + * @author api + */ + internal class ImageDisplay extends AbstractSprite implements MediaDisplay { + + private var image:DisplayObject; + private var _clip:Clip; + + public function ImageDisplay(clip:Clip) { + _clip = clip; + } + + public function init(clip:Clip):void { + log.debug("received image to display"); + if (image) + removeChild(image); + if (! clip.getContent()) return; + image = clip.getContent(); + addChild(image); + } + + public function hasContent():Boolean { + return image != null; + } + + override public function toString():String { + return "[ImageDisplay] for clip " + _clip; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/ImageHolder.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/ImageHolder.as new file mode 100644 index 0000000000000000000000000000000000000000..e6babeba19fbbb0ffe37bb34467183b44caea34a --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/ImageHolder.as @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import flash.display.*; + import flash.events.*; + + import org.flowplayer.util.Log; + + /** + * @author api + */ + public class ImageHolder extends Sprite { + + private var _loader:Loader; + private var _mask:Sprite; + + private var _width:int; + private var _height:int; + private var _originalWidth:int; + private var _originalHeight:int; + + private var _widthRatio:Number; + private var _heightRatio:Number; + + public function ImageHolder(loader:Loader) { + super(); + + _loader = loader; + + + _originalWidth = loader.contentLoaderInfo.width; + _originalHeight = loader.contentLoaderInfo.height; + + _width = loader.width; + _height= loader.height; + + _widthRatio = _width / _originalWidth; + _heightRatio= _height / _originalHeight; + + //width = _originalWidth; + //height = _originalHeight + + graphics.drawRect(0, 0, _originalWidth, _originalHeight); + addChild(_loader); + updateMask(); + } + + private function updateMask():void + { + if ( _mask != null && contains(_mask) ) + removeChild(_mask); + + _mask = new Sprite(); + _mask.graphics.beginFill(0xFF0000); + _mask.graphics.drawRect(0, 0, _width, _height); + addChild(_mask); + _loader.mask = _mask; + } + + public override function get width():Number { + return _width || super.width; + } + + public override function set width(value:Number):void { + _width = value; + _loader.width = value * _widthRatio; + updateMask(); + } + + public override function get height():Number { + return _height || super.height; + } + + public override function set height(value:Number):void { + _height = value; + _loader.height = value * _heightRatio; + updateMask(); + } + + public function get originalWidth():int { + return _originalWidth; + } + + public function get originalHeight():int { + return _originalHeight; + } + + public static function hasOffscreenContent(loader:Loader):Boolean + { + return loader.width != loader.contentLoaderInfo.width || loader.height != loader.contentLoaderInfo.height; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/KeyboardHandler.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/KeyboardHandler.as new file mode 100644 index 0000000000000000000000000000000000000000..aa359a0ed2a5e13b2f82a6199dbe52805bf75be6 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/KeyboardHandler.as @@ -0,0 +1,148 @@ +/* + * Author: Anssi Piirainen, <api@iki.fi> + * + * Copyright (c) 2009-2011 Flowplayer Oy + * + * This file is part of Flowplayer. + * + * Flowplayer is licensed under the GPL v3 license with an + * Additional Term, see http://flowplayer.org/license_gpl.html + */ +package org.flowplayer.view { + import flash.display.Stage; + import flash.events.KeyboardEvent; + import flash.ui.Keyboard; + + import flash.utils.Dictionary; + + import org.flowplayer.model.Clip; + import org.flowplayer.model.PlayerEvent; + import org.flowplayer.model.Status; + import org.flowplayer.util.Log; + + public class KeyboardHandler { + + private var log:Log = new Log(this); + private var _player:Flowplayer; + private var _keyboardShortcutsEnabled:Boolean; + + private var _handlers:Dictionary = new Dictionary(); + + public function set player(p:Flowplayer):void + { + _player = p; + } + + public function KeyboardHandler(stage:Stage, enteringFullscreenCb:Function) { + _keyboardShortcutsEnabled = true; + + addKeyListener(Keyboard.SPACE, function(event:KeyboardEvent):void { + _player.toggle(); + }); + + /* + * Volume control + */ + var volumeUp:Function = function(event:KeyboardEvent):void { + var volume:Number = _player.volume; + volume += 10; + log.debug("setting volume to " + volume); + _player.volume = volume > 100 ? 100 : volume; + }; + addKeyListener(Keyboard.UP, volumeUp); + addKeyListener(75, volumeUp); + + var volumeDown:Function = function(event:KeyboardEvent):void { + log.debug("down"); + var volume:Number = _player.volume; + volume -= 10; + log.debug("setting volume to " + volume); + _player.volume = volume < 0 ? 0 : volume; + }; + addKeyListener(Keyboard.DOWN, volumeDown); + addKeyListener(74, volumeDown); + + addKeyListener(77, function(event:KeyboardEvent):void { + _player.muted = ! _player.muted; + }); + + /* + * Jump seeking + */ + var jumpseek:Function = function(forwards:Boolean = true):void { +// if (! _player.isPlaying()) return; + var status:Status = _player.status; + if (! status) return; + var time:Number = status.time; + var clip:Clip = _player.playlist.current; + if (! clip) return; + + var targetTime:Number = time + (forwards ? 0.1 : -0.1) * clip.duration; + if (targetTime < 0) { + targetTime = 0; + } + if (targetTime > (status.allowRandomSeek ? clip.duration : (status.bufferEnd - clip.bufferLength))) { + targetTime = status.allowRandomSeek ? clip.duration : (status.bufferEnd - clip.bufferLength - 5); + } + _player.seek(targetTime); + }; + + var jumpforward:Function = function(event:KeyboardEvent):void { if ( ! event.ctrlKey ) jumpseek(); }; + var jumpbackward:Function = function(event:KeyboardEvent):void { if ( ! event.ctrlKey ) jumpseek(false); }; + addKeyListener(Keyboard.RIGHT, jumpforward); + addKeyListener(76, jumpforward); + addKeyListener(Keyboard.LEFT, jumpbackward); + addKeyListener(72, jumpbackward); + + + stage.addEventListener(KeyboardEvent.KEY_DOWN, + function(event:KeyboardEvent):void { + log.debug("keyDown: " + event.keyCode); + if ( enteringFullscreenCb() ) return; + if ( ! isKeyboardShortcutsEnabled() ) return; + if (_player.dispatchBeforeEvent(PlayerEvent.keyPress(event.keyCode))) { + _player.dispatchEvent(PlayerEvent.keyPress(event.keyCode)); + if (_handlers[event.keyCode] != null) { + for ( var i:int = 0; i < _handlers[event.keyCode].length; i++) + _handlers[event.keyCode][i](event); + } + } + }); + } + + public function addKeyListener(keyCode:uint, func:Function):void + { + if ( _handlers[keyCode] == null ) + _handlers[keyCode] = []; + + _handlers[keyCode].push(func); + } + + public function removeKeyListener(keyCode:uint, func:Function):void + { + if ( _handlers[keyCode] == null ) + return; + + if ( _handlers[keyCode].indexOf(func) == -1 ) + return; + + var handlers:Array = []; + for ( var i:int; i < _handlers[keyCode].length; i++ ) + if ( _handlers[keyCode][i] != func ) + handlers.push(_handlers[keyCode][i]); + + _handlers[keyCode] = handlers; + } + + public function isKeyboardShortcutsEnabled():Boolean + { + return _keyboardShortcutsEnabled; + } + + public function setKeyboardShortcutsEnabled(enabled:Boolean):void + { + _keyboardShortcutsEnabled = enabled; + } + + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Launcher.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Launcher.as new file mode 100644 index 0000000000000000000000000000000000000000..aec94bfda1bff9a1864f4890e03e007e3bee7048 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Launcher.as @@ -0,0 +1,893 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ +package org.flowplayer.view { + import flash.external.ExternalInterface; + + import org.flowplayer.config.Config; + import org.flowplayer.config.ConfigParser; + import org.flowplayer.config.ExternalInterfaceHelper; + import org.flowplayer.config.VersionInfo; + import org.flowplayer.controller.PlayListController; + import org.flowplayer.controller.ResourceLoader; + import org.flowplayer.controller.ResourceLoaderImpl; + import org.flowplayer.flow_internal; + import org.flowplayer.model.Callable; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipEvent; +import org.flowplayer.model.ClipEventType; +import org.flowplayer.model.DisplayPluginModel; + import org.flowplayer.model.DisplayProperties; + import org.flowplayer.model.DisplayPropertiesImpl; + import org.flowplayer.model.ErrorCode; + import org.flowplayer.model.EventDispatcher; + import org.flowplayer.model.Loadable; + import org.flowplayer.model.Logo; + import org.flowplayer.model.PlayButtonOverlay; + import org.flowplayer.model.PlayerError; + import org.flowplayer.model.PlayerEvent; + import org.flowplayer.model.Playlist; + import org.flowplayer.model.Plugin; + import org.flowplayer.model.PluginError; + import org.flowplayer.model.PluginEvent; + import org.flowplayer.model.PluginModel; + import org.flowplayer.model.ProviderModel; + import org.flowplayer.model.State; + import org.flowplayer.util.Arrange; + import org.flowplayer.util.Log; + import org.flowplayer.util.TextUtil; + import org.flowplayer.util.URLUtil; + import org.flowplayer.view.Panel; + import org.flowplayer.view.PluginLoader; + import org.flowplayer.view.Screen; + import org.flowplayer.view.KeyboardHandler; + import org.osflash.thunderbolt.Logger; + + import flash.display.DisplayObject; + import flash.display.DisplayObjectContainer; + import flash.display.Sprite; + import flash.events.Event; + import flash.events.MouseEvent; + import flash.events.TimerEvent; + import flash.net.URLRequest; + import flash.net.navigateToURL; + import flash.system.Capabilities; + import flash.system.Security; + import flash.text.TextField; + import flash.text.TextFieldAutoSize; + + import flash.utils.*; + + use namespace flow_internal; + + public class Launcher extends StyleableSprite implements ErrorHandler { + private var _panel:Panel; + private var _screen:Screen; + private var _config:Config; + private var _flowplayer:Flowplayer; + private var _pluginRegistry:PluginRegistry; + private var _animationEngine:AnimationEngine; + private var _playButtonOverlay:PlayButtonOverlay; + private var _controlsModel:DisplayPluginModel; + private var _providers:Dictionary = new Dictionary(); + private var _canvasLogo:Sprite; + private var _pluginLoader:PluginLoader; + private var _error:TextField; + private var _pluginsInitialized:Number = 0; + private var _enteringFullscreen:Boolean; + private var _copyrightNotice:TextField; + private var _playlistLoader:ResourceLoader; + private var _fullscreenManager:FullscreenManager; + private var _screenArrangeCount:int = 0; + private var _clickCount:int; + private var _clickTimer:Timer = new Timer(200, 1); + private var _clickEvent:MouseEvent; + + [Frame(factoryClass="org.flowplayer.view.Preloader")] + public function Launcher() { + addEventListener(Event.ADDED_TO_STAGE, function(e:Event):void { + URLUtil.loaderInfo = loaderInfo; + trace("Launcher added to stage"); + callAndHandleError(createFlashVarsConfig, PlayerError.INIT_FAILED); + }); + super("#canvas", this); + } + + private function initPhase1():void { + + if (_flowplayer) { + log.debug("already initialized, returning"); + return; + } + + Log.configure(_config.getLogConfiguration()); + trace("created log configuration, tracing enabled? " + Log.traceEnabled) + + initCustomClipEvents(); + + if (_config.playerId) { + Security.allowDomain(URLUtil.pageLocation); + } + + loader = createNewLoader(); + + rootStyle = _config.canvas.style; + stage.addEventListener(Event.RESIZE, onStageResize); + stage.addEventListener(Event.RESIZE, arrangeScreen); + setSize(Arrange.parentWidth, Arrange.parentHeight); + + if (! VersionInfo.commercial) { + log.debug("Adding logo to canvas"); + createLogoForCanvas(); + } + + log = new Log(this); + EventDispatcher.playerId = _config.playerId; + + log.debug("security sandbox type: " + Security.sandboxType); + + log.info(VersionInfo.versionInfo()); + trace(VersionInfo.versionInfo()); + log.debug("creating Panel"); + + createPanel(); + _pluginRegistry = new PluginRegistry(_panel); + + log.debug("Creating animation engine"); + createAnimationEngine(_pluginRegistry); + + log.debug("creating play button overlay"); + createPlayButtonOverlay(); + + log.debug("creating Flowplayer API"); + createFlowplayer(); + + // keyboard handler must be present for plugins. + // + + loadPlaylistFeed(); + } + + private function initPhase2(event:Event = null):void { + log.info("initPhase2"); + _flowplayer.keyboardHandler = new KeyboardHandler(stage, function():Boolean { return enteringFullscreen }); + loadPlugins(); + } + + private function initPhase3(event:Event = null):void { + log.debug("initPhase3, all plugins loaded"); + createScreen(); + + _config.getPlaylist().onBeforeBegin(function(event:ClipEvent):void { hideErrorMessage(); }); + if (_playButtonOverlay) { + PlayButtonOverlayView(_playButtonOverlay.getDisplayObject()).playlist = _config.getPlaylist(); + } + + log.debug("creating PlayListController"); + _providers = _pluginLoader.providers; + var playListController:PlayListController = createPlayListController(); + + addPlayListListeners(); + createFullscreenManager(playListController.playlist); + + addScreenToPanel(); + + if (!validateLicenseKey()) { + createLogoForCanvas(); + resizeCanvasLogo(); + } + + log.debug("creating logo"); + createLogo(); + + contextMenu = new ContextMenuBuilder(_config.playerId, _config.contextMenu).build(); + + log.debug("initializing ExternalInterface"); + if (useExternalInterface()) { + _flowplayer.initExternalInterface(); + } + + log.debug("calling onLoad to plugins"); + _pluginRegistry.onLoad(_flowplayer); + + if (countPlugins() == 0) { + log.debug("no loadable plugins, calling initPhase4"); + initPhase4(); + } + } + + private function initPhase4(event:Event = null):void { + log.info("initPhase4, all plugins initialized"); + + log.debug("Adding visible plugins to panel"); + addPluginsToPanel(_pluginRegistry); + + log.debug("dispatching onLoad"); + _flowplayer.dispatchEvent(PlayerEvent.load("player")); + + log.debug("starting configured streams"); + startStreams(); + arrangeScreen(); + + addListeners(); + +// _controlsModel.onPluginEvent(function(event:PluginEvent):void { +// log.debug("received plugin event " + event.id); +// var model:DisplayPluginModel = event.target as DisplayPluginModel; +// log.debug("controls y-pos now is " + model.getDisplayObject().y); +// }); +// +// _controlsModel.onBeforePluginEvent(function(event:PluginEvent):void { +// log.debug("received before plugin event " + event.id); +// var model:DisplayPluginModel = event.target as DisplayPluginModel; +// log.debug("controls y-pos now is " + model.getDisplayObject().y); +// event.preventDefault(); +// }); +// lookupSlowMotionPlugin(_flowplayer); + } + + private function resizeCanvasLogo():void { + _canvasLogo.alpha = 1; + _canvasLogo.width = 150; + _canvasLogo.scaleY = _canvasLogo.scaleX; + arrangeCanvasLogo(); + } + + private function useExternalInterface():Boolean { + log.debug("useExternalInteface: " + (_config.playerId != null)); + return _config.playerId != null; + } + + private function onStageResize(event:Event = null):void { + setSize(Arrange.parentWidth, Arrange.parentHeight); + arrangeCanvasLogo(); + } + + private function arrangeCanvasLogo():void { + if (!_canvasLogo) return; + _canvasLogo.x = 15; + _canvasLogo.y = Arrange.parentHeight - (_controlsModel ? _controlsModel.dimensions.height.toPx(Arrange.parentHeight) + 10 : 10) - _canvasLogo.height - _copyrightNotice.height; + _copyrightNotice.x = 12; + _copyrightNotice.y = _canvasLogo.y + _canvasLogo.height; + } + + private function loadPlugins():void { + var plugins:Array = _config.getLoadables(); + log.debug("will load following plugins: "); + logPluginInfo(plugins); + _pluginLoader = new PluginLoader(URLUtil.playerBaseUrl, _pluginRegistry, this, useExternalInterface()); + _pluginLoader.addEventListener(Event.COMPLETE, pluginLoadListener); + _flowplayer.pluginLoader = _pluginLoader; + if (plugins.length == 0) { + log.debug("configuration has no plugins"); + initPhase3(); + } else { +// _builtInPlugins = _config.createLoadables(BuiltInConfig.config.plugins); +// log.debug("following built-in plugins will be instantiated"); +// trace("builtIn plugins: "); +// logPluginInfo(_builtInPlugins, true); + _pluginLoader.load(plugins, onPluginLoad, onPluginLoadError); + } + } + + private function logPluginInfo(plugins:Array, doTrace:Boolean = false):void { + for (var i:Number = 0; i < plugins.length; i++) { + log.info("" + plugins[i]); + if (doTrace) { + trace("" + plugins[i]); + } + } + } + + private function pluginLoadListener(event:Event = null):void { + _pluginLoader.removeEventListener(Event.COMPLETE, pluginLoadListener); + callAndHandleError(initPhase3, PlayerError.INIT_FAILED); + } + + private function loadPlaylistFeed():void { + var playlistFeed:String = _config.playlistFeed; + if (! playlistFeed) { + callAndHandleError(initPhase2, PlayerError.INIT_FAILED); + return; + } + log.info("loading playlist from " + playlistFeed); + _playlistLoader = _flowplayer.createLoader(); + _playlistLoader.addTextResourceUrl(playlistFeed); + _playlistLoader.load(null, + function(loader:ResourceLoader):void { + log.info("received playlist feed"); + _config.playlistDocument = loader.getContent() as String; + _config.getPlaylist().dispatchPlaylistReplace(); + callAndHandleError(initPhase2, PlayerError.INIT_FAILED); + }); + } + + private function onPluginLoad(event:PluginEvent):void { + var plugin:PluginModel = event.target as PluginModel; + log.info("plugin " + plugin + " initialized"); + checkPluginsInitialized(); + } + + private function onPluginLoadError(event:PluginEvent):void { + if (event.target is Loadable) { + handleError(PlayerError.PLUGIN_LOAD_FAILED, "unable to load plugin '" + Loadable(event.target).name + "', url: '" + Loadable(event.target).url + "'"); +// throw new Error("unable to load plugin '" + Loadable(event.target).name + "', url: '" + Loadable(event.target).url + "'"); + } else { + var plugin:PluginModel = event.target as PluginModel; + _pluginRegistry.removePlugin(plugin); + handleError(PlayerError.PLUGIN_LOAD_FAILED, "load/init error on " + plugin); + } + } + + private function checkPluginsInitialized():void { + var numPlugins:int = countPlugins(); + if (++_pluginsInitialized == numPlugins) { + log.info("all plugins initialized"); + callAndHandleError(initPhase4, PlayerError.INIT_FAILED); + } + log.info(_pluginsInitialized + " out of " + numPlugins + " plugins initialized"); + } + + private function countPlugins():int { + var count:Number = 0; + var loadables:Array = _config.getLoadables(); + for (var i:Number = 0; i < loadables.length; i++) { + + var plugin:PluginModel = Loadable(loadables[i]).plugin; + if (! plugin) { + handleError(PlayerError.PLUGIN_LOAD_FAILED, "Unable to load plugin, url " + Loadable(loadables[i]).url + ", name " + Loadable(loadables[i]).name); +// throw new Error("Plugin " + loadables[i] + " not available"); + } + else + { + var isNonAdHocPlugin:Boolean = plugin.pluginObject is Plugin; + // var isNonAdHocPlugin:Boolean = (plugin is DisplayPluginModel && DisplayPluginModel(plugin).getDisplayObject() is Plugin) || + // plugin is ProviderModel && ProviderModel(plugin).pluginObject is Plugin; + + if (Loadable(loadables[i]).loadFailed) { + log.debug("load failed for " + loadables[i]); + count++; + } else if (! plugin) { + log.debug("this plugin is not loaded yet"); + count++; + } else if (isNonAdHocPlugin) { + log.debug("will wait for onLoad from plugin " + plugin); + count++; + } else { + log.debug("will NOT wait for onLoad from plugin " + Loadable(loadables[i]).plugin); + } + } + } + // +1 comes from the playbuttonoverlay + return count + (_playButtonOverlay ? 1 : 0); + } + + private function validateLicenseKey():Boolean { + try { + return LicenseKey.validate(root.loaderInfo.url, _flowplayer.version, _config.licenseKey, useExternalInterface()); + } catch (e:Error) { + log.warn("License key not accepted, will show flowplayer logo"); + } + return false; + } + + private function createFullscreenManager(playlist:Playlist):void { + _fullscreenManager = new FullscreenManager(stage, playlist, _panel, _pluginRegistry, _animationEngine); + _flowplayer.fullscreenManager = _fullscreenManager; + } + + public function showError(message:String):void { + if (! _panel) return; + if (! _config.showErrors) return; + if (_error && _error.parent == this) { + removeChild(_error); + } + + _error = TextUtil.createTextField(false); + _error.background = true; + _error.backgroundColor = 0; + _error.textColor = 0xffffff; + _error.autoSize = TextFieldAutoSize.CENTER; + _error.multiline = true; + _error.wordWrap = true; + _error.text = message; + _error.selectable = true; + _error.width = Arrange.parentWidth - 40; + Arrange.center(_error, Arrange.parentWidth, Arrange.parentHeight); + addChild(_error); + + createErrorMessageHideTimer(); + } + + private function createErrorMessageHideTimer():void { + var errorHideTimer:Timer = new Timer(10000, 1); + errorHideTimer.addEventListener(TimerEvent.TIMER_COMPLETE, hideErrorMessage); + errorHideTimer.start(); + } + + private function hideErrorMessage(event:TimerEvent = null):void { + if (_error && _error.parent == this) { + if (_animationEngine) { + _animationEngine.fadeOut(_error, 1000, function():void { removeChild(_error); }); + } else { + removeChild(_error); + } + } + } + + public function handleError(error:ErrorCode, info:Object = null, throwError:Boolean = true):void { + if (_flowplayer) { + _flowplayer.dispatchError(error, info); + } else { + // initialization is not complete, create a dispatches just to dispatch this error + new PlayerEventDispatcher().dispatchError(error, info); + } + var stack:String = ""; + if ( CONFIG::debug && info is Error && info.getStackTrace() ) + stack = info.getStackTrace(); + doHandleError(error.code + ": " + error.message + ( info ? ": " + info + (stack ? " - Stack: "+ stack : "") : ""), throwError); + } + + private function doHandleError(message:String, throwError:Boolean = true):void { + if (_config && _config.playerId) { + Logger.error(message); + } + showError(message); + if (throwError && Capabilities.isDebugger && _config.showErrors) { + throw new Error(message); + } + } + + private function createAnimationEngine(pluginRegistry:PluginRegistry):void { + _animationEngine = new AnimationEngine(_panel, pluginRegistry); + } + + private function addPluginsToPanel(_pluginRegistry:PluginRegistry):void { + for each (var pluginObj:Object in _pluginRegistry.plugins) { + if (pluginObj is DisplayPluginModel) { + var model:DisplayPluginModel = pluginObj as DisplayPluginModel; + log.debug("adding plugin '"+ model.name +"' to panel: " + model.visible + ", plugin object is " + model.getDisplayObject()); + if (model.visible) { + if (model.zIndex == -1) { + model.zIndex = 100; + } + _panel.addView(model.getDisplayObject(), undefined, model); + } + if (model.name == "controls") { + _controlsModel = model; + } + } + } + if (_controlsModel) { + arrangeCanvasLogo(); + } + } + + private function addScreenToPanel():void { + // if controls visible and screen was not explicitly configured --> place screen on top of controls + var screen:DisplayProperties = _pluginRegistry.getPlugin("screen") as DisplayProperties; + screen.display = "none"; + screen.getDisplayObject().visible = false; + _panel.addView(screen.getDisplayObject(), null, screen); + } + + private function arrangeScreen(event:Event = null):void { + log.debug("arrangeScreen(), already arranged " + _screenArrangeCount); + if (_screenArrangeCount > 1) return; + if (! _pluginRegistry) return; + var screen:DisplayProperties = _pluginRegistry.getPlugin("screen") as DisplayProperties; + if (! screen) return; + + if (_controlsModel && _controlsModel.visible) { + + if (isControlsAlwaysAutoHide() || (_controlsModel.position.bottom.px > 0)) { + log.debug("controls is autoHide or it's in a non-default vertical position, configuring screen to take all available space"); + setScreenBottomAndHeight(screen, 100, 0); + } else { + var controlsHeight:Number = _controlsModel.getDisplayObject().height; + var occupiedHeight:Number = screenTopOrBottomConfigured() ? getScreenTopOrBottomPx(screen) : controlsHeight; + log.debug("occupied by controls or screen's configured bottom/top is " + occupiedHeight); + + var heightPct:Number = 0; + if (screenTopOrBottomConfigured() && (screen.position.top.pct >= 0 || screen.position.bottom.pct >= 0)) { + heightPct = 100 - Math.abs(50 - (screen.position.top.pct >= 0 ? screen.position.top.pct : screen.position.bottom.pct))*2; + setScreenBottomAndHeight(screen, heightPct, controlsHeight); + } else { + heightPct = ((Arrange.parentHeight - occupiedHeight) / Arrange.parentHeight) * 100; + setScreenBottomAndHeight(screen, heightPct, controlsHeight); + } + } + } + log.debug("arrangeScreen(): arranging screen to pos " + screen.position); + screen.display = "block"; + screen.alpha = 1; + screen.getDisplayObject().visible = true; + _pluginRegistry.updateDisplayProperties(screen, true); + _panel.update(screen.getDisplayObject(), screen); + _panel.draw(screen.getDisplayObject()); + _screenArrangeCount++; + } + + private function getScreenTopOrBottomPx(screen:DisplayProperties):Number { + var screenConf:Object = _config.getObject("screen"); + if (screenConf.hasOwnProperty("top")) return screen.position.top.toPx(Arrange.parentHeight); + if (screenConf.hasOwnProperty("bottom")) return screen.position.bottom.toPx(Arrange.parentHeight); + return 0; + } + + private function setScreenBottomAndHeight(screen:DisplayProperties, heightPct:Number, bottom:Number = 0):void { + if (! screenTopOrBottomConfigured()) { + log.debug("screen vertical pos not configured, setting bottom to value " + bottom); + screen.bottom = bottom; + } else { + log.debug("using configured top/bottom for screen"); + } + + var heightConfigured:Boolean = _config.getObject("screen") && _config.getObject("screen").hasOwnProperty("height"); + if (! heightConfigured) { + log.debug("screen height not configured, setting it to value " + heightPct + "%"); + screen.height = heightPct + "%"; + } else { + log.debug("using configured height for screen"); + } + } + + private function screenTopOrBottomConfigured():Boolean { + var screen:Object = _config.getObject("screen"); + if (! screen) return false; + if (screen.hasOwnProperty("top")) return true; + if (screen.hasOwnProperty("bottom")) return true; + return false; + } + + private function isControlsAlwaysAutoHide():Boolean { + if (!_controlsModel) return false; + var controls:DisplayObject = _controlsModel.getDisplayObject(); + log.debug("controls.auotoHide " + controls["getAutoHide"]()); + return ! controls["getAutoHide"]()["fullscreenOnly"]; + } + + private function createFlowplayer():void { + _flowplayer = new Flowplayer(stage, _pluginRegistry, _panel, + _animationEngine, this, this, _config, URLUtil.playerBaseUrl); + + _flowplayer.onBeforeFullscreen(onFullscreen); +// _flowplayer.onFullscreenExit(onFullscreen); + } + + private function onFullscreen(event:PlayerEvent):void { + log.debug("entering fullscreen, disabling display clicks"); + _screenArrangeCount = 100; + stage.removeEventListener(Event.RESIZE, arrangeScreen); + + _enteringFullscreen = true; + var delay:Timer = new Timer(1000, 1); + delay.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete); + delay.start(); + } + + private function onTimerComplete(event:TimerEvent):void { + log.debug("fullscreen wait delay complete, display clicks are enabled again"); + _enteringFullscreen = false; + } + + private function createFlashVarsConfig():void { + log.debug("createFlashVarsConfig()"); + if (! root.loaderInfo.parameters) { + return; + } + var configStr:String = Preloader(root).injectedConfig || root.loaderInfo.parameters["config"]; + var configObj:Object = configStr && configStr.indexOf("{") == 0 ? ConfigParser.parse(configStr) : {}; + + if (! configStr || (configStr && configStr.indexOf("{") == 0 && ! configObj.hasOwnProperty("url"))) { + _config = ConfigParser.parseConfig(configObj, BuiltInConfig.config, loaderInfo.url, VersionInfo.controlsVersion, VersionInfo.audioVersion); + callAndHandleError(initPhase1, PlayerError.INIT_FAILED); + + } else { + ConfigParser.loadConfig(configObj.hasOwnProperty("url") ? String(configObj["url"]) : configStr, BuiltInConfig.config, function(config:Config):void { + _config = config; + callAndHandleError(initPhase1, PlayerError.INIT_FAILED); + }, new ResourceLoaderImpl(null, this), loaderInfo.url, VersionInfo.controlsVersion, VersionInfo.audioVersion); + } + } + + private function createPlayListController():PlayListController { + createHttpProviders(); + + var playListController:PlayListController = new PlayListController(_config.getPlaylist(), _providers, _config, createNewLoader()); + playListController.playerEventDispatcher = _flowplayer; + _flowplayer.playlistController = playListController; + return playListController; + } + + private function createHttpProviders():void { + if (! _providers) { + _providers = new Dictionary(); + } + _providers["http"] = createProvider("http"); + _providers["httpInstream"] = createProvider("httpInstream"); + } + + private function createProvider(name:String):Object { + log.debug("creating provider with name " + name); + var httpProvider:ProviderModel = _config.createHttpProvider(name); + _pluginRegistry.registerProvider(httpProvider); + return httpProvider.pluginObject; + } + + private function get hasHttpChildClip():Boolean { + var children:Array = _config.getPlaylist().childClips; +// log.debug("configuration has child clips", children); + for (var i:int = 0; i < children.length; i++) { + if (Clip(children[i]).provider == "httpInstream") { + log.info("child clip with http provider found"); + return true; + } + } + return false; + } + + private function createScreen():void { + _screen = new Screen(_config.getPlaylist(), _animationEngine, _playButtonOverlay, _pluginRegistry); + var screenModel:DisplayProperties = _config.getScreenProperties(); + initView(_screen, screenModel, null, false); + if (_playButtonOverlay) { + PlayButtonOverlayView(_playButtonOverlay.getDisplayObject()).setScreen(_screen, hasClip && _config.useBufferingAnimation); + } +// addViewLiteners(_screen); + } + + private function createPlayButtonOverlay():void { + _playButtonOverlay = _config.getPlayButtonOverlay(); + if (! _playButtonOverlay) return; + + _playButtonOverlay.onLoad(onPluginLoad); + _playButtonOverlay.onError(onPluginLoadError); + + var overlay:PlayButtonOverlayView = new PlayButtonOverlayView(! playButtonOverlayWidthDefined(), _playButtonOverlay, _pluginRegistry); + initView(overlay, _playButtonOverlay, null, false); + } + + private function playButtonOverlayWidthDefined():Boolean { + if (! _config.getObject("play")) return false; + return _config.getObject("play").hasOwnProperty("width"); + } + + private function get hasClip():Boolean { + var firstClip:Clip = _config.getPlaylist().current; + var hasClip:Boolean = ! firstClip.isNullClip && (firstClip.url || firstClip.provider != 'http'); + return hasClip; + } + + private function createLogo():void { + var logoView:LogoView = new LogoView(_panel, _flowplayer); + var logo:Logo = _config.getLogo(logoView) || new Logo(logoView, "logo"); + // do not show it initially + logo.visible = false; + logoView.model = logo; + initView(logoView, logo, logoView.draw, false); + } + + private function initView(view:DisplayObject, props:DisplayProperties, resizeListener:Function = null, addToPanel:Boolean = true):void { + if (props.name != "logo" || VersionInfo.commercial) { + _pluginRegistry.registerDisplayPlugin(props, view); + } + if (addToPanel) { + _panel.addView(view, resizeListener, props); + } + if (props is Callable) { + ExternalInterfaceHelper.initializeInterface(props as Callable, view); + } + } + + private function addListeners():void { + _clickTimer.addEventListener(TimerEvent.TIMER, onClickTimer); + + doubleClickEnabled = true; + addEventListener(MouseEvent.DOUBLE_CLICK, onDoubleClick); + + _screen.addEventListener(MouseEvent.CLICK, onClickEvent); + if (_playButtonOverlay) { + _playButtonOverlay.getDisplayObject().addEventListener(MouseEvent.CLICK, onClickEvent); + } + addEventListener(MouseEvent.ROLL_OVER, onMouseOver); + addEventListener(MouseEvent.ROLL_OUT, onMouseOut); + + // add some color so that the ROLL_OVER/ROLL_OUT events are always triggered + graphics.beginFill(0, 0); + graphics.drawRect(0, 0, Arrange.parentWidth, Arrange.parentHeight); + graphics.endFill(); + } + + private function onMouseOut(event:MouseEvent):void { + _flowplayer.dispatchEvent(PlayerEvent.mouseOut()); + } + + private function onMouseOver(event:MouseEvent):void { + _flowplayer.dispatchEvent(PlayerEvent.mouseOver()); + } + + private function createPanel():void { + _panel = new Panel(); + addChild(_panel); + } + + private function startStreams():void { + var canStart:Boolean = true; + if (_flowplayer.state != State.WAITING) { + log.debug("streams have been started in player.onLoad(), will not start streams here."); + canStart = false; + } + if (! hasClip) { + log.info("Configuration has no clips to play."); + canStart = false; + } + + var playButton:PlayButtonOverlayView = _playButtonOverlay ? PlayButtonOverlayView(_playButtonOverlay.getDisplayObject()) : null; + + if (canStart) { + if (_flowplayer.currentClip.autoPlay) { + log.debug("clip is autoPlay"); + _flowplayer.play(); + } else if (_flowplayer.currentClip.autoBuffering) { + log.debug("clip is autoBuffering"); + _flowplayer.startBuffering(); + } else { + if (playButton) { + playButton.stopBuffering(); + playButton.showButton(); + } + } + } else { + // cannot start playing here, stop buffering indicator, don't show the button + if (playButton) { + playButton.stopBuffering(); + } + } + } + + private function addPlayListListeners():void { + var playlist:Playlist = _config.getPlaylist(); + playlist.onError(onClipError); + playlist.onBegin(onBegin); + } + + private function onBegin(event:ClipEvent):void { + this.buttonMode = Boolean(Clip(event.target).linkUrl); + } + + private function onClipError(event:ClipEvent):void { + if (event.isDefaultPrevented()) return; + doHandleError(event.error.code + ", " + event.error.message + ", " + event.info2 + ", clip: '" + Clip(event.target) + "'"); + } + + private function onClickTimer(event:TimerEvent):void { + if (_clickCount == 1) { + onSingleClick(_clickEvent); + } + _clickCount = 0; + } + + private function onDoubleClick(event:MouseEvent = null):void { + log.debug("onDoubleClick"); + _flowplayer.toggleFullscreen(); + } + + private function onSingleClick(event:MouseEvent):void { + if (isParent(DisplayObject(event.target), _screen)) { + log.debug("screen clicked"); + _flowplayer.toggle(); + } + } + + private function onClickEvent(event:MouseEvent):void { + if (_enteringFullscreen) return; + log.debug("onViewClicked, target " + event.target + ", current target " + event.currentTarget); + event.stopPropagation(); + + if (_playButtonOverlay && isParent(DisplayObject(event.target), _playButtonOverlay.getDisplayObject())) { + _flowplayer.toggle(); + return; + } else { + // if using linkUrl, no doubleclick to fullscreen + var clip:Clip = _flowplayer.playlist.current; + if (clip.linkUrl) { + log.debug("opening linked page " + clip.linkUrl); + _flowplayer.pause(); + URLUtil.openPage(clip.linkUrl, clip.linkWindow); + return; + } + } + if (++_clickCount == 2) { + onDoubleClick(event); + } else { + _clickEvent = event; + _clickTimer.start(); + } + } + + private function isParent(child:DisplayObject, parent:DisplayObject):Boolean { + try { + if (DisplayObject(child).parent == parent) return true; + if (! (parent is DisplayObjectContainer)) return false; + for (var i:Number = 0;i < DisplayObjectContainer(parent).numChildren; i++) { + var curChild:DisplayObject = DisplayObjectContainer(parent).getChildAt(i); + if (isParent(child, curChild)) { + return true; + } + } + } catch (e:SecurityError) { + return true; + } + return false; + } + + override protected function onRedraw():void { + if (bgImageHolder && getChildIndex(bgImageHolder) > getChildIndex(_panel)) { + swapChildren(bgImageHolder, _panel); + } + } + + private function createLogoForCanvas():void { + if (_canvasLogo) return; + _copyrightNotice = LogoUtil.createCopyrightNotice(8); + addChild(_copyrightNotice); + + _canvasLogo = new CanvasLogo(); + _canvasLogo.width = 85; + _canvasLogo.scaleY = _canvasLogo.scaleX; + _canvasLogo.alpha = .4; + _canvasLogo.addEventListener(MouseEvent.CLICK, + function(event:MouseEvent):void { navigateToURL(new URLRequest("http://flowplayer.org"), "_self"); }); + _canvasLogo.buttonMode = true; + log.debug("adding logo to display list"); + addChild(_canvasLogo); + onStageResize(); + } + + private function createNewLoader():ResourceLoader { + return new ResourceLoaderImpl(_config.playerId ? null : URLUtil.playerBaseUrl, this); + } + + private function initCustomClipEvents():void { + createCustomClipEvents(_config.connectionCallbacks); + createCustomClipEvents(_config.streamCallbacks); + } + + private function createCustomClipEvents(callbacks:Array):void { + if (! callbacks) return; + for (var i:int = 0; i < callbacks.length; i++) { + log.debug("creating custom event type " + callbacks[i]); + new ClipEventType(callbacks[i], true); + } + } + + private function callAndHandleError(func:Function, error:PlayerError):void { + try { + + func(); + } catch (e:Error) { + handleError(error, e, false); + throw e; + } + } + + internal function get enteringFullscreen():Boolean { + return _enteringFullscreen; + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/LogoUtil.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/LogoUtil.as new file mode 100644 index 0000000000000000000000000000000000000000..b958481110b0b0979c0cccf5689f3a8f244ac8e8 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/LogoUtil.as @@ -0,0 +1,38 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import org.flowplayer.util.TextUtil; + + import flash.text.TextField; + + /** + * @author api + */ + internal class LogoUtil { + + public static function createCopyrightNotice(fontSize:int):TextField { + var copyrightNotice:TextField = TextUtil.createTextField(false, null, fontSize, false); + copyrightNotice.text = "© 2008-2011 Flowplayer Ltd"; + copyrightNotice.textColor = 0x888888; + copyrightNotice.height = 15; + return copyrightNotice; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/MediaDisplay.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/MediaDisplay.as new file mode 100644 index 0000000000000000000000000000000000000000..91ae19c804ea470a4d09707e19f59812d79c6845 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/MediaDisplay.as @@ -0,0 +1,30 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import org.flowplayer.model.Clip; + + /** + * @author api + */ + internal interface MediaDisplay { + function init(clip:Clip):void; + function hasContent():Boolean; + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/MediaDisplayFactory.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/MediaDisplayFactory.as new file mode 100644 index 0000000000000000000000000000000000000000..54a24bd128b3ea87844271d425fd17107b409daa --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/MediaDisplayFactory.as @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import flash.display.DisplayObject; + + import org.flowplayer.flow_internal; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipType; + import org.flowplayer.model.Playlist; + + + + + + + + + + use namespace flow_internal; + + /** + * @author api + */ + internal class MediaDisplayFactory { + + private var playList:Playlist; + + public function MediaDisplayFactory(playList:Playlist) { + this.playList = playList; + } + + public function createMediaDisplay(clip:Clip):DisplayObject { + var display:DisplayObject; + if (clip.type == ClipType.VIDEO) + display = new VideoDisplay(clip); + //if we have a video api clip type display the video api display which collects the loader of the swf as a displayobject + if (clip.type == ClipType.API) + display = new VideoApiDisplay(clip); + if (clip.type == ClipType.IMAGE || clip.type == ClipType.AUDIO) + display = new ImageDisplay(clip); + return display; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/MediaResizer.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/MediaResizer.as new file mode 100644 index 0000000000000000000000000000000000000000..d3e48d1fa20d4278afab3eedd18a8828d17245e2 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/MediaResizer.as @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import org.flowplayer.model.Clip; + import org.flowplayer.model.MediaSize; + import org.flowplayer.util.Log; + + /** + * @author api + */ + internal class MediaResizer { + + private var log:Log = new Log(this); + private var _clip:Clip; + private var _maxWidth:int; + private var _maxHeight:int; + private var _currentSizingOption:MediaSize; + + public function MediaResizer(clip:Clip, maxWidth:int, maxHeight:int) { + this._clip = clip; + this._maxWidth = maxWidth; + this._maxHeight = maxHeight; + _currentSizingOption = MediaSize.FITTED_PRESERVING_ASPECT_RATIO; + } + + public function setMaxSize(width:int, height:int):void { + this._maxWidth = width; + this._maxHeight = height; + } + + public function resizeTo(sizingOption:MediaSize, force:Boolean = false):Boolean { + log.debug("resizeTo() " + sizingOption); + if (sizingOption == null) + sizingOption = _currentSizingOption; + + var resized:Boolean = false; + if (sizingOption == MediaSize.FITTED_PRESERVING_ASPECT_RATIO) { + resized = resizeToFit(); + } else if (sizingOption == MediaSize.HALF_FROM_ORIGINAL) { + resized = resizeToHalfAvailableSize(); + } else if (sizingOption == MediaSize.ORIGINAL) { + resized = resizeToOrig(force); + } else if (sizingOption == MediaSize.FILLED_TO_AVAILABLE_SPACE) { + resized = resizeToMax(); + } else if (sizingOption == MediaSize.CROP_TO_AVAILABLE_SPACE) { + resized = resizeToFit(true); + } + _currentSizingOption = sizingOption; + return resized; + } + + private function resizeToFit(allowCrop:Boolean = false):Boolean { + if (origWidth == 0 || origHeight == 0) { + log.warn("resizeToFit: original sizes not available, will not resize"); + return false; + } + log.debug("resize to fit, original size " + _clip.originalWidth + "x" + _clip.originalHeight + ", will crop? " + allowCrop); + + var xRatio:Number = _maxWidth / origWidth; + var useXRatio:Boolean = allowCrop ? xRatio * origHeight > _maxHeight : xRatio * origHeight <= _maxHeight; + + log.debug("using " + (useXRatio ? "x-ratio" : "y-ratio")); + if (useXRatio) { + resize(_maxWidth, calculateFittedDimension(_maxHeight, origHeight, xRatio)); + } else { + var yRatio:Number = _maxHeight / origHeight; + resize(calculateFittedDimension(_maxWidth, origWidth, yRatio), _maxHeight); + } + return true; + } + + private function calculateFittedDimension(maxLength:int, origLength:int, scalingFactor:Number):int { + var result:int = Math.ceil(scalingFactor * origLength); + return result > maxLength ? maxLength : result; + } + + public function scale(scalingFactor:Number):void { + resize(scalingFactor * origWidth, scalingFactor * origHeight); + } + + private function resizeToOrig(force:Boolean = false):Boolean { + if (force) { + resize(origWidth, origHeight); + return true; + } + if (origHeight > _maxHeight || origWidth > _maxWidth) { + log.warn("original size bigger that mas size! resizeToOrig() falls to resizeToFit()"); + return resizeToFit(); + } else if (origWidth && origHeight) { + log.debug("resize to original size"); + resize(origWidth, origHeight); + return true; + } else { + log.warn("resizeToOrig() cannot resize to original size because original size is not available"); + return false; + } + } + + private function resizeToHalfAvailableSize():Boolean { + log.debug("resize to half"); + scale((_maxWidth / 2) / origWidth); + return true; + } + + private function resizeToMax():Boolean { + log.debug("resizing to max size (filling available space)"); + resize(_maxWidth, _maxHeight); + return true; + } + + private function resize(newWidth:int, newHeight:int):void { + log.debug("resizing to " + newWidth + "x" + newHeight); + _clip.width = newWidth; + _clip.height = newHeight; + log.debug("resized to " + _clip.width + "x" + _clip.height); + } + + public function get currentSize():MediaSize { + return _currentSizingOption; + } + + public function hasOrigSize():Boolean { + return origHeight > 0 && origWidth > 0; + } + + public function toString():String { + return "[MediaResizer] origWidth: " + origWidth + ", origHeight: " + origHeight + ", maxWidth: " + _maxWidth + ", maxHeight: " + _maxHeight; + } + + public function get origWidth():int { + return _clip.originalWidth; + } + + public function get origHeight():int { + return _clip.originalHeight; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Panel.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Panel.as new file mode 100644 index 0000000000000000000000000000000000000000..56f49ee77c7234eb1bd78b0e3dd3e78891d77634 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Panel.as @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import org.flowplayer.model.DisplayPropertiesImpl; + + import flash.display.DisplayObject; + import flash.display.Sprite; + import flash.events.Event; + import flash.geom.Rectangle; + import flash.utils.Dictionary; + + import org.flowplayer.layout.DrawWrapper; + import org.flowplayer.layout.Layout; + import org.flowplayer.layout.MarginLayout; + import org.flowplayer.model.DisplayProperties; + import org.flowplayer.util.Log; + + /** + * @author anssi + */ + internal class Panel extends Sprite { + + private var log:Log = new Log(this); + private var layout:Layout; +// private var displayProperties:Dictionary = new Dictionary(); + + public function Panel() { + addEventListener(Event.ADDED_TO_STAGE, createLayout); + } + + public function addView(view:DisplayObject, resizeListener:Object = null, properties:DisplayProperties = null):void { + if (!properties) { + properties = new DisplayPropertiesImpl(); + properties.left = 0; + properties.top = 0; + properties.width = view.width || "50%"; + properties.height = view.height || "50%"; + } else { + if (! properties.dimensions.height.hasValue()) { + properties.height = view.height; + } + if (! properties.dimensions.width.hasValue()) { + properties.width = view.width; + } + if (! (properties.position.left.hasValue() || properties.position.right.hasValue())) { + properties.left = "50%"; + } + if (! (properties.position.top.hasValue() || properties.position.bottom.hasValue())) { + properties.top = "50%"; + } + } + if (properties.zIndex < 0) { + properties.zIndex = 1; + } + var listener:Function; + if (resizeListener) + listener = resizeListener is Function ? resizeListener as Function : view[resizeListener]; + else + listener = new DrawWrapper(view).draw; + view.alpha = properties.alpha; + + properties.setDisplayObject(view); + addChildView(properties); + + layout.addView(view, listener, properties); + } + + override public function addChild(child:DisplayObject):DisplayObject { + log.debug("addChild " + child); + if (child is Preloader) { + log.warn("adding Preloader to panel??"); + } + return super.addChild(child); + } + + override public function swapChildren(child1:DisplayObject, child2:DisplayObject):void { + log.warn("swapChildren on Panel called, overridden here and does nothing"); + } + + private function addChildView(properties:DisplayProperties):void { + log.info("updating Z index of " + properties + ", target Z index is " + properties.zIndex + ", numChildreb " + numChildren); + + for (var i:int = 0; i < numChildren; i++) { + log.debug(getChildAt(i) + " at " + i); + } + + if (properties.zIndex < numChildren) { + log.debug("adding child at " + properties.zIndex); + var currentChild:DisplayObject = getChildAt(properties.zIndex); + addChildAt(properties.getDisplayObject(), properties.zIndex); + } else { + addChild(properties.getDisplayObject()); + } + properties.zIndex = getChildIndex(properties.getDisplayObject()); + log.debug("Z index updated to " + properties.zIndex); + + log.debug("child indexes are now: "); + + for (var j:int = 0; j < numChildren; j++) { + log.debug(getChildAt(j) + " at " + j); + } + } + + public function getZIndex(view:DisplayObject):int { + try { + return getChildIndex(view); + } catch (e:Error) { + // view not added in this panel + } + return -1; + } + + public function update(view:DisplayObject, properties:DisplayProperties):Rectangle { + log.debug("updating zIndex to " + properties.zIndex); + if (properties.zIndex >= 0) { + setChildIndex(view, properties.zIndex < numChildren ? properties.zIndex : numChildren - 1); + } + return layout.update(view, properties); + } + + private function removeView(view:DisplayObject):void { + log.debug("removeView " + view); + if (! getChildByName(view.name)) { + return; + } + super.removeChild(view); + layout.removeView(view); + } + + public override function removeChild(child:DisplayObject):DisplayObject { + removeView(child); + return child; + } + + private function createLayout(event:Event):void { + layout = new MarginLayout(stage); + } + + /** + * Redraw the panel. + * @param disp if specified only this display object is redrawn + */ + public function draw(disp:DisplayObject = null):void { + layout.draw(disp); + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/PlayerEventDispatcher.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/PlayerEventDispatcher.as new file mode 100644 index 0000000000000000000000000000000000000000..331ad203a78cc910027150e8746c6d9a262fcbf9 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/PlayerEventDispatcher.as @@ -0,0 +1,145 @@ +package org.flowplayer.view { + import org.flowplayer.flow_internal; + import org.flowplayer.model.ErrorCode; + import org.flowplayer.model.EventDispatcher; + import org.flowplayer.model.PlayerError; + import org.flowplayer.model.PlayerEvent; + import org.flowplayer.model.PlayerEventType; + + import flash.utils.Dictionary; + + use namespace flow_internal; + + /** + * @author anssi + */ + public class PlayerEventDispatcher extends EventDispatcher { + + /** + * Dispatches a player event of the specified type. + */ + public function dispatch(eventType:PlayerEventType, info:Object = null, dispatchExternal:Boolean = true):void { + doDispatchEvent(new PlayerEvent(eventType, info), dispatchExternal); + } + + /** + * Dispatches a player event. + */ + public function dispatchEvent(event:PlayerEvent):void { + doDispatchEvent(event, true); + } + + public function dispatchError(error:ErrorCode, info:Object = null):void { + doDispatchErrorEvent(new PlayerEvent(error.eventType, error, info), true); + } + + /** + * Dispatches the specified event to the before phase listeners. + */ + public function dispatchBeforeEvent(event:PlayerEvent):Boolean { + return doDispatchBeforeEvent(event, true); + } + + /** + * Adds a onLoad event listener. The event is triggered when the player has been loaded and initialized. + * @param listener + * @param add if true the listener is addes, otherwise removed + * @see PlayerEventType + */ + public function onLoad(listener:Function):void { + setListener(PlayerEventType.LOAD, listener); + } + + /** + * Adds a onUnload event listener. The event is triggered when the player is closed. Note that this event + * will be only triggered when the player is embedded using the flowplayer.js script. + * @param listener + * @param add if true the listener is addes, otherwise removed + * @see PlayerEventType + */ + public function onUnload(listener:Function):void { + setListener(PlayerEventType.UNLOAD, listener); + } + + /** + * Add a fullscreen-enter event listener for the "before phase" of this event. + */ + public function onBeforeFullscreen(listener:Function):void { + setListener(PlayerEventType.FULLSCREEN, listener, null, true); + } + + /** + * Adds a fullscreen-enter event listener. The event is fired when the player goes to + * the fullscreen mode. + * @param listener + * @see PlayerEventType + */ + public function onFullscreen(listener:Function):void { + log.debug("adding listener for fullscreen " + PlayerEventType.FULLSCREEN); + setListener(PlayerEventType.FULLSCREEN, listener); + } + + /** + * Adds a fullscreen-exit event listener. The event is fired when the player exits from + * the fullscreen mode. + * @param listener + * @see PlayerEventType + */ + public function onFullscreenExit(listener:Function):void { + setListener(PlayerEventType.FULLSCREEN_EXIT, listener); + } + + /** + * Adds a volume mute event listener. The event is fired when the volume is muted + * @param listener + * @see PlayerEventType + */ + public function onMute(listener:Function):void { + setListener(PlayerEventType.MUTE, listener); + } + + /** + * Adds a volume un-mute event listener. The event is fired when the volume is unmuted + * @param listener + * @see PlayerEventType + */ + public function onUnmute(listener:Function):void { + setListener(PlayerEventType.UNMUTE, listener); + } + + /** + * Adds a volume event listener. The event is fired when the volume level is changed. + * @param listener + * @see PlayerEventType + */ + public function onVolume(listener:Function):void { + setListener(PlayerEventType.VOLUME, listener); + } + + /** + * Adds a mouse over listener. + * @param listener + * @return + */ + public function onMouseOver(listener:Function):void { + setListener(PlayerEventType.MOUSE_OVER, listener); + } + + /** + * Adds a mouse over listener. + * @param listener + * @return + */ + public function onMouseOut(listener:Function):void { + setListener(PlayerEventType.MOUSE_OUT, listener); + } + + override protected function get cancellableEvents():Dictionary { + return PlayerEventType.cancellable; + } + + override protected function get allEvents():Dictionary { + return PlayerEventType.all; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/PluginLoader.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/PluginLoader.as new file mode 100644 index 0000000000000000000000000000000000000000..2b8bfb013f401d906ef7b2990f760ea984d446a3 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/PluginLoader.as @@ -0,0 +1,349 @@ +/* + * Copyright 2008 Flowplayer Oy + * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import flash.display.AVM1Movie; +import flash.system.Security; + + import org.flowplayer.model.ErrorCode; + import org.flowplayer.model.Plugin; + import org.flowplayer.controller.NetStreamControllingStreamProvider; + + import com.adobe.utils.StringUtil; + + import org.flowplayer.config.ExternalInterfaceHelper; + import org.flowplayer.controller.StreamProvider; + import org.flowplayer.model.Callable; + import org.flowplayer.model.DisplayPluginModel; + import org.flowplayer.model.FontProvider; + import org.flowplayer.model.Loadable; + import org.flowplayer.model.PlayerError; + import org.flowplayer.model.PluginError; + import org.flowplayer.model.PluginEvent; + import org.flowplayer.model.PluginModel; + import org.flowplayer.model.ProviderModel; + import org.flowplayer.util.Log; + import org.flowplayer.util.URLUtil; + + import flash.display.DisplayObject; + import flash.display.Loader; + import flash.display.LoaderInfo; + import flash.events.Event; + import flash.events.EventDispatcher; + import flash.events.IOErrorEvent; + import flash.events.ProgressEvent; + import flash.net.URLRequest; + import flash.system.ApplicationDomain; + import flash.system.LoaderContext; + import flash.system.SecurityDomain; + import flash.utils.Dictionary; + import flash.utils.getDefinitionByName; + import flash.utils.getQualifiedClassName; + + + /** + * @author api + */ + public class PluginLoader extends EventDispatcher { + + private var log:Log = new Log(this); + private var _loadables:Array; + private var _loadedPlugins:Dictionary; + private var _loadedCount:int; + private var _errorHandler:ErrorHandler; + private var _swiffsToLoad:Array; + private var _pluginRegistry:PluginRegistry; + private var _providers:Dictionary; + private var _callback:Function; + private var _baseUrl:String; + private var _useExternalInterface:Boolean; + private var _loadErrorListener:Function; + private var _loadListener:Function; + private var _loadComplete:Boolean; + private var _allPlugins:Array; + private var _loaderContext:LoaderContext; + private var _loadStartedCount:int = 0; + + public function PluginLoader(baseUrl:String, pluginRegistry:PluginRegistry, errorHandler:ErrorHandler, useExternalInterface:Boolean) { + _baseUrl = baseUrl; + _pluginRegistry = pluginRegistry; + _errorHandler = errorHandler; + _useExternalInterface = useExternalInterface; + _loadedCount = 0; + } + + private function constructUrl(url:String):String { + if (url.indexOf("..") >= 0) return url; + if (url.indexOf("/") >= 0) return url; + return URLUtil.addBaseURL(_baseUrl, url); + } + + public function loadPlugin(model:Loadable, callback:Function = null):void { + _callback = callback; + _loadListener = null; + _loadErrorListener = null; + load([model]); + } + + public function load(plugins:Array, loadListener:Function = null, loadErrorListener:Function = null):void { + log.debug("load()"); + _loadListener = loadListener; + _loadErrorListener = loadErrorListener; + + Security.allowDomain("*"); + + _providers = new Dictionary(); + _allPlugins = plugins.concat([]); + _loadables = plugins.filter(function(plugin:*, index:int, array:Array):Boolean { + return plugin.url && String(plugin.url).toLocaleLowerCase().indexOf(".swf") > 0; + }); + _swiffsToLoad = getPluginSwiffUrls(plugins); + + _loadedPlugins = new Dictionary(); + _loadedCount = 0; + _loadStartedCount = 0; + + _loaderContext = new LoaderContext(); + _loaderContext.applicationDomain = ApplicationDomain.currentDomain; + if (!URLUtil.localDomain(_baseUrl)) { + _loaderContext.securityDomain = SecurityDomain.currentDomain; + } + + for (var i:Number = 0; i < _loadables.length; i++) { + Loadable(_loadables[i]).onError(_loadErrorListener); + } + + intitializeBuiltInPlugins(plugins); + if (_swiffsToLoad.length == 0) { + setConfigPlugins(); + dispatchEvent(new Event(Event.COMPLETE, true, false)); + return; + } + + loadNext(); + } + + private function loadNext():Boolean { + if (_loadStartedCount >= _swiffsToLoad.length) { + log.debug("loadNext(): all plugins loaded"); + return false; + } + + var loader:Loader = new Loader(); + loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded); + var url:String = _swiffsToLoad[_loadStartedCount]; + + loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, createIOErrorListener(url)); + loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress); + log.debug("starting to load plugin from url " + _swiffsToLoad[_loadStartedCount]); + loader.load(new URLRequest(url), _loaderContext); + _loadStartedCount++; + return true; + } + + private function getPluginSwiffUrls(plugins:Array):Array { + var result:Array = new Array(); + for (var i:Number = 0; i < plugins.length; i++) { + var loadable:Loadable = Loadable(plugins[i]); + if (! loadable.isBuiltIn && loadable.url && result.indexOf(loadable.url) < 0) { + result.push(constructUrl(loadable.url)); + } + } + return result; + } + + private function intitializeBuiltInPlugins(plugins:Array):void { + for (var i:int = 0; i < plugins.length; i++) { + var loadable:Loadable = plugins[i] as Loadable; + log.debug("intitializeBuiltInPlugins() " + loadable); + if (loadable.isBuiltIn) { + log.info("intitializeBuiltInPlugins(), instantiating from loadable " + loadable + ", with config ", loadable.config); + var instance:Object = loadable.instantiate(); + var model:PluginModel = createPluginModel(loadable, instance); + model.isBuiltIn = true; +// if (instance.hasOwnProperty("onConfig")) { +// instance.onConfig(model); +// } + initializePlugin(model, instance); + } + } + } + + private function createIOErrorListener(url:String):Function { + return function(event:IOErrorEvent):void { + log.error("onIoError " + url); + _loadables.forEach(function(loadable:Loadable, index:int, array:Array):void { + if (! loadable.loadFailed && hasSwiff(url, loadable.url)) { + log.debug("onIoError: this is the swf for loadable " + loadable); + loadable.loadFailed = true; + loadable.dispatchError(PluginError.INIT_FAILED); + incrementLoadedCountAndFireEventIfNeeded(); + } + }); + }; + } + + private function onProgress(event:ProgressEvent):void { + log.debug("load in progress"); + } + + + public function get plugins():Dictionary { + return _loadedPlugins; + } + + private function loaded(event:Event):void { + var info:LoaderInfo = event.target as LoaderInfo; + log.debug("loaded class name " + getQualifiedClassName(info.content)); + + var instanceUsed:Boolean = false; + _loadables.forEach(function(loadable:Loadable, index:int, array:Array):void { + if (! loadable.plugin && hasSwiff(info.url, loadable.url)) { + log.debug("this is the swf for loadable " + loadable); + if (loadable.type == "classLibrary") { + initializeClassLibrary(loadable, info); + } else { + var plugin:Object = info.content is AVM1Movie ? info.loader : createPluginInstance(instanceUsed, info.content); + initializePlugin(createPluginModel(loadable, plugin), plugin); + //initializePlugin(loadable, instanceUsed, info); + instanceUsed = true; + } + } + }); + incrementLoadedCountAndFireEventIfNeeded(); + if (_callback != null) { + _callback(); + } + loadNext(); + } + + private function incrementLoadedCountAndFireEventIfNeeded():void { + if (++_loadedCount == _swiffsToLoad.length) { + log.debug("all plugin SWFs loaded. loaded total " + loadedCount + " plugins"); + setConfigPlugins(); + dispatchEvent(new Event(Event.COMPLETE, true, false)); + } + } + + private function initializeClassLibrary(loadable:Loadable, info:LoaderInfo):void { + log.debug("initializing class library " + info.applicationDomain); + _loadedPlugins[loadable] = info.applicationDomain; + _pluginRegistry.registerGenericPlugin(loadable.createPlugin(info.applicationDomain)); + } + + private function createPluginModel(loadable:Loadable, pluginInstance:Object):PluginModel { + log.debug("creating model for loadable " + loadable + ", instance " + pluginInstance); + + _loadedPlugins[loadable] = pluginInstance; + + log.debug("pluginInstance " + pluginInstance); + if (pluginInstance is DisplayObject) { + return Loadable(loadable).createDisplayPlugin(pluginInstance as DisplayObject); + + } else if (pluginInstance is StreamProvider) { + return Loadable(loadable).createProvider(pluginInstance); + } else { + return Loadable(loadable).createPlugin(pluginInstance); + } + } + + private function initializePlugin(model:PluginModel, pluginInstance:Object):void { + if (pluginInstance is FontProvider) { + _pluginRegistry.registerFont(FontProvider(pluginInstance).fontFamily); + + } else if (pluginInstance is DisplayObject) { + _pluginRegistry.registerDisplayPlugin(model as DisplayPluginModel, pluginInstance as DisplayObject); + + } else if (pluginInstance is StreamProvider) { + _providers[model.name] = pluginInstance; + _pluginRegistry.registerProvider(model as ProviderModel); + } else { + _pluginRegistry.registerGenericPlugin(model); + } + if (pluginInstance is Plugin) { + if (_loadListener != null) { + model.onLoad(_loadListener); + } + model.onError(onPluginError); + } + if (model is Callable && _useExternalInterface) { + ExternalInterfaceHelper.initializeInterface(model as Callable, pluginInstance); + } + } + + private function onPluginError(event:PluginEvent):void { + log.debug("onPluginError() " + event.error); + if (event.error) { + _errorHandler.handleError(event.error, event.info + ", " + event.info2, true); + } + } + + private function createPluginInstance(instanceUsed:Boolean, instance:DisplayObject):Object { + if (instance.hasOwnProperty("newPlugin")) return instance["newPlugin"](); + + if (! instanceUsed) { + log.debug("using existing instance " + instance); + return instance; + } + var className:String = getQualifiedClassName(instance); + log.info("creating new " + className); + var PluginClass:Class = Class(getDefinitionByName(className)); + return new PluginClass() as DisplayObject; + } + + public function setConfigPlugins():void { + _allPlugins.forEach(function(loadable:Loadable, index:int, array:Array):void { + if (! loadable.loadFailed) { + var pluginInstance:Object = plugins[loadable]; + // we don't have a plugin instance for all of these (dock for example) + if (pluginInstance) { + log.info(index + ": setting config to " + pluginInstance + ", " + loadable); + if (pluginInstance is NetStreamControllingStreamProvider) { + log.debug("NetStreamControllingStreamProvider(pluginInstance).config = " +loadable.plugin); + NetStreamControllingStreamProvider(pluginInstance).model = ProviderModel(loadable.plugin); + } else { + if (pluginInstance.hasOwnProperty("onConfig")) { + pluginInstance.onConfig(loadable.plugin); + } + } + } + } + }); + } + + private function hasSwiff(infoUrl:String, modelUrl:String):Boolean { + if (! modelUrl) return false; + var slashPos:int = modelUrl.lastIndexOf("/"); + var swiffUrl:String = slashPos >= 0 ? modelUrl.substr(slashPos) : modelUrl; + return StringUtil.endsWith(infoUrl, swiffUrl); + } + + public function get providers():Dictionary { + return _providers; + } + + public function get loadedCount():int { + return _loadedCount; + } + + public function get loadComplete():Boolean { + return _loadComplete; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/PluginRegistry.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/PluginRegistry.as new file mode 100644 index 0000000000000000000000000000000000000000..8f69b2e118fc2f159a7b4a2aa925a21956a8233e --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/PluginRegistry.as @@ -0,0 +1,255 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import org.flowplayer.controller.ClipURLResolver; + import org.flowplayer.controller.ConnectionProvider; + import org.flowplayer.controller.StreamProvider; + import org.flowplayer.controller.NetStreamControllingStreamProvider; + import org.flowplayer.model.DisplayPluginModel; + import org.flowplayer.model.Cloneable; + import org.flowplayer.model.DisplayProperties; + import org.flowplayer.model.Plugin; + import org.flowplayer.model.PluginModel; + import org.flowplayer.model.ProviderModel; + import org.flowplayer.util.Assert; + import org.flowplayer.util.Log; + import org.flowplayer.util.PropertyBinder; + + import flash.display.DisplayObject; + import flash.utils.Dictionary; + + /** + * @author api + */ + public class PluginRegistry { + + private var log:Log = new Log(this); + private var _plugins:Dictionary = new Dictionary(); + private var _originalProps:Dictionary = new Dictionary(); + private var _providers:Dictionary = new Dictionary(); + private var _genericPlugins:Dictionary = new Dictionary(); + private var _fonts:Array = new Array(); + private var _panel:Panel; + private var _flowPlayer:FlowplayerBase; + + public function PluginRegistry(panel:Panel) { + _panel = panel; + } + + /** + * Gets all plugins. + * @return the plugins keyed by the plugin name + */ + public function get plugins():Dictionary { + return _plugins; + } + + /** + * Gets all providers. + * @return the providers keyed by the plugin name + */ + public function get providers():Dictionary { + return _providers; + } + + /** + * Gets a plugin by it's name. + * @return the plugin mode, this is a clone of the current model and changes made + * to the returned object are not reflected to the copy stored in this registrty + */ + public function getPlugin(name:String):Object { + var plugin:Object = _plugins[name] || _providers[name] || _genericPlugins[name]; + log.debug("found plugin " + plugin); + if (plugin is DisplayProperties) { + updateZIndex(plugin as DisplayProperties); + } + return plugin; +// return clone(plugin); + } + + private function updateZIndex(props:DisplayProperties):void { + var zIndex:int = _panel.getZIndex(props.getDisplayObject()); + if (zIndex >= 0) { + props.zIndex = zIndex; + } + } + + private function clone(obj:Object):Object { + return obj && obj is Cloneable ? Cloneable(obj).clone() : obj; + } + + /** + * Gets plugin's model corresponding to the specified DisplayObject. + * @param disp the display object whose model is looked up + * @param return the display properties, or <code>null</code> if a plugin cannot be found + */ + public function getPluginByDisplay(disp:DisplayObject):DisplayProperties { + for each (var plugin:DisplayProperties in _plugins) { + if (plugin.getDisplayObject() == disp) { + updateZIndex(plugin); + return plugin; + } + } + return null; + } + + /** + * Gets all FontProvider plugins. + * @return an array of FontProvider instances configured or loaded into the player + * @see FontProvider + */ + public function get fonts():Array { + return _fonts; + } + + /** + * Gets the original display properties. The original values were the ones + * configured for the plugin or as the ones specified when the plugin was loaded. + * @param pluginName + * @return a clone of the original display properties, or <code>null</code> if there is no plugin + * corresponding to the specified name + */ + public function getOriginalProperties(pluginName:String):DisplayProperties { + return clone(_originalProps[pluginName]) as DisplayProperties; + } + + internal function registerFont(fontFamily:String):void { + _fonts.push(fontFamily); + } + + public function registerDisplayPlugin(plugin:DisplayProperties, view:DisplayObject):void { + log.debug("registerDisplayPlugin() " + plugin.name); + plugin.setDisplayObject(view); + _plugins[plugin.name] = plugin; + _originalProps[plugin.name] = plugin.clone(); + } + + internal function registerProvider(model:ProviderModel):void { + log.info("registering provider " + model); + _providers[model.name] = model; + } + + internal function registerGenericPlugin(model:PluginModel):void { + log.info("registering generic plugin " + model.name); + _genericPlugins[model.name] = model; + } + + internal function removePlugin(plugin:PluginModel):void { + if (! plugin) return; + delete _plugins[plugin.name]; + delete _originalProps[plugin.name]; + delete _providers[plugin.name]; + + if (plugin is DisplayPluginModel) { + _panel.removeChild(DisplayPluginModel(plugin).getDisplayObject()); + } + } + + public function updateDisplayProperties(props:DisplayProperties, updateOriginalProps:Boolean = false):void { + Assert.notNull(props.name, "displayProperties.name cannot be null"); + var view:DisplayObject = DisplayProperties(_plugins[props.name]).getDisplayObject(); + if (view) { + props.setDisplayObject(view); + } + _plugins[props.name] = props.clone(); + if (updateOriginalProps) { + _originalProps[props.name] = props.clone(); + } + } + + public function update(plugin:PluginModel):void { + _plugins[plugin.name] = plugin.clone(); + } + + internal function updateDisplayPropertiesForDisplay(view:DisplayObject, updated:Object):void { + var props:DisplayProperties = getPluginByDisplay(view); + if (props) { + new PropertyBinder(props).copyProperties(updated); + updateDisplayProperties(props); + } + } + + internal function onLoad(flowPlayer:FlowplayerBase):void { + log.debug("onLoad"); + _flowPlayer = flowPlayer; + setPlayerToPlugins(_providers); + setPlayerToPlugins(_plugins); + setPlayerToPlugins(_genericPlugins); + } + + private function setPlayerToPlugins(plugins:Dictionary):void { + // we need to create a copy because any change to the + // dictionary during the foreach makes it start again, + // which causes double onLoad calls + + var transientCopy:Dictionary = new Dictionary(); + for ( var name:String in plugins ) + transientCopy[name] = plugins[name]; + + for each (var model:Object in transientCopy) { + setPlayerToPlugin(model); + } + } + + internal function setPlayerToPlugin(plugin:Object):void { + var pluginObj:Object; + try { + log.debug("setPlayerToPlugin " + plugin); + if (plugin is DisplayProperties) { + pluginObj = DisplayProperties(plugin).getDisplayObject(); + } else if (plugin is PluginModel) { + pluginObj = PluginModel(plugin).pluginObject; + } + if (pluginObj is NetStreamControllingStreamProvider) { + log.debug("setting player to " + pluginObj); + NetStreamControllingStreamProvider(pluginObj).player = _flowPlayer as Flowplayer; + } else { + pluginObj["onLoad"](_flowPlayer); + } + log.debug("onLoad() successfully executed for plugin " + plugin); + } catch (e:Error) { + if (pluginObj is Plugin || pluginObj is StreamProvider) { + throw e; + } + log.warn("was not able to initialize player to plugin " + plugin + ": "+ e.message); + } + } + + internal function addPluginEventListener(listener:Function):void { + for each (var model:Object in _plugins) { + if (model is PluginModel) { + PluginModel(model).onPluginEvent(listener); + } + } + } + + public function getUrlResolvers():Array { + var result:Array = []; + for (var name:String in _genericPlugins) { + var model:PluginModel = _genericPlugins[name] as PluginModel; + var plugin:Object = model.pluginObject; + if (plugin is ClipURLResolver && ! (plugin is ConnectionProvider)) { + result.push(name); + } + } + result.sort(); + return result; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Preloader.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Preloader.as new file mode 100644 index 0000000000000000000000000000000000000000..02004b4d48dff6b0f81c027b9b63b6267bbdd6b6 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Preloader.as @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2008 - 2010 Flowplayer Oy + * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ +package org.flowplayer.view { + import flash.display.DisplayObject; + import flash.display.MovieClip; + import flash.display.StageAlign; + import flash.display.StageScaleMode; + import flash.events.Event; + import flash.events.ProgressEvent; + import flash.utils.getDefinitionByName; + import flash.utils.*; + import flash.display.StageDisplayState; + + import org.flowplayer.util.Arrange; + import org.flowplayer.util.Log; + import org.flowplayer.util.LogConfiguration; + + public class Preloader extends MovieClip { + private var _log:Log = new Log(this); + private var _app:DisplayObject; + // this variable can be set from external SWF files, if it's set well use it to construct the config + public var injectedConfig:String; + + public function Preloader() { + + var logConfig:LogConfiguration = new LogConfiguration(); + logConfig.level = "error"; + logConfig.filter = "org.flowplayer.view.Preloader"; + Log.configure(logConfig); + _log.debug("Preloader"); + + stop(); + addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); + } + + private function onStageResize(e:Event):void{ + setParentDimensions(); + } + + private function setParentDimensions():void{ + if(stage.displayState == StageDisplayState.FULL_SCREEN || (Arrange.set && !Arrange.hasParent)){ + Arrange.parentWidth=stage.stageWidth; + Arrange.parentHeight=stage.stageHeight; + return; + } + if(Arrange.set && Arrange.hasParent){ + Arrange.parentWidth = Arrange.localWidth; + Arrange.parentHeight = Arrange.localHeight; + return; + } + var p:Object = parent; + while(p){ + if(p.width !=0 && p.height !=0 && getQualifiedClassName(p) != 'mx.controls::SWFLoader'){ + Arrange.parentWidth =Arrange.localWidth = p.width; + Arrange.parentHeight = Arrange.localHeight = p.height; + Arrange.hasParent = true; + break; + } + p=p.parent; + } + if(Arrange.parentWidth == 0 && Arrange.parentHeight == 0){ + Arrange.parentWidth = stage.stageWidth; + Arrange.parentHeight = stage.stageHeight; + } + Arrange.set = true; + } + + private function onAddedToStage(event:Event):void { + log("onAddedToStage(): stage size is " + Arrange.parentWidth + " x " + Arrange.parentHeight); + log("onAddedToStage(), bytes loaded " + loaderInfo.bytesLoaded); + stage.addEventListener(Event.RESIZE, onStageResize, false, 1); + setParentDimensions(); + + addEventListener(Event.ENTER_FRAME, enterFrameHandler); + } + + private function enterFrameHandler(evt:Event):void { + log("enterFrameHandler() " + loaderInfo.bytesLoaded); + + if (loaderInfo.bytesLoaded == loaderInfo.bytesTotal) { + log("bytesLoaded == bytesTotal, stageWidth = " + Arrange.parentWidth + " , stageHeight = " + Arrange.parentHeight); + if (Arrange.parentWidth != 0 && Arrange.parentHeight != 0) { + initialize(); + removeEventListener(Event.ENTER_FRAME, enterFrameHandler); + } + } + } + + private function initialize():void { + log("initialize()"); + nextFrame(); + + if (_app) { + log("initialize(), _app already instantiated returning"); + return; + } + + prepareStage(); + try { + var mainClass:Class = getAppClass(); + _app = new mainClass() as DisplayObject; + addChild(_app as DisplayObject); + log("Launcher instantiated " + _app); + removeEventListener(Event.ENTER_FRAME, enterFrameHandler); + } catch (e:Error) { + log("error instantiating Launcher " + e + ": " + e.message); + _app = null; + } + } + + private function getAppClass():Class { + try { + return Class(getDefinitionByName("org.flowplayer.view.Launcher")); + } catch (e:Error) { + } + return null; + } + + private function prepareStage():void { + if (! stage) return; + stage.align = StageAlign.TOP_LEFT; + stage.scaleMode = StageScaleMode.NO_SCALE; + } + + private function log(msg:Object):void { + _log.debug(msg + ""); + trace(msg + ""); + } + + private function get rotationEnabled():Boolean { + var config:Object = stage.loaderInfo.parameters["config"]; + if (! config) return true; + if (config.replace(/\s/g, "").indexOf("buffering:null") > 0) return false; + return true; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/RotatingAnimation.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/RotatingAnimation.as new file mode 100644 index 0000000000000000000000000000000000000000..90bc5d968045169d3b63aa11ef02cfab9144c2ec --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/RotatingAnimation.as @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ +package org.flowplayer.view { + import flash.display.Sprite; + import flash.events.TimerEvent; +import flash.utils.Timer; + + public class RotatingAnimation extends AbstractSprite { + private var _rotationImage:BufferAnimation; + private var _rotation:Sprite; + private var _rotationTimer:Timer; + + public function RotatingAnimation() { + createRotation(); + _rotationTimer = new Timer(50); + _rotationTimer.addEventListener(TimerEvent.TIMER, rotate); + _rotationTimer.start(); + } + + public function start():void { + _rotationTimer.start(); + } + + public function stop():void { + _rotationTimer.stop(); + } + + protected override function onResize():void { + arrangeRotation(width, height); + } + + private function rotate(event:TimerEvent):void { + _rotation.rotation += 10; + } + + private function createRotation():void { + _rotationImage = new BufferAnimation(); + _rotation = new Sprite(); + _rotation.addChild(_rotationImage); + addChild(_rotation); + } + + private function arrangeRotation(width:Number, height:Number):void { + if (_rotationImage) { + _rotationImage.height = height; + _rotationImage.scaleX = _rotationImage.scaleY; + + _rotationImage.x = - _rotationImage.width / 2; + _rotationImage.y = - _rotationImage.height / 2; + _rotation.x = _rotationImage.width / 2 + (width - _rotationImage.width)/2; + _rotation.y = _rotationImage.height / 2 + (height - _rotationImage.height)/2; + } + } + } +} \ No newline at end of file diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Screen.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Screen.as new file mode 100644 index 0000000000000000000000000000000000000000..e29d5c60d6057f9a773f3931ba48f7d560299900 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Screen.as @@ -0,0 +1,401 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ +package org.flowplayer.view { + import flash.events.MouseEvent; + + import org.flowplayer.controller.MediaController; + import org.flowplayer.flow_internal; + import org.flowplayer.model.Clip; + import org.flowplayer.model.ClipEvent; + import org.flowplayer.model.ClipEventSupport; + import org.flowplayer.model.ClipType; + import org.flowplayer.model.ClipEventType; + import org.flowplayer.model.DisplayProperties; + import org.flowplayer.model.MediaSize; + import org.flowplayer.model.PlayButtonOverlay; + import org.flowplayer.model.Playlist; + import org.flowplayer.util.Arrange; + import org.flowplayer.util.Log; + import org.flowplayer.view.MediaDisplay; + + import flash.display.DisplayObject; + import flash.events.Event; + import flash.events.FullScreenEvent; + import flash.geom.Rectangle; + import flash.utils.Dictionary; + + use namespace flow_internal; + + internal class Screen extends AbstractSprite { + + private var _displayFactory:MediaDisplayFactory; + private var _displays:Dictionary; + private var _resizer:ClipResizer; + private var _playList:Playlist; + private var _prevClip:Clip; + private var _fullscreenManaer:FullscreenManager; + private var _animationEngine:AnimationEngine; + private var _pluginRegistry:PluginRegistry; + + public function Screen(playList:Playlist, animationEngine:AnimationEngine, play:PlayButtonOverlay, pluginRegistry:PluginRegistry) { + log.debug("in constructor"); + _displays = new Dictionary(); + _displayFactory = new MediaDisplayFactory(playList); + _resizer = new ClipResizer(playList, this); + createDisplays(playList.clips.concat(playList.childClips)); + addListeners(playList); + _playList = playList; + _animationEngine = animationEngine; + _pluginRegistry = pluginRegistry; + } + + override public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void { + addEventListenerToDisplays(_playList.clips.concat(_playList.childClips), type, listener); + } + + private function addEventListenerToDisplays(clips:Array, type:String, listener:Function):void { + for (var i:Number = 0; i < clips.length; i++) { + var clip:Clip = clips[i]; + if (! clip.isNullClip) { + var display:DisplayObject = _displays[clip]; + display.addEventListener(type, listener); + } + } + } + + private function createDisplays(clips:Array):void { + for (var i:Number = 0; i < clips.length; i++) { + var clip:Clip = clips[i]; + if (! clip.isNullClip) { + createDisplay(clip); + } + } + } + + private function createDisplay(clip:Clip):void { + var display:DisplayObject = _displayFactory.createMediaDisplay(clip); + display.width = this.width; + display.height = this.height; + display.visible = false; + addChild(display); + log.debug("created display " + display); + _displays[clip] = display; + } + + public function setVideoApiOverlaySize(width:Number, height:Number):void { + var display:Object = _displays[_playList.current]; + display.overlay.width = width; + display.overlay.height = height; + } + + public function set fullscreenManager(manager:FullscreenManager):void { + _fullscreenManaer = manager; + } + + protected override function onResize():void { + log.debug("onResize " + Arrange.describeBounds(this)); + _resizer.setMaxSize(width, height); + // we need to resize the previous clip because it might be the stopped image that we are currently showing + resizeClip(_playList.previousClip); + resizeClip(_playList.current); + arrangePlay(); + } + + private function get play():DisplayProperties { + return DisplayProperties(_pluginRegistry.getPlugin("play")); + } + + internal function arrangePlay():void { + if (playView) { + playView.setSize(play.dimensions.width.toPx(this.width), play.dimensions.height.toPx(this.height)); + Arrange.center(playView, width, height); + if (playView.parent == this) { + setChildIndex(playView, numChildren-1); + } + } + } + + private function get playView():AbstractSprite { + if (! play) return null; + return play.getDisplayObject() as AbstractSprite; + } + + private function resizeClip(clip:Clip):void { + if (! clip) return; + if (! clip.getContent()) { + log.warn("clip does not have content, cannot resize. Clip " + clip); + } + if (clip && clip.getContent()) { + if (_fullscreenManaer.isFullscreen) { + var nonHwScaled:MediaSize = clip.scaling == MediaSize.ORIGINAL ? MediaSize.FITTED_PRESERVING_ASPECT_RATIO : clip.scaling; + _resizer.resizeClipTo(clip, clip.accelerated ? MediaSize.ORIGINAL : nonHwScaled); + } else { + _resizer.resizeClipTo(clip, clip.scaling); + } + } + } + + // resized is called when the clip has been resized + internal function resized(clip:Clip):void { + var disp:DisplayObject = _displays[clip]; + disp.width = clip.width; + disp.height = clip.height; + + if (clip.accelerated && _fullscreenManaer.isFullscreen) { + log.debug("in hardware accelerated fullscreen, will not center the clip"); + disp.x = 0; + disp.y = 0; + return; + } + + Arrange.center(disp, width, height); + + //dispatch resized noticed for plugins to manage + clip.dispatchEvent(new ClipEvent(ClipEventType.CLIP_RESIZED)); + } + + public function getDisplayBounds():Rectangle { + var clip:Clip = _playList.current; + var disp:DisplayObject = _displays[clip]; + if (! disp) { + return fallbackDisplayBounds(); + } + if (! disp.visible && _prevClip) { + clip = _prevClip; + disp = _displays[clip]; + } + if (! (disp && disp.visible)) { + return fallbackDisplayBounds(); + } + if (clip.width > 0) { + var result:Rectangle = new Rectangle(disp.x, disp.y, clip.width, clip.height); + log.debug("disp size is " + result.width + " x " + result.height); + return result; + } else { + return fallbackDisplayBounds(); + } + } + + private function fallbackDisplayBounds():Rectangle { + return new Rectangle(0, 0, Arrange.parentWidth, Arrange.parentHeight); + } + + public function set mediaController(controller:MediaController):void { + } + + private function showDisplay(event:ClipEvent):void { + log.info("showDisplay()"); + var clipNow:Clip = event.target as Clip; + if (clipNow.isNullClip) return; + setDisplayVisible(clipNow, true); + _prevClip = clipNow; + log.info("showDisplay done"); + } + + private function setDisplayVisible(clipNow:Clip, visible:Boolean):void { + var disp:DisplayObject = _displays[clipNow]; + log.debug("display " + disp + ", " + disp.name + ", will be made " + (visible ? "visible" : "hidden")); + if (visible) { + MediaDisplay(disp).init(clipNow); + disp.visible = true; + //disp.alpha = 0; // fix for #84 + log.debug("starting fadeIn for " + disp); + _animationEngine.cancel(disp); + _animationEngine.animateProperty(disp, "alpha", 1, clipNow.fadeInSpeed); + Arrange.center(disp, width, height); + } else if (disp.visible) { + _animationEngine.cancel(disp); + _animationEngine.animateProperty(disp, "alpha", 0, clipNow.fadeOutSpeed, function():void { disp.visible = false; }); + return; + } + } + + private function onPlaylistChanged(event:ClipEvent):void { + log.info("onPlaylistChanged()"); + _prevClip = null; + removeDisplays(ClipEventSupport(event.info).clips); + createDisplays(Playlist(event.target).clips); + } + + private function onClipAdded(event:ClipEvent):void { + log.info("onClipAdded(): " + event.info + ", " + event.info2); + var clip:Clip = event.info2 ? event.info2 as Clip : ClipEventSupport(event.target).clips[event.info] as Clip; + log.debug("added clip " + clip); + createDisplay(clip); + } + + private function removeDisplays(clips:Array):void { + for (var i:Number = 0; i < clips.length; i++) { + removeChild(_displays[clips[i]]); + } + } + + private function addListeners(eventSupport:ClipEventSupport):void { + eventSupport.onPlaylistReplace(onPlaylistChanged); + eventSupport.onClipAdd(onClipAdded); + eventSupport.onBufferFull(onBufferFull); + + eventSupport.onBegin(onBegin); + eventSupport.onStart(onStart); + eventSupport.onResume(onResume); + + eventSupport.onUpdate(onUpdate); + + var oneShot:Function = function(clip:Clip):Boolean { return clip.isOneShot; }; + eventSupport.onStop(removeOneShotDisplay, oneShot); + eventSupport.onFinish(removeOneShotDisplay, oneShot); + } + + private function onUpdate(event:ClipEvent):void { + onResize(); + } + + private function removeOneShotDisplay(event:ClipEvent):void { + log.debug("removing display of a one shot clip " + event.target); + removeChild(_displays[event.target]); + delete _displays[event.target]; + } + + private function onBegin(event:ClipEvent):void { + var clip:Clip = event.target as Clip; + if (clip.metaData == false) { + log.info("onBegin: clip.metaData == false, showing it"); + handleStart(clip, event.info as Boolean); + } + + if (clip.getContent() && clip.metaData) { + handleStart(clip, event.info as Boolean ); + } + } + + private function onStart(event:ClipEvent):void { + var clip:Clip = event.target as Clip; + if (clip.metaData == false) return; + handleStart(clip, event.info as Boolean); + } + + private function onResume(event:ClipEvent):void { + var clip:Clip = event.target as Clip; + setDisplayVisibleIfHidden(clip); + + var shown:Array = [_displays[clip]]; + if (onAudioWithRelatedImage(clip)) { + shown.push(_displays[_playList.previousClip]); + } + hideAllDisplays(shown); + } + + private function handleStart(clip:Clip, pauseAfterStart:Boolean):void { + if (clip.isNullClip) return; + log.debug("handleStart(), previous clip " + _playList.previousClip); + // TODO: remove this playlist based cover image thing completely, just relay on coverImage property of audio clips + if (pauseAfterStart && _playList.previousClip && _playList.previousClip.type == ClipType.IMAGE) { + log.debug("autoBuffering next clip on a splash image, will not show next display"); + setDisplayVisibleIfHidden(_playList.previousClip); + if (clip.type == ClipType.AUDIO) return; + + clip.onResume(onFirstFrameResume); + return; + } + + //only show the image playlist for mp3 clips with no display + if (_playList.previousClip && clip.type == ClipType.AUDIO && !clip.getContent()) { + + // TODO: remove this playlist based cover image thing completely, just relay on coverImage property of audio clips + if (onAudioWithRelatedImage(clip)) { + setDisplayVisibleIfHidden(_playList.previousClip); + } else if (clip.type == ClipType.AUDIO && clip.getCustomProperty("coverImage")) { + setDisplayVisibleIfHidden(clip); + hideAllDisplays([_displays[clip]]); + } else { + hideAllDisplays(); + } + _prevClip = clip; + return; + } + + + + setDisplayVisibleIfHidden(clip); + hideAllDisplays([_displays[clip]]); + } + + private function onAudioWithRelatedImage(clip:Clip):Boolean { + if (! _playList.previousClip) return false; + if (clip.type != ClipType.AUDIO) return false; + return _playList.previousClip.type == ClipType.IMAGE && _playList.previousClip.image; + } + + private function setDisplayVisibleIfHidden(clip:Clip):void { + var disp:DisplayObject = _displays[clip]; + if (disp.alpha < 1 || ! disp.visible) { + setDisplayVisible(clip, true); + } + } + + private function hideAllDisplays(except:Array = null):void { + var clips:Array = _playList.clips.concat(_playList.childClips); + for (var i:Number = 0; i < clips.length; i++) { + var clip:Clip = clips[i] as Clip; + var disp:MediaDisplay = _displays[clip]; + if (disp && (! except || except.indexOf(disp) < 0)) { + setDisplayVisible(clips[i] as Clip, false); + } + } + } + + private function onFirstFrameResume(event:ClipEvent):void { + var clip:Clip = event.target as Clip; + clip.unbind(onFirstFrameResume); + showDisplay(event); + } + + private function onBufferFull(event:ClipEvent):void { + var clipNow:Clip = event.target as Clip; + if (clipNow.type == ClipType.IMAGE) { + showDisplay(event); + } + if (clipNow.type == ClipType.VIDEO) { + var disp:MediaDisplay = _displays[clipNow]; + if (! disp) return; + disp.init(clipNow); + + if (clipNow.live) { + showDisplay(event); + } + } + } + + internal function hidePlay():void { + if (playView.parent == this) { + removeChild(playView); + } + } + + internal function showPlay():void { + log.debug("showPlay"); + addChild(playView); + playView.visible = true; + playView.alpha = play.alpha; + + arrangePlay(); + log.debug("play bounds: " + Arrange.describeBounds(playView)); + log.debug("play parent: " + playView.parent); + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Styleable.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Styleable.as new file mode 100644 index 0000000000000000000000000000000000000000..a859251df260eaf2f7955afea1745e65fbc2c5be --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/Styleable.as @@ -0,0 +1,68 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + + /** + * Interface for objects that support modifying their display style. + */ + public interface Styleable { + + /** + * Notifies new css properties. + * + * @param styleProps and object containing the new properties. The propertis contained by this + * object are added, if a specific object already exists it's overwritten. If the parameter is not specified + * returns the current style properties. + * @return void + */ + function onBeforeCss(styleProps:Object = null):void; + + + /** + * Sets/adds css style properties. + * + * @param styleProps and object containing the new properties. The propertis contained by this + * object are added, if a specific object already exists it's overwritten. If the parameter is not specified + * returns the current style properties. + * @return the style props after setting the new properties + */ + function css(styleProps:Object = null):Object; + + + /** + * Notifies a css properties animation. + * + * @param styleProps and object containing the properties to be animated. The propertis contained by this + * object are added, if a specific object already exists it's overwritten. + * @return void + */ + function onBeforeAnimate(styleProps:Object):void; + + /** + * Animates css properties. + * + * @param styleProps and object containing the properties to be animated. The propertis contained by this + * object are added, if a specific object already exists it's overwritten. + * @return the style props after setting the new properties + */ + function animate(styleProps:Object):Object; + + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/StyleableSprite.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/StyleableSprite.as new file mode 100644 index 0000000000000000000000000000000000000000..cdf6fea698602a0bdc7bbf8406b65f33706e32a5 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/StyleableSprite.as @@ -0,0 +1,396 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import flash.events.MouseEvent; + import flash.net.URLRequest; +import flash.net.navigateToURL; + import org.flowplayer.controller.ResourceLoader; + import org.flowplayer.controller.ResourceLoaderImpl; + import org.flowplayer.layout.Length; + import org.flowplayer.util.GraphicsUtil; + import org.flowplayer.view.AbstractSprite; + import org.flowplayer.view.ErrorHandler; + import org.flowplayer.view.FlowStyleSheet; + + import flash.display.Bitmap; + import flash.display.DisplayObject; + import flash.display.DisplayObjectContainer; + import flash.display.Graphics; + import flash.display.Loader; + import flash.display.Sprite; + import flash.events.Event; + import flash.utils.getDefinitionByName; + import flash.utils.getQualifiedClassName; + + /** + * A sprite that can be styled using a StyleSheet. The stylesheet can specify a background image + * to be used or alternatively a background color gradient. + * + * @author api + */ + public class StyleableSprite extends AbstractSprite implements Styleable { + + private var _style:FlowStyleSheet; + private var _image:DisplayObject; + private var _imageMask:DisplayObject; + private var _imageHolder:Sprite; + private var _errorHandler:ErrorHandler; + private var _border:Sprite; + private var _redrawing:Boolean; + private var _loader:ResourceLoader; + + /** + * Creates a new StyleableSprite. + */ + public function StyleableSprite(styleName:String = null, errorHandler:ErrorHandler = null, loader:ResourceLoader = null) { + _errorHandler = errorHandler; + _loader = loader; + if (styleName && loader) { + _style = new FlowStyleSheet(styleName); + loadOrDrawBackground(); + } + } + + /** + * Redraws the sprite, by calling <code>redraw()</code>. Overriding method should call either <code>super.onResize()</code> + * to properly have the background occupy the who space. + */ + override public function setSize(width:Number, height:Number):void { + super.setSize(width, height); + redraw(); + } + + /** + * Called when the background has been redrawn. + */ + protected function onRedraw():void { + } + + private function redraw():void { + if (! style) { + onRedraw(); + return; + } + drawBackground(); + arrangeBackgroundImage(); + drawBorder(); + setChildIndexes(); + addLinkListener(); + onRedraw(); + _redrawing = false; + } + + private function addLinkListener():void { + setLinkListener(this, false); + setLinkListener(_imageHolder, false); + + if (_style.linkUrl) { + setLinkListener(_imageHolder || this, true); + } + } + + private function setLinkListener(parent:Sprite, enable:Boolean):void { + if (! parent) return; + parent.buttonMode = enable; + if (enable) { + parent.addEventListener(MouseEvent.CLICK, onBackgroundImageClicked); + } else { + parent.removeEventListener(MouseEvent.CLICK, onBackgroundImageClicked); + } + } + + private function drawBackground():void { + graphics.clear(); + if (! _style.backgroundTransparent) { + log.debug("drawing background color " + _style.backgroundColor + ", alpha " + _style.backgroundAlpha); + graphics.beginFill(_style.backgroundColor, _style.backgroundAlpha); + GraphicsUtil.drawRoundRectangle(graphics, 0, 0, width, height, _style.borderRadius); + graphics.endFill(); + } else { + log.debug("background color is transparent"); + } + if (_style.backgroundGradient) { + log.debug("adding gradient"); + GraphicsUtil.addGradient(this, _imageHolder ? getChildIndex(_imageHolder) : 0, _style.backgroundGradient, _style.borderRadius); + } else { + GraphicsUtil.removeGradient(this); + } + } + + private function setChildIndexes():void { + if (_imageHolder) { + setChildIndex(_imageHolder, 0); + } + } + + /** + * Sets a new stylesheet. + */ + public final function set style(style:FlowStyleSheet):void { + log.debug("set style"); + _style = style; + onSetStyle(style); + loadOrDrawBackground(); + } + + protected function onSetStyle(style:FlowStyleSheet):void { + } + + public function onBeforeCss(styleProps:Object = null):void + { + + } + + public function css(styleProps:Object = null):Object { + _redrawing = true; + log.debug("css " +styleProps); + if (! styleProps) return _style.rootStyle; + + var rootStyle:Object = null; + for (var propName:String in styleProps) { + if (FlowStyleSheet.ROOT_STYLE_PROPS.indexOf(propName) >= 0) { + if (! rootStyle) { + rootStyle = new Object(); + } + log.debug(propName + " will affect root style, new value " + styleProps[propName]); + rootStyle[propName] = styleProps[propName]; + } else { + log.debug("updating style of " + propName); + addStyleRules(propName, styleProps[propName]); + } + } + if (rootStyle) { + addStyleRules(_style.rootStyleName, rootStyle); + } + return _style.rootStyle; + } + + private function addStyleRules(styleName:String, style:Object):void { + if (styleName == _style.rootStyleName) { + _style.addToRootStyle(style); + onSetRootStyle(_style.rootStyle); + loadOrDrawBackground(); + } else { + _style.addStyleRules(styleName, style); + onSetStyleObject(styleName, style); + } + } + + protected function onSetStyleObject(styleName:String, style:Object):void { + } + + /** + * Sets the style properties object. This sprite is redrawn accoring + * to the new style properties. + * @see #onArranged() + */ + public final function set rootStyle(style:Object):void { + log.debug("setting root style to " + this); + if (! _style) { + _style = new FlowStyleSheet(getQualifiedClassName(this)); + } + _style.rootStyle = style; + onSetRootStyle(style); + loadOrDrawBackground(); + } + + public function addToRootStyle(style:Object):void { + _style.addToRootStyle(style); + onAddToRootStyle(); + loadOrDrawBackground(); + } + + private function onAddToRootStyle():void { + } + + protected function onSetRootStyle(style:Object):void { + } + + public final function get style():FlowStyleSheet { + return _style; + } + + private function loadOrDrawBackground():void { + if (_style.backgroundImage) { + log.debug("stylesheet specified a background image " + _style.backgroundImage); + loadBackgroundImage(); + } else { + _image = null; + removeBackgroundImage(); + redraw(); + } + } + + private function loadBackgroundImage():void { + var image:String = _style.backgroundImage; + if (! image) return; + if (image.indexOf("url(") == 0) { + image = image.substring(4, image.length - 1); + } + if (! _loader) { + throw new Error("ResourceLoader not available, cannot load backgroundImage"); + } + _loader.load(image, onImageLoaded); + } + + private function onImageLoaded(loader:ResourceLoader):void { + _image = loader.getContent() as DisplayObject; + log.debug("received bacground image " + _image); + redraw(); + } + + private function arrangeBackgroundImage():void { + if (! _image) return; +// graphics.clear(); + createImageHolder(); + + if (_style.backgroundRepeat) { + repeatBackground(_image); + } else { + addBackgroundImage(_image); + var xPos:Length = _style.backgroundImageX; + var yPos:Length = _style.backgroundImageY; + + log.debug("background image xPos " + xPos); + log.debug("background image yPos " + yPos); + + if (xPos.px >= 0) { + _imageHolder.x = xPos.px; + } else if (xPos.pct > 0) { + _imageHolder.x = xPos.pct/100 * width - _imageHolder .width/2; + } + + if (yPos.px >= 0) { + _imageHolder.y = yPos.px; + } else if (yPos.pct > 0) { + _imageHolder.y = yPos.pct/100 * height - _imageHolder .height/2; + } + } + } + + private function removeBackgroundImage():Boolean { + if (_imageHolder) { + log.debug("removing background image"); + removeChild(_imageHolder); + _imageHolder = null; + return true; + } + return false; + } + + private function createImageHolder():void { + removeBackgroundImage(); + _imageHolder = new Sprite(); + addChild(_imageHolder); + _imageMask = createMask(); + addChild(_imageMask); + _imageHolder.mask = _imageMask; + _imageHolder.x = 0; + _imageHolder.y = 0; + } + + private function onBackgroundImageClicked(event:MouseEvent):void { + navigateToURL(new URLRequest(_style.linkUrl), _style.linkWindow); + event.stopPropagation(); + } + + /** + * Creates a sprite that is equal to the size of this sprite. + * @return a sprite that can be used as a mask to hide display objects + * that exceed of go outside the borders of this sprite + */ + protected function createMask():Sprite { + var mask:Sprite = new Sprite(); + mask.graphics.beginFill(0); + GraphicsUtil.drawRoundRectangle(mask.graphics, 0, 0, width, height, _style.borderRadius); + return mask; + } + + private function addBackgroundImage(image:DisplayObject):DisplayObject { + _imageHolder.addChild(image); + return image; + } + + private function repeatBackground(image:DisplayObject):void { + var xMax:int = Math.round(width/image.width); + var yMax:int = Math.round(height/image.height); + log.debug(xMax + ", " + yMax); + for (var x:int = 0; x <= xMax; x++) { + for (var y:int = 0; y <= yMax; y++) { + var clone:DisplayObject = clone(image); + // make sure cloning succeeded + if (! clone) return; + + var child:DisplayObject = addBackgroundImage(clone); + child.x = x * image.width; + child.y = y * image.height; + log.debug("added backgound at " + child.x + ", " + child.y); + } + } + } + + private function clone(target:DisplayObject):DisplayObject { + if (! target) return null; + if (target is Bitmap) return new Bitmap(Bitmap(target).bitmapData); + if (target is Loader) return clone(Loader(target).content); + + var ClassReference:Class = getDefinitionByName(getQualifiedClassName(target)) as Class; + return new ClassReference() as DisplayObject; + } + + private function drawBorder():void { + if (_border && _border.parent == this) { + removeChild(_border); + } + if (! _style.borderWidth > 0) return; + _border = new Sprite(); + addChild(_border); + log.info("border weight is " + _style.borderWidth + ", alpha "+ _style.borderAlpha); + _border.graphics.lineStyle(_style.borderWidth, _style.borderColor, _style.borderAlpha); + GraphicsUtil.drawRoundRectangle(_border.graphics, 0, 0, width, height, _style.borderRadius); + } + + protected function get bgImageHolder():Sprite { + return _imageHolder; + } + + /** + * Currently just returns the root style object. + */ + + public function onBeforeAnimate(styleProps:Object):void + { + + } + + public function animate(styleProps:Object):Object { + return _style.rootStyle; + } + + public function get redrawing() : Boolean{ + return _redrawing; + } + + protected function set loader(loader:ResourceLoader):void { + log.debug("got loader"); + _loader = loader; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/VideoApiDisplay.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/VideoApiDisplay.as new file mode 100644 index 0000000000000000000000000000000000000000..71f14cbd09956e8294c0ebbe81fda2cc1d4cd5f7 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/VideoApiDisplay.as @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import org.flowplayer.util.Arrange; + import org.flowplayer.model.Clip; + import org.flowplayer.view.MediaDisplay; + + import flash.display.Sprite; + import flash.display.DisplayObject; + + /** + * @author api + * @author danielr + */ + internal class VideoApiDisplay extends AbstractSprite implements MediaDisplay { + + private var video:DisplayObject; + private var _overlay:Sprite; + private var _clip:Clip; + + public function VideoApiDisplay(clip:Clip) { + _clip = clip; + createOverlay(); + } + + private function createOverlay():void { + // we need to have an invisible layer on top of the video, otherwise the ContextMenu does not work?? + _overlay = new Sprite(); + addChild(_overlay); + _overlay.graphics.beginFill(0, 0); + _overlay.graphics.drawRect(0, 0, 10, 10); + _overlay.graphics.endFill(); + } + + public function get overlay():Sprite { + return _overlay; + } + + override protected function onResize():void { + _overlay.width = this.width; + _overlay.height = this.height; + } + + override public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void { + _overlay.addEventListener(type, listener, useCapture, priority, useWeakReference); + } + + override public function set alpha(value:Number):void { + } + + public function init(clip:Clip):void { + _clip = clip; + log.info("init " + _clip); + + //get the display object from the chromeless video provider which is a loader of the external swf loading the video from + + video = clip.getContent(); + if (video == null) { + log.warn("no video content in clip " + clip); + return; + } + video.width = this.width; + video.height = this.height; + addChild(video); + swapChildren(_overlay, video); + } + + public function hasContent():Boolean { + return video != null; + } + + override public function toString():String { + return "[VideoApiDisplay] for clip " + _clip; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/VideoDisplay.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/VideoDisplay.as new file mode 100644 index 0000000000000000000000000000000000000000..b6942592b1ce15abee50d2720f2f8f3647f7b8b1 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/VideoDisplay.as @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2008-2011 Flowplayer Oy * + * This file is part of Flowplayer. + * + * Flowplayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Flowplayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + import org.flowplayer.util.Arrange; + import org.flowplayer.model.Clip; + import org.flowplayer.view.MediaDisplay; + + import flash.display.Sprite; + import flash.media.Video; + + /** + * @author api + */ + internal class VideoDisplay extends AbstractSprite implements MediaDisplay { + + private var video:Video; + private var _overlay:Sprite; + private var _clip:Clip; + + public function VideoDisplay(clip:Clip) { + _clip = clip; + createOverlay(); + } + + private function createOverlay():void { + // we need to have an invisible layer on top of the video, otherwise the ContextMenu does not work?? + _overlay = new Sprite(); + addChild(_overlay); + _overlay.graphics.beginFill(0, 0); + _overlay.graphics.drawRect(0, 0, 10, 10); + _overlay.graphics.endFill(); + } + + public function get overlay():Sprite { + return _overlay; + } + + override protected function onResize():void { + Arrange.sameSize(_overlay, this); + } + + override public function set alpha(value:Number):void { + super.alpha = value; + if (video) { + video.alpha = value; + log.debug("display of + " + _clip + " new alpha " + video.alpha); + } else { + log.debug("set alpha() no video available"); + } + } + + public function init(clip:Clip):void { + _clip = clip; + log.info("init " + _clip); + if (video) + removeChild(video); + video = clip.getContent() as Video; + if (video == null) { + log.warn("no video content in clip " + clip); + return; + } + video.width = this.width; + video.height = this.height; + addChild(video); + swapChildren(_overlay, video); + } + + public function hasContent():Boolean { + return video != null; + } + + override public function toString():String { + return "[VideoDisplay] for clip " + _clip; + } + } +} diff --git a/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/WrapperForIE.as b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/WrapperForIE.as new file mode 100644 index 0000000000000000000000000000000000000000..d2ef9dcb2c4e95db0fb6987ea4c828178f0b5512 --- /dev/null +++ b/typo3/contrib/flowplayer/src/actionscript/org/flowplayer/view/WrapperForIE.as @@ -0,0 +1,48 @@ +/* + * Copyright 2008 Anssi Piirainen + * + * This file is part of FlowPlayer. + * + * FlowPlayer is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FlowPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FlowPlayer. If not, see <http://www.gnu.org/licenses/>. + */ + +package org.flowplayer.view { + /** + * @author api + */ + internal class WrapperForIE { + private var _player:Flowplayer; + + public function WrapperForIE(player:Flowplayer) { + _player = player; + } + + public function fp_stop():void { + _player.stop(); + } + + public function fp_pause():void { + _player.pause(); + } + + public function fp_resume():void { + _player.resume(); + } + + public function fp_close():void { + _player.close(); + } + + } +} diff --git a/typo3/contrib/flowplayer/src/flash/resources.fla b/typo3/contrib/flowplayer/src/flash/resources.fla new file mode 100644 index 0000000000000000000000000000000000000000..12393feb8ec37a3b3383bcb203a14e281ce54af8 Binary files /dev/null and b/typo3/contrib/flowplayer/src/flash/resources.fla differ diff --git a/typo3/contrib/flowplayer/src/flash/resources.swc b/typo3/contrib/flowplayer/src/flash/resources.swc new file mode 100644 index 0000000000000000000000000000000000000000..a086cfe886eda9a44595b1ed5dfe2a8dea4e9f3a Binary files /dev/null and b/typo3/contrib/flowplayer/src/flash/resources.swc differ diff --git a/typo3/contrib/flowplayer/src/flash/resources.swf b/typo3/contrib/flowplayer/src/flash/resources.swf new file mode 100644 index 0000000000000000000000000000000000000000..86b4338fff8733584fec0f2d7b30bc2011a86810 Binary files /dev/null and b/typo3/contrib/flowplayer/src/flash/resources.swf differ diff --git a/typo3/contrib/videojs/video-js/LICENSE.txt b/typo3/contrib/videojs/video-js/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..65c5ca88a67c30becee01c5a8816d964b03862f9 --- /dev/null +++ b/typo3/contrib/videojs/video-js/LICENSE.txt @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/typo3/contrib/videojs/video-js/README.markdown b/typo3/contrib/videojs/video-js/README.markdown new file mode 100644 index 0000000000000000000000000000000000000000..dfe503508430d00d0bd0a9aa53d153a1eea3ea6a --- /dev/null +++ b/typo3/contrib/videojs/video-js/README.markdown @@ -0,0 +1,202 @@ +VideoJS - [HTML5 Video Player](http://videojs.com) +================================================== +Version 2.0.2 + +View [VideoJS.com](http://videojs.com) for a demo and overview. + +VideoJS is an HTML5 video player that uses the HTML5 video tag built into modern browsers, and uses javascript to add custom controls, new functionality, and to fix cross browser bugs. + +The base of VideoJS is Kroc Camen's [Video for Everybody](http://camendesign.com/code/video_for_everybody), which is a video embed code that falls back to a Flash video player or download links for browsers and devices that don't support HTML5 video. + +View demo.html for an example of how to use it. + +Originally based on [this tutorial](http://blog.steveheffernan.com/2010/04/how-to-build-an-html5-video-player/). + +Contributors (Github Username) +------------------------------ +heff, dz0ny, sentientbit, tvdeyen, brandonarbini, gordonbrander, Shraymonks, albertogasparin, sandaru1, nicholasbs, majornista, Fredust85, @wonderboymusic + + +Getting Started +--------------- + +### Step 1: Include VideoJS Javascript and CSS files in your page. +Change the src/href to the appropriate location on your server. + + <script src="video.js" type="text/javascript" charset="utf-8"></script> + <link rel="stylesheet" href="video-js.css" type="text/css" media="screen" title="Video JS" charset="utf-8"> + + +### Step 2: Add the VideoJS setup code to your page or another script. +Must run after the VideoJS javascript file has been included + + <script type="text/javascript" charset="utf-8"> + + // Add VideoJS to all video tags on the page when the DOM is ready + VideoJS.setupAllWhenReady(); + + </script> + + +### Step 3: Add the VideoJS embed code to your page (grab the latest version for demo.html). +Change the video and image files to your own. You can even swap out the Flash Fallback for your own, just maintain the "vjs-flash-fallback" class on the object. I know, seems like a lot of HTML, but it's super compatible. [Check it](http://camendesign.com/code/video_for_everybody/test.html). + + <!-- Begin VideoJS --> + <div class="video-js-box"> + <!-- Using the Video for Everybody Embed Code http://camendesign.com/code/video_for_everybody --> + <video id="example_video_1" class="video-js" width="640" height="264" poster="http://video-js.zencoder.com/oceans-clip.png" controls preload> + <source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' /> + <source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm; codecs="vp8, vorbis"' /> + <source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg; codecs="theora, vorbis"' /> + <!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. --> + <object id="flash_fallback_1" class="vjs-flash-fallback" width="640" height="264" type="application/x-shockwave-flash" + data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf"> + <param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" /> + <param name="allowfullscreen" value="true" /> + <param name="flashvars" value='config={"playlist":["http://video-js.zencoder.com/oceans-clip.png", {"url": "http://video-js.zencoder.com/oceans-clip.mp4","autoPlay":false,"autoBuffering":true}]}' /> + <!-- Image Fallback. Typically the same as the poster image. --> + <img src="http://video-js.zencoder.com/oceans-clip.png" width="640" height="264" alt="Poster Image" + title="No video playback capabilities." /> + </object> + </video> + <!-- Download links provided for devices that can't play video in the browser. --> + <p class="vjs-no-video"><strong>Download Video:</strong> + <a href="http://video-js.zencoder.com/oceans-clip.mp4">MP4</a>, + <a href="http://video-js.zencoder.com/oceans-clip.webm">WebM</a>, + <a href="http://video-js.zencoder.com/oceans-clip.ogv">Ogg</a><br> + <!-- Support VideoJS by keeping this link. --> + <a href="http://videojs.com">HTML5 Video Player</a> by VideoJS + </p> + </div> + <!-- End VideoJS --> + + +Storing a Reference to the Player(s) +------------------------------------ +You can set up the player(s) in a way that allows you to access it later, and control things like the video playback. In this case, the setup has to happen after the DOM has been loaded. You can use any library's DOM Ready method, or the one built into VideoJS. + +### Using a Video's ID or Element + + VideoJS.DOMReady(function(){ + var myPlayer = VideoJS.setup("example_video_1"); + }); + + +### Using an array of video elements/IDs +Note: It returns an array of players + + VideoJS.DOMReady(function(){ + var myManyPlayers = VideoJS.setup(["example_video_1", "example_video_2", video3Element]); + }); + + +### All videos on the page with the "video-js" class + + VideoJS.DOMReady(function(){ + var myManyPlayers = VideoJS.setup("All"); + }); + + +### After you have references to your players you can...(example) + + VideoJS.DOMReady(function(){ + var myPlayer = VideoJS.setup("example_video_1"); + myPlayer.play(); // Starts playing the video for this player. + }); + + +Setting Options +--------------- +Set options when setting up the videos. The defaults are shown here. + + VideoJS.setupAllWhenReady({ + controlsBelow: false, // Display control bar below video instead of in front of + controlsHiding: true, // Hide controls when mouse is not over the video + defaultVolume: 0.85, // Will be overridden by user's last volume if available + flashPlayerVersion: 9, // Required flash version for fallback + }); + +### Or as the second option of VideoJS.setup + + VideoJS.DOMReady(function(){ + var myPlayer = VideoJS.setup("example_video_1", { + // Same options + }); + }); + + +Coming Next +----------- +- API to Flash fallback + +Changelog +--------- +2.0.2 (2010-12-10) + +- Feature: Rewrote and optimized subtitle code. +- Feature: Protecting against volume ranges outside of 1 and 0. +- Fix: Bug in Safari for Mac OS 10.5 (Leopard) that was breaking fullscreen. + +2.0.1 (2010-11-22) + +- Fix: Issue with big play button when multiple videos are on the page. +- Fix: Optimized play progress tracking. +- Fix: Optimized buffer progress checking. +- Fix: Firefox not showing Flash fallback object. + +2.0.0 (2010-11-21) + +- Feature: Created "behaviors" concept for adding behaviors to elements +- Feature: Switched back to divs for controls, for more portable styles +- Feature: Created playerFallbackOrder array option. ["html5", "flash", "links"] +- Feature: Created playerType concept, for initializing different platforms +- Feature: Added play button for Android +- Feature: Added spinner for iPad (non-fullscreen) +- Feature: Split into multiple files for easier development +- Feature: Combined VideoJS & _V_ into the same variable to reduce confusion +- Fix: Checking for m3u8 files (Apple HTTP Streaming) +- Fix: Catching error on localStorage full that safari seems to randomly throw +- Fix: Scrubbing to end doesn't trigger onEnded + +1.1.5 (2010-11-09) + +- Feature: Switched to track method for setting subtitles. Now works like spec. +- Feature: Created "players" concept for defining fallbacks and fallback order +- Fix: Android playback bug. +- Fix: Massive reorganization of code to make easier to navigate + +1.1.4 (2010-11-06) + +- Feature: Added loading spinner. +- Feature: Improved styles loaded checking. +- Feature: Added volume() function to get and set volume through the player. +- Fix: Fix issue where FF would loop video in background when ended. +- Fix: Bug in Chrome that shows poster & plays audio if you set currentTime too quickly. +- Fix: Bug in Safari where waiting is triggered and shows spinner when not needed +- Fix: Updated to show links if only unplayable sources and no Flash. +- Fix: Issue where if play button was loaded after play, it wouldn't hide. + +1.1.3 (2010-10-19) + +- Feature: Width/Height functions for resizing the player +- Feature: Made initial click & hold trigger new value on progress and volume +- Feature: Made controls not hide when hovering over them +- Feature: Added big play button as default starting control. +- Fix: Removed trailing comma that was breaking IE7 +- Fix: Removed some vars from global scope +- Fix: Changed a document.onmousemove to an eventListener to prevent conflicts +- Fix: Added a unique ID to FlowPlayer demo object to fix a FlowPlayer bug. Thanks @emirpprime. +- Fix: Safari error on unloaded video + +1.1.2 (2010-09-20) + +- Added a fix for the poster bug in iPad/iPhone +- Added more specificity to styles + +1.1.1 (2010-09-14) + +- First Formally Versioned Release + +1.0.0 (2010-05-18) + +- First released diff --git a/typo3/contrib/videojs/video-js/demo-subtitles.srt b/typo3/contrib/videojs/video-js/demo-subtitles.srt new file mode 100644 index 0000000000000000000000000000000000000000..c86609c3d646261d79fd66645cfee39dd69827a6 --- /dev/null +++ b/typo3/contrib/videojs/video-js/demo-subtitles.srt @@ -0,0 +1,13 @@ +1 +00:00:02,400 --> 00:00:05,200 +[Background Music Playing] + +2 +00:00:15,712 --> 00:00:17,399 +Heay!! + +3 +00:00:25,712 --> 00:00:30,399 +[Bird noises] + + diff --git a/typo3/contrib/videojs/video-js/demo.html b/typo3/contrib/videojs/video-js/demo.html new file mode 100644 index 0000000000000000000000000000000000000000..0cc81c005130d6d0109549d7a18d63b3ccde4c72 --- /dev/null +++ b/typo3/contrib/videojs/video-js/demo.html @@ -0,0 +1,101 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="utf-8" /> + <title>HTML5 Video Player</title> + + <!-- Include the VideoJS Library --> + <script src="video.js" type="text/javascript" charset="utf-8"></script> + + <script type="text/javascript"> + // Must come after the video.js library + + // Add VideoJS to all video tags on the page when the DOM is ready + VideoJS.setupAllWhenReady(); + + /* ============= OR ============ */ + + // Setup and store a reference to the player(s). + // Must happen after the DOM is loaded + // You can use any library's DOM Ready method instead of VideoJS.DOMReady + + /* + VideoJS.DOMReady(function(){ + + // Using the video's ID or element + var myPlayer = VideoJS.setup("example_video_1"); + + // OR using an array of video elements/IDs + // Note: It returns an array of players + var myManyPlayers = VideoJS.setup(["example_video_1", "example_video_2", video3Element]); + + // OR all videos on the page + var myManyPlayers = VideoJS.setup("All"); + + // After you have references to your players you can...(example) + myPlayer.play(); // Starts playing the video for this player. + }); + */ + + /* ========= SETTING OPTIONS ========= */ + + // Set options when setting up the videos. The defaults are shown here. + + /* + VideoJS.setupAllWhenReady({ + controlsBelow: false, // Display control bar below video instead of in front of + controlsHiding: true, // Hide controls when mouse is not over the video + defaultVolume: 0.85, // Will be overridden by user's last volume if available + flashVersion: 9, // Required flash version for fallback + linksHiding: true // Hide download links when video is supported + }); + */ + + // Or as the second option of VideoJS.setup + + /* + VideoJS.DOMReady(function(){ + var myPlayer = VideoJS.setup("example_video_1", { + // Same options + }); + }); + */ + + </script> + + <!-- Include the VideoJS Stylesheet --> + <link rel="stylesheet" href="video-js.css" type="text/css" media="screen" title="Video JS"> +</head> +<body> + + <!-- Begin VideoJS --> + <div class="video-js-box"> + <!-- Using the Video for Everybody Embed Code http://camendesign.com/code/video_for_everybody --> + <video id="example_video_1" class="video-js" width="640" height="264" controls="controls" preload="auto" poster="http://video-js.zencoder.com/oceans-clip.png"> + <source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' /> + <source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm; codecs="vp8, vorbis"' /> + <source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg; codecs="theora, vorbis"' /> + <!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. --> + <object id="flash_fallback_1" class="vjs-flash-fallback" width="640" height="264" type="application/x-shockwave-flash" + data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf"> + <param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" /> + <param name="allowfullscreen" value="true" /> + <param name="flashvars" value='config={"playlist":["http://video-js.zencoder.com/oceans-clip.png", {"url": "http://video-js.zencoder.com/oceans-clip.mp4","autoPlay":false,"autoBuffering":true}]}' /> + <!-- Image Fallback. Typically the same as the poster image. --> + <img src="http://video-js.zencoder.com/oceans-clip.png" width="640" height="264" alt="Poster Image" + title="No video playback capabilities." /> + </object> + </video> + <!-- Download links provided for devices that can't play video in the browser. --> + <p class="vjs-no-video"><strong>Download Video:</strong> + <a href="http://video-js.zencoder.com/oceans-clip.mp4">MP4</a>, + <a href="http://video-js.zencoder.com/oceans-clip.webm">WebM</a>, + <a href="http://video-js.zencoder.com/oceans-clip.ogv">Ogg</a><br> + <!-- Support VideoJS by keeping this link. --> + <a href="http://videojs.com">HTML5 Video Player</a> by VideoJS + </p> + </div> + <!-- End VideoJS --> + +</body> +</html> \ No newline at end of file diff --git a/typo3/contrib/videojs/video-js/skins/hu.css b/typo3/contrib/videojs/video-js/skins/hu.css new file mode 100644 index 0000000000000000000000000000000000000000..06c55eb1ead1a4d8dba6a655ae05a20a9eff305c --- /dev/null +++ b/typo3/contrib/videojs/video-js/skins/hu.css @@ -0,0 +1,116 @@ +/* +VideoJS HuCSS Skin (http://videojs.com) +Version 2.0.0 +*/ + +.hu-css .vjs-controls { + height: 47px; opacity: 0.95; color: #fff; + background: #3A3835; +} +.hu-css.video-js-box.vjs-controls-below .vjs-controls { background: #3A3835; } + +.hu-css .vjs-controls > div { + top: 0; + background: none; + border-radius: 0; -webkit-border-radius: 0; -moz-border-radius: 0; + box-shadow: none; -webkit-box-shadow: none; -moz-box-shadow: none; +} + +/* Top Level Items */ +.hu-css .vjs-controls > div.vjs-play-control, +.hu-css .vjs-controls > div.vjs-volume-control, +.hu-css .vjs-controls > div.vjs-fullscreen-control { + bottom: 20px; height: 27px; +} +/* Bottom Level Items */ +.hu-css .vjs-controls > div.vjs-progress-control, .hu-css .vjs-controls > div.vjs-time-control { + margin-top: 28px; height: 19px; +} + +/* Placement of Control Items */ +.hu-css .vjs-controls > div.vjs-play-control { width: 33px; left: 0px; } +.hu-css .vjs-controls > div.vjs-progress-control { width: left: 84px; right: 0; } +.hu-css .vjs-controls > div.vjs-time-control { width: 84px; left: 0px; } +.hu-css .vjs-controls > div.vjs-volume-control { width: 43px; right: 44px; } +.hu-css .vjs-controls > div.vjs-fullscreen-control { width: 43px; right: 0px; } + +/* Play/Pause +-------------------------------------------------------------------------------- */ +.hu-css.vjs-paused .vjs-play-control span { margin: 9px 0 0 12px; } +.hu-css.vjs-playing .vjs-play-control span { margin: 9px 0 0 12px; } +.hu-css .vjs-play-control:hover { background-color: #000; } + +/* Progress +-------------------------------------------------------------------------------- */ +.hu-css .vjs-progress-holder { /* Box containing play and load progresses */ + height: 19px; border: none; + margin: 0px 0px 0 0px; /* Placement within the progress control item */ + background: #000; + border-radius: 0; -webkit-border-radius: 0; -moz-border-radius: 0; +} +.hu-css .vjs-progress-holder div { height: 13px; margin-top: 3px; border-radius: 0; -webkit-border-radius: 0; -moz-border-radius: 0; } +.hu-css .vjs-play-progress { + /* Default */ background: #777; + /* Webkit */ background: -webkit-gradient(linear, left top, left bottom, from(#999), to(#777)); + /* Firefox */ background: -moz-linear-gradient(top, #999, #777); +} +.hu-css .vjs-load-progress { background: #555; } + +/* Time Display +-------------------------------------------------------------------------------- */ +.hu-css .vjs-controls .vjs-time-control { font-size: 11px; background: #000; } +.hu-css .vjs-controls .vjs-time-control span { line-height: 19px; /* Centering vertically */ } + +/* Volume +-------------------------------------------------------------------------------- */ +/*.hu-css .vjs-volume-control:hover { background-color: #000; }*/ +.hu-css .vjs-volume-control div { margin: 0 5px 0 5px; padding: 9px 0 0 0; } +.hu-css .vjs-volume-control div span { /* Individual volume bars */ + margin: 0 2px 0 0; /* Space between */ + width: 3px; height: 0px; /* Total height is height + bottom border */ + border-bottom: 12px solid #555; /* Default (off) color and height of visible portion */ +} +.hu-css .vjs-volume-control div span.vjs-volume-level-on { border-color: #fff; /* Volume on bar color */ } +/* Creating differnt bar heights through height (transparent) and bottom border (visible). */ +.hu-css .vjs-volume-control div span:nth-child(1) { border-bottom-width: 2px; height: 10px; } +.hu-css .vjs-volume-control div span:nth-child(2) { border-bottom-width: 4px; height: 8px; } +.hu-css .vjs-volume-control div span:nth-child(3) { border-bottom-width: 6px; height: 6px; } +.hu-css .vjs-volume-control div span:nth-child(4) { border-bottom-width: 8px; height: 4px; } +.hu-css .vjs-volume-control div span:nth-child(5) { border-bottom-width: 10px; height: 2px; } + +/* Fullscreen +-------------------------------------------------------------------------------- */ +.hu-css .vjs-fullscreen-control:hover { background-color: #000; } +.hu-css .vjs-fullscreen-control div { margin: 8px 0 0 0px; padding-left: 13px; height: 13px; border-left: 1px solid #555; } +.hu-css .vjs-fullscreen-control div span:nth-child(1) { margin-right: 9px; margin-bottom: 5px; border-top: 4px solid #fff; border-right: 4px solid rgba(0,0,0,0); } +.hu-css .vjs-fullscreen-control div span:nth-child(2) { border-top: 4px solid #fff; border-left: 4px solid rgba(0,0,0,0); } +.hu-css .vjs-fullscreen-control div span:nth-child(3) { clear: both; margin: 0 9px 0 0; border-bottom: 4px solid #fff; border-right: 4px solid rgba(0,0,0,0); } +.hu-css .vjs-fullscreen-control div span:nth-child(4) { border-bottom: 4px solid #fff; border-left: 4px solid rgba(0,0,0,0); } +/* Icon when video is in fullscreen mode */ +.hu-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(1) { border: none; border-bottom: 4px solid #fff; border-left: 4px solid rgba(0,0,0,0); } +.hu-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(2) { border: none; border-bottom: 4px solid #fff; border-right: 4px solid rgba(0,0,0,0); } +.hu-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(3) { border: none; border-top: 4px solid #fff; border-left: 4px solid rgba(0,0,0,0); } +.hu-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(4) { border: none; border-top: 4px solid #fff; border-right: 4px solid rgba(0,0,0,0); } + +/* Big Play Button (at start) +---------------------------------------------------------*/ +.hu-css div.vjs-big-play-button { + width: 76px; height: 70px; margin: -35px 0 0 -38px; + border: 1px solid #ccc; opacity: 0.8; + border-radius: 0px; -webkit-border-radius: 0px; -moz-border-radius: 0px; + + background: rgba(50,50,50,0.8); + + /* CSS Shadows */ + box-shadow: none; -webkit-box-shadow: none; -moz-box-shadow: none; +} +.hu-css div.vjs-big-play-button:hover { + box-shadow: 0px 0px 80px #fff; -webkit-box-shadow: 0px 0px 80px #fff; -moz-box-shadow: 0px 0px 80px #fff; +} +.hu-css div.vjs-big-play-button span { + margin: 16px 0 0 21px; + /* Drawing the play triangle with borders - http://www.infimum.dk/HTML/slantinfo.html */ + border-left: 40px solid #fff; /* Width & Color of play icon */ + /* Height of play icon is total top & bottom border widths. Color is transparent. */ + border-top: 20px solid rgba(0,0,0,0); border-bottom: 20px solid rgba(0,0,0,0); +} \ No newline at end of file diff --git a/typo3/contrib/videojs/video-js/skins/tube.css b/typo3/contrib/videojs/video-js/skins/tube.css new file mode 100644 index 0000000000000000000000000000000000000000..3c7f01c52483f7a6c63a53406911b901919eeef5 --- /dev/null +++ b/typo3/contrib/videojs/video-js/skins/tube.css @@ -0,0 +1,111 @@ +/* +VideoJS TubeCSS Skin (http://videojs.com) +Version 2.0.0 +*/ + +.tube-css .vjs-controls { + opacity: 1; color: #000; + height: 24px; + bottom: 0; + background-color: #ccc; + background: #fcfcfc -webkit-gradient(linear, left top, left bottom, from(#fcfcfc), to(#d0d0d0)) left top; + background: #fcfcfc -moz-linear-gradient(top, #fcfcfc, #d0d0d0) left top; +} + +.tube-css .vjs-controls > div { + height: 23px; margin: 0; background: none; top: 0; + border: 1px solid #b1b1b1; border-left-color: #eee; + border-radius: 0; -webkit-border-radius: 0; -moz-border-radius: 0; + box-shadow: none; -webkit-box-shadow: none; -moz-box-shadow: none; +} + +/* Placement of Control Items */ +.tube-css .vjs-controls > div.vjs-play-control { width: 25px; left: 0; } +.tube-css .vjs-controls > div.vjs-progress-control { left: 102px; right: 83px; } +.tube-css .vjs-controls > div.vjs-time-control { width: 75px; left: 27px; } +.tube-css .vjs-controls > div.vjs-volume-control { width: 50px; right: 30px; } +.tube-css .vjs-controls > div.vjs-fullscreen-control { width: 30px; right: 0; } + +/* Removing borders on time & progress to join them */ +.tube-css .vjs-controls > div.vjs-progress-control { border-left: none; } +.tube-css .vjs-controls > div.vjs-time-control { border-right: none; } + + +/* Play/Pause +-------------------------------------------------------------------------------- */ +.tube-css .vjs-play-control { margin-left: 0; border-left-color: #b1b1b1; } +.tube-css.vjs-paused .vjs-play-control span { border-left-color: #333; border-top-width: 7px; border-left-width: 13px; border-bottom-width: 7px; margin: 5px 0 0 7px; } +.tube-css.vjs-playing .vjs-play-control span { height: 14px; margin: 5px auto 0; border-left: 4px solid #333; border-right: 4px solid #333; } +.tube-css.vjs-paused .vjs-play-control:hover span { border-left-color: #CF1A1A; } +.tube-css.vjs-playing .vjs-play-control:hover span { border-left-color: #CF1A1A; border-right-color: #CF1A1A; } + +/* Time Display +-------------------------------------------------------------------------------- */ +.tube-css .vjs-controls .vjs-time-control { font-size: 11px; } +.tube-css .vjs-controls .vjs-time-control span { line-height: 25px; /* Centering vertically */ } + +/* Progress +-------------------------------------------------------------------------------- */ +.tube-css .vjs-progress-holder { + margin-right: 10px; + background-color: #b1b1b1; + background: #b1b1b1 -webkit-gradient(linear, left top, left bottom, from(#b1b1b1), to(#cacaca)) left top; + background: #b1b1b1 -moz-linear-gradient(top, #b1b1b1, #cacaca) left top; + border-color: #CACACA; border-bottom-color: #eaeaea; + border-radius: 0; -webkit-border-radius: 0; -moz-border-radius: 0; +} +.tube-css .vjs-progress-control .vjs-load-progress { background: #C89191; border-radius: 0; -webkit-border-radius: 0; -moz-border-radius: 0; } +.tube-css .vjs-progress-control .vjs-play-progress { background: #f33; background: -webkit-gradient(linear, left top, left bottom, from(#f33), to(#CF1A1A)); background: -moz-linear-gradient(top, #f33, #CF1A1A); -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; } + +/* Volume +-------------------------------------------------------------------------------- */ +.tube-css .vjs-volume-control div { padding: 3px 0 0 0; } +.tube-css .vjs-volume-control div span { border-bottom-color: #ccc; } +/* Volume icon color */ +.tube-css .vjs-volume-control div span.vjs-volume-level-on { border-color: #333; } +/* Volume icon hovering color */ +.tube-css .vjs-volume-control:hover div span.vjs-volume-level-on { border-color: #CF1A1A; } + +/* Fullscreen +-------------------------------------------------------------------------------- */ +.tube-css .vjs-fullscreen-control div { margin: 4px 0 0 8px; } +/* Fullscreen icon color */ +.tube-css .vjs-fullscreen-control div span:nth-child(3), .tube-css .vjs-fullscreen-control div span:nth-child(4), .tube-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(1), .tube-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(2) { + border-bottom-color: #333; +} +.tube-css .vjs-fullscreen-control div span:nth-child(1), .tube-css .vjs-fullscreen-control div span:nth-child(2), .tube-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(3), .tube-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(4) { + border-top-color: #333; +} +/* Fullscreen icon hovering color */ +.tube-css .vjs-fullscreen-control:hover div span:nth-child(3), .tube-css .vjs-fullscreen-control:hover div span:nth-child(4), .tube-css.vjs-fullscreen .vjs-fullscreen-control:hover div span:nth-child(1), .tube-css.vjs-fullscreen .vjs-fullscreen-control:hover div span:nth-child(2) { + border-bottom-color: #CF1A1A; +} +.tube-css .vjs-fullscreen-control:hover div span:nth-child(1), .tube-css .vjs-fullscreen-control:hover div span:nth-child(2), .tube-css.vjs-fullscreen .vjs-fullscreen-control:hover div span:nth-child(3), .tube-css.vjs-fullscreen .vjs-fullscreen-control:hover div span:nth-child(4) { + border-top-color: #CF1A1A; +} + +/* Big Play Button (at start) +---------------------------------------------------------*/ +.tube-css div.vjs-big-play-button { + width: 84px; height: 58px; margin: -29px 0 0 -42px; + border: 2px solid #ccc; opacity: 0.9; + border-radius: 10px; -webkit-border-radius: 10px; -moz-border-radius: 10px; + + /* CSS Background Gradients */ + /* Default */ background-color: #333; + /* Webkit */ background: #000 -webkit-gradient(linear, left top, left bottom, from(#000), to(#333)) left 29px; + /* Firefox */ background: #000 -moz-linear-gradient(top, #000, #333) left 29px; + + /* CSS Shadows */ + box-shadow: none; -webkit-box-shadow: none; -moz-box-shadow: none; +} +.tube-css div.vjs-big-play-button:hover { + opacity: 1; +} +.tube-css div.vjs-big-play-button span { + margin: 11px 0 0 26px; + /* Drawing the play triangle with borders - http://www.infimum.dk/HTML/slantinfo.html */ + border-left: 36px solid #fff; /* Width & Color of play icon */ + /* Height of play icon is total top & bottom border widths. Color is transparent. */ + border-top: 18px solid rgba(0,0,0,0); border-bottom: 18px solid rgba(0,0,0,0); +} diff --git a/typo3/contrib/videojs/video-js/skins/vim.css b/typo3/contrib/videojs/video-js/skins/vim.css new file mode 100644 index 0000000000000000000000000000000000000000..0a318d542b18259052e01a5b3e3baeacd6191021 --- /dev/null +++ b/typo3/contrib/videojs/video-js/skins/vim.css @@ -0,0 +1,89 @@ +/* +VideoJS VimCSS Skin (http://videojs.com) +Version 2.0.0 +*/ + +.vim-css .vjs-controls { + height: 60px; opacity: 0.9; color: #fff; +} +.vim-css .vjs-controls > div { + height: 32px; top: 18px; padding: 0; text-align: center; background: rgba(23, 35, 34, 0.746094); + border-radius: 0; -webkit-border-radius: 0; -moz-border-radius: 0; + box-shadow: none; -webkit-box-shadow: none; -moz-box-shadow: none; +} +/* Placement of Control Items */ +.vim-css .vjs-controls > div.vjs-play-control { width: 65px; left: 10px; } +.vim-css .vjs-controls > div.vjs-progress-control { left: 85px; right: 160px; } +.vim-css .vjs-controls > div.vjs-time-control { width: 75px; right: 85px; } +.vim-css .vjs-controls > div.vjs-volume-control { width: 50px; right: 35px; } +.vim-css .vjs-controls > div.vjs-fullscreen-control { width: 25px; right: 10px; } + +/* Play/Pause +-------------------------------------------------------------------------------- */ +.vim-css .vjs-controls .vjs-play-control { top: 10px; margin: 0; height: 40px; border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; } +.vim-css .vjs-play-control:hover { background: #00ADEF; } +.vim-css.vjs-paused .vjs-play-control span { border-left-color: #fff; border-top-width: 9px; border-left-width: 18px; border-bottom-width: 9px; margin: 11px 0 0 24px; } +.vim-css.vjs-playing .vjs-play-control span { width: 5px; height: 18px; margin: 5px auto 0; border-left: 5px solid #fff; border-right: 5px solid #fff; margin: 11px 0 0 24px; } + +/* Progress +-------------------------------------------------------------------------------- */ +.vim-css .vjs-controls .vjs-progress-control { border-radius: 5px 0 0 5px; -webkit-border-radius: 5px 0 0 5px; -moz-border-radius: 5px 0 0 5px; } +.vim-css .vjs-progress-control .vjs-progress-holder { height: 8px; padding: 1px; margin: 10px 5px 0 10px; border-color: #666666; border-radius: 0; -webkit-border-radius: 0; -moz-border-radius: 0; } +.vim-css .vjs-progress-control .vjs-play-progress { height: 8px; background: #00ADEF; border-radius: 0; -webkit-border-radius: 0; -moz-border-radius: 0; } +.vim-css .vjs-progress-control .vjs-load-progress { height: 8px; background: #898F8F; border-radius: 0; -webkit-border-radius: 0; -moz-border-radius: 0; } + +/* Time Display +-------------------------------------------------------------------------------- */ +.vim-css .vjs-controls .vjs-time-control { font-size: 11px; } +.vim-css .vjs-controls .vjs-time-control span { line-height: 32px; /* Centering vertically */ } + +/* Volume +-------------------------------------------------------------------------------- */ +.vim-css .vjs-volume-control div { padding: 7px 0 0 5px; width: 30px; } +.vim-css .vjs-volume-control div span { + float: left; margin: 0 2px 0 0; padding: 0; width: 3px; height: 3px; border-bottom: 12px solid #666666; + -webkit-transition: all 100ms linear; -moz-transition: all 100ms linear; +} +.vim-css .vjs-volume-control div span.vjs-volume-level-on { border-color: #00ADEF; } +.vim-css .vjs-volume-control div span:hover { height: 0; border-bottom-width: 15px; } + +/* Fullscreen +-------------------------------------------------------------------------------- */ +.vim-css .vjs-fullscreen-control div { margin: 10px 0 0 0; } +.vim-css .vjs-controls .vjs-fullscreen-control { border-radius: 0 5px 5px 0; -webkit-border-radius: 0 5px 5px 0; -moz-border-radius: 0 5px 5px 0; } +/* Making default fullscreen icon smaller */ +.vim-css .vjs-fullscreen-control div span:nth-child(1) { margin: 0 4px 4px 0; border: none; border-top: 4px solid #fff; border-right: 4px solid rgba(0,0,0,0); } +.vim-css .vjs-fullscreen-control div span:nth-child(2) { border: none; border-top: 4px solid #fff; border-left: 4px solid rgba(0,0,0,0); } +.vim-css .vjs-fullscreen-control div span:nth-child(3) { clear: both; margin: 0 4px 0 0; border: none; border-bottom: 4px solid #fff; border-right: 4px solid rgba(0,0,0,0); } +.vim-css .vjs-fullscreen-control div span:nth-child(4) { border: none; border-bottom: 4px solid #fff; border-left: 4px solid rgba(0,0,0,0); } +.vim-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(1) { border: none; border-bottom: 4px solid #fff; border-left: 4px solid rgba(0,0,0,0); } +.vim-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(2) { border: none; border-bottom: 4px solid #fff; border-right: 4px solid rgba(0,0,0,0); } +.vim-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(3) { border: none; border-top: 4px solid #fff; border-left: 4px solid rgba(0,0,0,0); } +.vim-css.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(4) { border: none; border-top: 4px solid #fff; border-right: 4px solid rgba(0,0,0,0); } +/* Fullscreen control hovering */ +.vim-css .vjs-fullscreen-control:hover div span:nth-child(3), .vim-css .vjs-fullscreen-control:hover div span:nth-child(4), .vim-css.vjs-fullscreen .vjs-fullscreen-control:hover div span:nth-child(1), .vim-css.vjs-fullscreen .vjs-fullscreen-control:hover div span:nth-child(2) { border-bottom-color: #00ADEF; } +.vim-css .vjs-fullscreen-control:hover div span:nth-child(1), .vim-css .vjs-fullscreen-control:hover div span:nth-child(2), .vim-css.vjs-fullscreen .vjs-fullscreen-control:hover div span:nth-child(3), .vim-css.vjs-fullscreen .vjs-fullscreen-control:hover div span:nth-child(4) { border-top-color: #00ADEF; } + +/* Big Play Button (at start) +---------------------------------------------------------*/ +.vim-css div.vjs-big-play-button { + width: 130px; height: 80px; margin: -40px 0 0 -65px; + border: none; opacity: 0.9; + border-radius: 10px; -webkit-border-radius: 10px; -moz-border-radius: 10px; + + background: rgba(23, 35, 34, 0.746094); + + /* CSS Shadows */ + box-shadow: none; -webkit-box-shadow: none; -moz-box-shadow: none; +} +.vim-css div.vjs-big-play-button:hover { + background: #00ADEF; + opacity: 1; +} +.vim-css div.vjs-big-play-button span { + margin: 22px 0 0 48px; + /* Drawing the play triangle with borders - http://www.infimum.dk/HTML/slantinfo.html */ + border-left: 36px solid #fff; /* Width & Color of play icon */ + /* Height of play icon is total top & bottom border widths. Color is transparent. */ + border-top: 18px solid rgba(0,0,0,0); border-bottom: 18px solid rgba(0,0,0,0); +} diff --git a/typo3/contrib/videojs/video-js/video-js.css b/typo3/contrib/videojs/video-js/video-js.css new file mode 100644 index 0000000000000000000000000000000000000000..c9c482371f18fe6931c3e4dbd9bcb9ce918c262f --- /dev/null +++ b/typo3/contrib/videojs/video-js/video-js.css @@ -0,0 +1,242 @@ +/* +VideoJS Default Styles (http://videojs.com) +Version 2.0.2 + +REQUIRED STYLES (be careful overriding) +================================================================================ */ +/* Box containing video, controls, and download links. + Will be set to the width of the video element through JS + If you want to add some kind of frame or special positioning, use another containing element, not video-js-box. */ +.video-js-box { text-align: left; position: relative; line-height: 0 !important; margin: 0; padding: 0 !important; border: none !important; } + +/* Video Element */ +video.video-js { background-color: #000; position: relative; padding: 0; } + +.vjs-flash-fallback { display: block; } + +/* Poster Overlay Style */ +.video-js-box img.vjs-poster { display: block; position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 0; padding: 0; cursor: pointer; } +/* Subtiles Style */ +.video-js-box .vjs-subtitles { color: #fff; font-size: 20px; text-align: center; position: absolute; bottom: 40px; left: 0; right: 0; } + +/* Fullscreen styles for main elements */ +.video-js-box.vjs-fullscreen { position: fixed; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden; z-index: 1000; } +.video-js-box.vjs-fullscreen video.video-js, +.video-js-box.vjs-fullscreen .vjs-flash-fallback { position: relative; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000; } +.video-js-box.vjs-fullscreen img.vjs-poster { z-index: 1001; } +.video-js-box.vjs-fullscreen .vjs-spinner { z-index: 1001; } +.video-js-box.vjs-fullscreen .vjs-controls { z-index: 1003; } +.video-js-box.vjs-fullscreen .vjs-big-play-button { z-index: 1004; } +.video-js-box.vjs-fullscreen .vjs-subtitles { z-index: 1004; } + +/* Styles Loaded Check */ +.vjs-styles-check { height: 5px; position: absolute; } +/* Controls Below Video */ +.video-js-box.vjs-controls-below .vjs-controls { position: relative; opacity: 1; background-color: #000; } +.video-js-box.vjs-controls-below .vjs-subtitles { bottom: 75px; } /* Account for height of controls below video */ + +/* DEFAULT SKIN (override in another file) +================================================================================ +Using all CSS to draw the controls. Images could be used if desired. +Instead of editing this file, I recommend creating your own skin CSS file to be included after this file, +so you can upgrade to newer versions easier. */ + +/* Controls Layout + Using absolute positioning to position controls */ +.video-js-box .vjs-controls { + position: absolute; margin: 0; opacity: 0.85; color: #fff; + display: none; /* Start hidden */ + left: 0; right: 0; /* 100% width of video-js-box */ + width: 100%; + bottom: 0px; /* Distance from the bottom of the box/video. Keep 0. Use height to add more bottom margin. */ + height: 35px; /* Including any margin you want above or below control items */ + padding: 0; /* Controls are absolutely position, so no padding necessary */ +} + +.video-js-box .vjs-controls > div { /* Direct div children of control bar */ + position: absolute; /* Use top, bottom, left, and right to specifically position the control. */ + text-align: center; margin: 0; padding: 0; + height: 25px; /* Default height of individual controls */ + top: 5px; /* Top margin to put space between video and controls when controls are below */ + + /* CSS Background Gradients + Using to give the aqua-ish look. */ + /* Default */ background-color: #0B151A; + /* Webkit */ background: #1F3744 -webkit-gradient(linear, left top, left bottom, from(#0B151A), to(#1F3744)) left 12px; + /* Firefox */ background: #1F3744 -moz-linear-gradient(top, #0B151A, #1F3744) left 12px; + + /* CSS Curved Corners */ + border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; + + /* CSS Shadows */ + box-shadow: 1px 1px 2px #000; -webkit-box-shadow: 1px 1px 2px #000; -moz-box-shadow: 1px 1px 2px #000; +} + +/* Placement of Control Items + - Left side of pogress bar, use left & width + - Rigth side of progress bar, use right & width + - Expand with the video (like progress bar) use left & right */ +.vjs-controls > div.vjs-play-control { left: 5px; width: 25px; } +.vjs-controls > div.vjs-progress-control { left: 35px; right: 165px; } /* Using left & right so it expands with the width of the video */ +.vjs-controls > div.vjs-time-control { width: 75px; right: 90px; } /* Time control and progress bar are combined to look like one */ +.vjs-controls > div.vjs-volume-control { width: 50px; right: 35px; } +.vjs-controls > div.vjs-fullscreen-control { width: 25px; right: 5px; } + +/* Removing curved corners on progress control and time control to join them. */ +.vjs-controls > div.vjs-progress-control { + border-top-right-radius: 0; -webkit-border-top-right-radius: 0; -moz-border-radius-topright: 0; + border-bottom-right-radius: 0; -webkit-border-bottom-right-radius: 0; -moz-border-radius-bottomright: 0; +} +.vjs-controls > div.vjs-time-control { + border-top-left-radius: 0; -webkit-border-top-left-radius: 0; -moz-border-radius-topleft: 0; + border-bottom-left-radius: 0; -webkit-border-bottom-left-radius: 0; -moz-border-radius-bottomleft: 0; +} + +/* Play/Pause +-------------------------------------------------------------------------------- */ +.vjs-play-control { cursor: pointer !important; } +/* Play Icon */ +.vjs-play-control span { display: block; font-size: 0; line-height: 0; } +.vjs-paused .vjs-play-control span { + width: 0; height: 0; margin: 8px 0 0 8px; + /* Drawing the play triangle with borders - http://www.infimum.dk/HTML/slantinfo.html */ + border-left: 10px solid #fff; /* Width & Color of play icon */ + /* Height of play icon is total top & bottom border widths. Color is transparent. */ + border-top: 5px solid rgba(0,0,0,0); border-bottom: 5px solid rgba(0,0,0,0); +} +.vjs-playing .vjs-play-control span { + width: 3px; height: 10px; margin: 8px auto 0; + /* Drawing the pause bars with borders */ + border-top: 0px; border-left: 3px solid #fff; border-bottom: 0px; border-right: 3px solid #fff; +} + +/* Progress +-------------------------------------------------------------------------------- */ +.vjs-progress-holder { /* Box containing play and load progresses */ + position: relative; padding: 0; overflow:hidden; cursor: pointer !important; + height: 9px; border: 1px solid #777; + margin: 7px 1px 0 5px; /* Placement within the progress control item */ + border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; +} +.vjs-progress-holder div { /* Progress Bars */ + position: absolute; display: block; width: 0; height: 9px; margin: 0; padding: 0; + border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; +} +.vjs-play-progress { + /* CSS Gradient */ + /* Default */ background: #fff; + /* Webkit */ background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#777)); + /* Firefox */ background: -moz-linear-gradient(top, #fff, #777); +} +.vjs-load-progress { + opacity: 0.8; + /* CSS Gradient */ + /* Default */ background-color: #555; + /* Webkit */ background: -webkit-gradient(linear, left top, left bottom, from(#555), to(#aaa)); + /* Firefox */ background: -moz-linear-gradient(top, #555, #aaa); +} + +/* Time Display +-------------------------------------------------------------------------------- */ +.vjs-controls .vjs-time-control { font-size: 10px; line-height: 1; font-weight: normal; font-family: Helvetica, Arial, sans-serif; } +.vjs-controls .vjs-time-control span { line-height: 25px; /* Centering vertically */ } + +/* Volume +-------------------------------------------------------------------------------- */ +.vjs-volume-control { cursor: pointer !important; } +.vjs-volume-control div { display: block; margin: 0 5px 0 5px; padding: 4px 0 0 0; } +/* Drawing the volume icon using 6 span elements */ +.vjs-volume-control div span { /* Individual volume bars */ + float: left; padding: 0; + margin: 0 2px 0 0; /* Space between */ + width: 5px; height: 0px; /* Total height is height + bottom border */ + border-bottom: 18px solid #555; /* Default (off) color and height of visible portion */ +} +.vjs-volume-control div span.vjs-volume-level-on { border-color: #fff; /* Volume on bar color */ } +/* Creating differnt bar heights through height (transparent) and bottom border (visible). */ +.vjs-volume-control div span:nth-child(1) { border-bottom-width: 2px; height: 16px; } +.vjs-volume-control div span:nth-child(2) { border-bottom-width: 4px; height: 14px; } +.vjs-volume-control div span:nth-child(3) { border-bottom-width: 7px; height: 11px; } +.vjs-volume-control div span:nth-child(4) { border-bottom-width: 10px; height: 8px; } +.vjs-volume-control div span:nth-child(5) { border-bottom-width: 14px; height: 4px; } +.vjs-volume-control div span:nth-child(6) { margin-right: 0; } + +/* Fullscreen +-------------------------------------------------------------------------------- */ +.vjs-fullscreen-control { cursor: pointer !important; } +.vjs-fullscreen-control div { + padding: 0; text-align: left; vertical-align: top; cursor: pointer !important; + margin: 5px 0 0 5px; /* Placement within the fullscreen control item */ + width: 20px; height: 20px; +} +/* Drawing the fullscreen icon using 4 span elements */ +.vjs-fullscreen-control div span { float: left; margin: 0; padding: 0; font-size: 0; line-height: 0; width: 0; text-align: left; vertical-align: top; } +.vjs-fullscreen-control div span:nth-child(1) { /* Top-left triangle */ + margin-right: 3px; /* Space between top-left and top-right */ + margin-bottom: 3px; /* Space between top-left and bottom-left */ + border-top: 6px solid #fff; /* Height and color */ + border-right: 6px solid rgba(0,0,0,0); /* Width */ +} +.vjs-fullscreen-control div span:nth-child(2) { border-top: 6px solid #fff; border-left: 6px solid rgba(0,0,0,0); } +.vjs-fullscreen-control div span:nth-child(3) { clear: both; margin: 0 3px 0 0; border-bottom: 6px solid #fff; border-right: 6px solid rgba(0,0,0,0); } +.vjs-fullscreen-control div span:nth-child(4) { border-bottom: 6px solid #fff; border-left: 6px solid rgba(0,0,0,0); } +/* Icon when video is in fullscreen mode */ +.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(1) { border: none; border-bottom: 6px solid #fff; border-left: 6px solid rgba(0,0,0,0); } +.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(2) { border: none; border-bottom: 6px solid #fff; border-right: 6px solid rgba(0,0,0,0); } +.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(3) { border: none; border-top: 6px solid #fff; border-left: 6px solid rgba(0,0,0,0); } +.vjs-fullscreen .vjs-fullscreen-control div span:nth-child(4) { border: none; border-top: 6px solid #fff; border-right: 6px solid rgba(0,0,0,0); } + +/* Download Links - Used for browsers that don't support any video. +---------------------------------------------------------*/ +.vjs-no-video { font-size: small; line-height: 1.5; } + +/* Big Play Button (at start) +---------------------------------------------------------*/ +div.vjs-big-play-button { + display: none; /* Start hidden */ z-index: 2; + position: absolute; top: 50%; left: 50%; width: 80px; height: 80px; margin: -43px 0 0 -43px; text-align: center; vertical-align: center; cursor: pointer !important; + border: 3px solid #fff; opacity: 0.9; + border-radius: 20px; -webkit-border-radius: 20px; -moz-border-radius: 20px; + + /* CSS Background Gradients */ + /* Default */ background-color: #0B151A; + /* Webkit */ background: #1F3744 -webkit-gradient(linear, left top, left bottom, from(#0B151A), to(#1F3744)) left 40px; + /* Firefox */ background: #1F3744 -moz-linear-gradient(top, #0B151A, #1F3744) left 40px; + + /* CSS Shadows */ + box-shadow: 4px 4px 8px #000; -webkit-box-shadow: 4px 4px 8px #000; -moz-box-shadow: 4px 4px 8px #000; +} +div.vjs-big-play-button:hover { + box-shadow: 0px 0px 80px #fff; -webkit-box-shadow: 0px 0px 80px #fff; -moz-box-shadow: 0px 0px 80px #fff; +} + +div.vjs-big-play-button span { + display: block; font-size: 0; line-height: 0; + width: 0; height: 0; margin: 20px 0 0 23px; + /* Drawing the play triangle with borders - http://www.infimum.dk/HTML/slantinfo.html */ + border-left: 40px solid #fff; /* Width & Color of play icon */ + /* Height of play icon is total top & bottom border widths. Color is transparent. */ + border-top: 20px solid rgba(0,0,0,0); border-bottom: 20px solid rgba(0,0,0,0); +} + +/* Spinner Styles +---------------------------------------------------------*/ +/* CSS Spinners by Kilian Valkhof - http://kilianvalkhof.com/2010/css-xhtml/css3-loading-spinners-without-images/ */ +.vjs-spinner { display: none; position: absolute; top: 50%; left: 50%; width: 100px; height: 100px; z-index: 1; margin: -50px 0 0 -50px; + /* Scaling makes the circles look smoother. */ + transform: scale(0.5); -webkit-transform:scale(0.5); -moz-transform:scale(0.5); +} +/* Spinner circles */ +.vjs-spinner div { position:absolute; left: 40px; top: 40px; width: 20px; height: 20px; background: #fff; + border-radius: 20px; -webkit-border-radius: 20px; -moz-border-radius: 20px; + border: 1px solid #ccc; /* Added border so can be visible on white backgrounds */ +} +/* Each circle */ +.vjs-spinner div:nth-child(1) { opacity: 0.12; transform: rotate(000deg) translate(0, -40px) scale(0.1); -webkit-transform: rotate(000deg) translate(0, -40px) scale(0.1); -moz-transform: rotate(000deg) translate(0, -40px) scale(0.1); } +.vjs-spinner div:nth-child(2) { opacity: 0.25; transform: rotate(045deg) translate(0, -40px) scale(0.2); -webkit-transform: rotate(045deg) translate(0, -40px) scale(0.2); -moz-transform: rotate(045deg) translate(0, -40px) scale(0.2); } +.vjs-spinner div:nth-child(3) { opacity: 0.37; transform: rotate(090deg) translate(0, -40px) scale(0.4); -webkit-transform: rotate(090deg) translate(0, -40px) scale(0.4); -moz-transform: rotate(090deg) translate(0, -40px) scale(0.4); } +.vjs-spinner div:nth-child(4) { opacity: 0.50; transform: rotate(135deg) translate(0, -40px) scale(0.6); -webkit-transform: rotate(135deg) translate(0, -40px) scale(0.6); -moz-transform: rotate(135deg) translate(0, -40px) scale(0.6); } +.vjs-spinner div:nth-child(5) { opacity: 0.62; transform: rotate(180deg) translate(0, -40px) scale(0.8); -webkit-transform: rotate(180deg) translate(0, -40px) scale(0.8); -moz-transform: rotate(180deg) translate(0, -40px) scale(0.8); } +.vjs-spinner div:nth-child(6) { opacity: 0.75; transform: rotate(225deg) translate(0, -40px) scale(1.0); -webkit-transform: rotate(225deg) translate(0, -40px) scale(1.0); -moz-transform: rotate(225deg) translate(0, -40px) scale(1.0); } +.vjs-spinner div:nth-child(7) { opacity: 0.87; transform: rotate(270deg) translate(0, -40px) scale(1.1); -webkit-transform: rotate(270deg) translate(0, -40px) scale(1.1); -moz-transform: rotate(270deg) translate(0, -40px) scale(1.1); } +.vjs-spinner div:nth-child(8) { opacity: 1.00; transform: rotate(315deg) translate(0, -40px) scale(1.3); -webkit-transform: rotate(315deg) translate(0, -40px) scale(1.3); -moz-transform: rotate(315deg) translate(0, -40px) scale(1.3); } \ No newline at end of file diff --git a/typo3/contrib/videojs/video-js/video.js b/typo3/contrib/videojs/video-js/video.js new file mode 100644 index 0000000000000000000000000000000000000000..c0efccd1a88789ae58597330769a731b46acc0f8 --- /dev/null +++ b/typo3/contrib/videojs/video-js/video.js @@ -0,0 +1,1758 @@ +/* +VideoJS - HTML5 Video Player +v2.0.2 + +This file is part of VideoJS. Copyright 2010 Zencoder, Inc. + +VideoJS is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +VideoJS is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with VideoJS. If not, see <http://www.gnu.org/licenses/>. +*/ + +// Self-executing function to prevent global vars and help with minification +(function(window, undefined){ + var document = window.document; + +// Using jresig's Class implementation http://ejohn.org/blog/simple-javascript-inheritance/ +(function(){var initializing=false, fnTest=/xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; this.JRClass = function(){}; JRClass.extend = function(prop) { var _super = this.prototype; initializing = true; var prototype = new this(); initializing = false; for (var name in prop) { prototype[name] = typeof prop[name] == "function" && typeof _super[name] == "function" && fnTest.test(prop[name]) ? (function(name, fn){ return function() { var tmp = this._super; this._super = _super[name]; var ret = fn.apply(this, arguments); this._super = tmp; return ret; }; })(name, prop[name]) : prop[name]; } function JRClass() { if ( !initializing && this.init ) this.init.apply(this, arguments); } JRClass.prototype = prototype; JRClass.constructor = JRClass; JRClass.extend = arguments.callee; return JRClass;};})(); + +// Video JS Player Class +var VideoJS = JRClass.extend({ + + // Initialize the player for the supplied video tag element + // element: video tag + init: function(element, setOptions){ + + // Allow an ID string or an element + if (typeof element == 'string') { + this.video = document.getElementById(element); + } else { + this.video = element; + } + // Store reference to player on the video element. + // So you can acess the player later: document.getElementById("video_id").player.play(); + this.video.player = this; + this.values = {}; // Cache video values. + this.elements = {}; // Store refs to controls elements. + + // Default Options + this.options = { + autoplay: false, + preload: true, + useBuiltInControls: false, // Use the browser's controls (iPhone) + controlsBelow: false, // Display control bar below video vs. in front of + controlsAtStart: false, // Make controls visible when page loads + controlsHiding: true, // Hide controls when not over the video + defaultVolume: 0.85, // Will be overridden by localStorage volume if available + playerFallbackOrder: ["html5", "flash", "links"], // Players and order to use them + flashPlayer: "htmlObject", + flashPlayerVersion: false // Required flash version for fallback + }; + // Override default options with global options + if (typeof VideoJS.options == "object") { _V_.merge(this.options, VideoJS.options); } + // Override default & global options with options specific to this player + if (typeof setOptions == "object") { _V_.merge(this.options, setOptions); } + // Override preload & autoplay with video attributes + if (this.getPreloadAttribute() !== undefined) { this.options.preload = this.getPreloadAttribute(); } + if (this.getAutoplayAttribute() !== undefined) { this.options.autoplay = this.getAutoplayAttribute(); } + + // Store reference to embed code pieces + this.box = this.video.parentNode; + this.linksFallback = this.getLinksFallback(); + this.hideLinksFallback(); // Will be shown again if "links" player is used + + // Loop through the player names list in options, "html5" etc. + // For each player name, initialize the player with that name under VideoJS.players + // If the player successfully initializes, we're done + // If not, try the next player in the list + this.each(this.options.playerFallbackOrder, function(playerType){ + if (this[playerType+"Supported"]()) { // Check if player type is supported + this[playerType+"Init"](); // Initialize player type + return true; // Stop looping though players + } + }); + + // Start Global Listeners - API doesn't exist before now + this.activateElement(this, "player"); + this.activateElement(this.box, "box"); + }, + /* Behaviors + ================================================================================ */ + behaviors: {}, + newBehavior: function(name, activate, functions){ + this.behaviors[name] = activate; + this.extend(functions); + }, + activateElement: function(element, behavior){ + // Allow passing and ID string + if (typeof element == "string") { element = document.getElementById(element); } + this.behaviors[behavior].call(this, element); + }, + /* Errors/Warnings + ================================================================================ */ + errors: [], // Array to track errors + warnings: [], + warning: function(warning){ + this.warnings.push(warning); + this.log(warning); + }, + /* History of errors/events (not quite there yet) + ================================================================================ */ + history: [], + log: function(event){ + if (!event) { return; } + if (typeof event == "string") { event = { type: event }; } + if (event.type) { this.history.push(event.type); } + if (this.history.length >= 50) { this.history.shift(); } + try { console.log(event.type); } catch(e) { try { opera.postError(event.type); } catch(e){} } + }, + /* Local Storage + ================================================================================ */ + setLocalStorage: function(key, value){ + if (!localStorage) { return; } + try { + localStorage[key] = value; + } catch(e) { + if (e.code == 22 || e.code == 1014) { // Webkit == 22 / Firefox == 1014 + this.warning(VideoJS.warnings.localStorageFull); + } + } + }, + /* Helpers + ================================================================================ */ + getPreloadAttribute: function(){ + if (typeof this.video.hasAttribute == "function" && this.video.hasAttribute("preload")) { + var preload = this.video.getAttribute("preload"); + // Only included the attribute, thinking it was boolean + if (preload === "" || preload === "true") { return "auto"; } + if (preload === "false") { return "none"; } + return preload; + } + }, + getAutoplayAttribute: function(){ + if (typeof this.video.hasAttribute == "function" && this.video.hasAttribute("autoplay")) { + var autoplay = this.video.getAttribute("autoplay"); + if (autoplay === "false") { return false; } + return true; + } + }, + // Calculates amoutn of buffer is full + bufferedPercent: function(){ return (this.duration()) ? this.buffered()[1] / this.duration() : 0; }, + // Each that maintains player as context + // Break if true is returned + each: function(arr, fn){ + if (!arr || arr.length === 0) { return; } + for (var i=0,j=arr.length; i<j; i++) { + if (fn.call(this, arr[i], i)) { break; } + } + }, + extend: function(obj){ + for (var attrname in obj) { + if (obj.hasOwnProperty(attrname)) { this[attrname]=obj[attrname]; } + } + } +}); +VideoJS.player = VideoJS.prototype; + +//////////////////////////////////////////////////////////////////////////////// +// Player Types +//////////////////////////////////////////////////////////////////////////////// + +/* Flash Object Fallback (Player Type) +================================================================================ */ +VideoJS.player.extend({ + flashSupported: function(){ + if (!this.flashElement) { this.flashElement = this.getFlashElement(); } + // Check if object exists & Flash Player version is supported + if (this.flashElement && this.flashPlayerVersionSupported()) { + return true; + } else { + return false; + } + }, + flashInit: function(){ + this.replaceWithFlash(); + this.element = this.flashElement; + this.video.src = ""; // Stop video from downloading if HTML5 is still supported + var flashPlayerType = VideoJS.flashPlayers[this.options.flashPlayer]; + this.extend(VideoJS.flashPlayers[this.options.flashPlayer].api); + (flashPlayerType.init.context(this))(); + }, + // Get Flash Fallback object element from Embed Code + getFlashElement: function(){ + var children = this.video.children; + for (var i=0,j=children.length; i<j; i++) { + if (children[i].className == "vjs-flash-fallback") { + return children[i]; + } + } + }, + // Used to force a browser to fall back when it's an HTML5 browser but there's no supported sources + replaceWithFlash: function(){ + // this.flashElement = this.video.removeChild(this.flashElement); + if (this.flashElement) { + this.box.insertBefore(this.flashElement, this.video); + this.video.style.display = "none"; // Removing it was breaking later players + } + }, + // Check if browser can use this flash player + flashPlayerVersionSupported: function(){ + var playerVersion = (this.options.flashPlayerVersion) ? this.options.flashPlayerVersion : VideoJS.flashPlayers[this.options.flashPlayer].flashPlayerVersion; + return VideoJS.getFlashVersion() >= playerVersion; + } +}); +VideoJS.flashPlayers = {}; +VideoJS.flashPlayers.htmlObject = { + flashPlayerVersion: 9, + init: function() { return true; }, + api: { // No video API available with HTML Object embed method + width: function(width){ + if (width !== undefined) { + this.element.width = width; + this.box.style.width = width+"px"; + this.triggerResizeListeners(); + return this; + } + return this.element.width; + }, + height: function(height){ + if (height !== undefined) { + this.element.height = height; + this.box.style.height = height+"px"; + this.triggerResizeListeners(); + return this; + } + return this.element.height; + } + } +}; + + +/* Download Links Fallback (Player Type) +================================================================================ */ +VideoJS.player.extend({ + linksSupported: function(){ return true; }, + linksInit: function(){ + this.showLinksFallback(); + this.element = this.video; + }, + // Get the download links block element + getLinksFallback: function(){ return this.box.getElementsByTagName("P")[0]; }, + // Hide no-video download paragraph + hideLinksFallback: function(){ + if (this.linksFallback) { this.linksFallback.style.display = "none"; } + }, + // Hide no-video download paragraph + showLinksFallback: function(){ + if (this.linksFallback) { this.linksFallback.style.display = "block"; } + } +}); + +//////////////////////////////////////////////////////////////////////////////// +// Class Methods +// Functions that don't apply to individual videos. +//////////////////////////////////////////////////////////////////////////////// + +// Combine Objects - Use "safe" to protect from overwriting existing items +VideoJS.merge = function(obj1, obj2, safe){ + for (var attrname in obj2){ + if (obj2.hasOwnProperty(attrname) && (!safe || !obj1.hasOwnProperty(attrname))) { obj1[attrname]=obj2[attrname]; } + } + return obj1; +}; +VideoJS.extend = function(obj){ this.merge(this, obj, true); }; + +VideoJS.extend({ + // Add VideoJS to all video tags with the video-js class when the DOM is ready + setupAllWhenReady: function(options){ + // Options is stored globally, and added ot any new player on init + VideoJS.options = options; + VideoJS.DOMReady(VideoJS.setup); + }, + + // Run the supplied function when the DOM is ready + DOMReady: function(fn){ + VideoJS.addToDOMReady(fn); + }, + + // Set up a specific video or array of video elements + // "video" can be: + // false, undefined, or "All": set up all videos with the video-js class + // A video tag ID or video tag element: set up one video and return one player + // An array of video tag elements/IDs: set up each and return an array of players + setup: function(videos, options){ + var returnSingular = false, + playerList = [], + videoElement; + + // If videos is undefined or "All", set up all videos with the video-js class + if (!videos || videos == "All") { + videos = VideoJS.getVideoJSTags(); + // If videos is not an array, add to an array + } else if (typeof videos != 'object' || videos.nodeType == 1) { + videos = [videos]; + returnSingular = true; + } + + // Loop through videos and create players for them + for (var i=0; i<videos.length; i++) { + if (typeof videos[i] == 'string') { + videoElement = document.getElementById(videos[i]); + } else { // assume DOM object + videoElement = videos[i]; + } + playerList.push(new VideoJS(videoElement, options)); + } + + // Return one or all depending on what was passed in + return (returnSingular) ? playerList[0] : playerList; + }, + + // Find video tags with the video-js class + getVideoJSTags: function() { + var videoTags = document.getElementsByTagName("video"), + videoJSTags = [], videoTag; + + for (var i=0,j=videoTags.length; i<j; i++) { + videoTag = videoTags[i]; + if (videoTag.className.indexOf("video-js") != -1) { + videoJSTags.push(videoTag); + } + } + return videoJSTags; + }, + + // Check if the browser supports video. + browserSupportsVideo: function() { + if (typeof VideoJS.videoSupport != "undefined") { return VideoJS.videoSupport; } + VideoJS.videoSupport = !!document.createElement('video').canPlayType; + return VideoJS.videoSupport; + }, + + getFlashVersion: function(){ + // Cache Version + if (typeof VideoJS.flashVersion != "undefined") { return VideoJS.flashVersion; } + var version = 0, desc; + if (typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] == "object") { + desc = navigator.plugins["Shockwave Flash"].description; + if (desc && !(typeof navigator.mimeTypes != "undefined" && navigator.mimeTypes["application/x-shockwave-flash"] && !navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)) { + version = parseInt(desc.match(/^.*\s+([^\s]+)\.[^\s]+\s+[^\s]+$/)[1], 10); + } + } else if (typeof window.ActiveXObject != "undefined") { + try { + var testObject = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); + if (testObject) { + version = parseInt(testObject.GetVariable("$version").match(/^[^\s]+\s(\d+)/)[1], 10); + } + } + catch(e) {} + } + VideoJS.flashVersion = version; + return VideoJS.flashVersion; + }, + + // Browser & Device Checks + isIE: function(){ return !+"\v1"; }, + isIPad: function(){ return navigator.userAgent.match(/iPad/i) !== null; }, + isIPhone: function(){ return navigator.userAgent.match(/iPhone/i) !== null; }, + isIOS: function(){ return VideoJS.isIPhone() || VideoJS.isIPad(); }, + iOSVersion: function() { + var match = navigator.userAgent.match(/OS (\d+)_/i); + if (match && match[1]) { return match[1]; } + }, + isAndroid: function(){ return navigator.userAgent.match(/Android/i) !== null; }, + androidVersion: function() { + var match = navigator.userAgent.match(/Android (\d+)\./i); + if (match && match[1]) { return match[1]; } + }, + + warnings: { + // Safari errors if you call functions on a video that hasn't loaded yet + videoNotReady: "Video is not ready yet (try playing the video first).", + // Getting a QUOTA_EXCEEDED_ERR when setting local storage occasionally + localStorageFull: "Local Storage is Full" + } +}); + +// Shim to make Video tag valid in IE +if(VideoJS.isIE()) { document.createElement("video"); } + +// Expose to global +window.VideoJS = window._V_ = VideoJS; + +/* HTML5 Player Type +================================================================================ */ +VideoJS.player.extend({ + html5Supported: function(){ + if (VideoJS.browserSupportsVideo() && this.canPlaySource()) { + return true; + } else { + return false; + } + }, + html5Init: function(){ + this.element = this.video; + + this.fixPreloading(); // Support old browsers that used autobuffer + this.supportProgressEvents(); // Support browsers that don't use 'buffered' + + // Set to stored volume OR 85% + this.volume((localStorage && localStorage.volume) || this.options.defaultVolume); + + // Update interface for device needs + if (VideoJS.isIOS()) { + this.options.useBuiltInControls = true; + this.iOSInterface(); + } else if (VideoJS.isAndroid()) { + this.options.useBuiltInControls = true; + this.androidInterface(); + } + + // Add VideoJS Controls + if (!this.options.useBuiltInControls) { + this.video.controls = false; + + if (this.options.controlsBelow) { _V_.addClass(this.box, "vjs-controls-below"); } + + // Make a click on th video act as a play button + this.activateElement(this.video, "playToggle"); + + // Build Interface + this.buildStylesCheckDiv(); // Used to check if style are loaded + this.buildAndActivatePoster(); + this.buildBigPlayButton(); + this.buildAndActivateSpinner(); + this.buildAndActivateControlBar(); + this.loadInterface(); // Show everything once styles are loaded + this.getSubtitles(); + } + }, + /* Source Managemet + ================================================================================ */ + canPlaySource: function(){ + // Cache Result + if (this.canPlaySourceResult) { return this.canPlaySourceResult; } + // Loop through sources and check if any can play + var children = this.video.children; + for (var i=0,j=children.length; i<j; i++) { + if (children[i].tagName.toUpperCase() == "SOURCE") { + var canPlay = this.video.canPlayType(children[i].type) || this.canPlayExt(children[i].src); + if (canPlay == "probably" || canPlay == "maybe") { + this.firstPlayableSource = children[i]; + this.canPlaySourceResult = true; + return true; + } + } + } + this.canPlaySourceResult = false; + return false; + }, + // Check if the extention is compatible, for when type won't work + canPlayExt: function(src){ + if (!src) { return ""; } + var match = src.match(/\.([^\.]+)$/); + if (match && match[1]) { + var ext = match[1].toLowerCase(); + // Android canPlayType doesn't work + if (VideoJS.isAndroid()) { + if (ext == "mp4" || ext == "m4v") { return "maybe"; } + // Allow Apple HTTP Streaming for iOS + } else if (VideoJS.isIOS()) { + if (ext == "m3u8") { return "maybe"; } + } + } + return ""; + }, + // Force the video source - Helps fix loading bugs in a handful of devices, like the iPad/iPhone poster bug + // And iPad/iPhone javascript include location bug. And Android type attribute bug + forceTheSource: function(){ + this.video.src = this.firstPlayableSource.src; // From canPlaySource() + this.video.load(); + }, + /* Device Fixes + ================================================================================ */ + // Support older browsers that used "autobuffer" + fixPreloading: function(){ + if (typeof this.video.hasAttribute == "function" && this.video.hasAttribute("preload") && this.video.preload != "none") { + this.video.autobuffer = true; // Was a boolean + } else { + this.video.autobuffer = false; + this.video.preload = "none"; + } + }, + + // Listen for Video Load Progress (currently does not if html file is local) + // Buffered does't work in all browsers, so watching progress as well + supportProgressEvents: function(e){ + _V_.addListener(this.video, 'progress', this.playerOnVideoProgress.context(this)); + }, + playerOnVideoProgress: function(event){ + this.setBufferedFromProgress(event); + }, + setBufferedFromProgress: function(event){ // HTML5 Only + if(event.total > 0) { + var newBufferEnd = (event.loaded / event.total) * this.duration(); + if (newBufferEnd > this.values.bufferEnd) { this.values.bufferEnd = newBufferEnd; } + } + }, + + iOSInterface: function(){ + if(VideoJS.iOSVersion() < 4) { this.forceTheSource(); } // Fix loading issues + if(VideoJS.isIPad()) { // iPad could work with controlsBelow + this.buildAndActivateSpinner(); // Spinner still works well on iPad, since iPad doesn't have one + } + }, + + // Fix android specific quirks + // Use built-in controls, but add the big play button, since android doesn't have one. + androidInterface: function(){ + this.forceTheSource(); // Fix loading issues + _V_.addListener(this.video, "click", function(){ this.play(); }); // Required to play + this.buildBigPlayButton(); // But don't activate the normal way. Pause doesn't work right on android. + _V_.addListener(this.bigPlayButton, "click", function(){ this.play(); }.context(this)); + this.positionBox(); + this.showBigPlayButtons(); + }, + /* Wait for styles (TODO: move to _V_) + ================================================================================ */ + loadInterface: function(){ + if(!this.stylesHaveLoaded()) { + // Don't want to create an endless loop either. + if (!this.positionRetries) { this.positionRetries = 1; } + if (this.positionRetries++ < 100) { + setTimeout(this.loadInterface.context(this),10); + return; + } + } + this.hideStylesCheckDiv(); + this.showPoster(); + if (this.video.paused !== false) { this.showBigPlayButtons(); } + if (this.options.controlsAtStart) { this.showControlBars(); } + this.positionAll(); + }, + /* Control Bar + ================================================================================ */ + buildAndActivateControlBar: function(){ + /* Creating this HTML + <div class="vjs-controls"> + <div class="vjs-play-control"> + <span></span> + </div> + <div class="vjs-progress-control"> + <div class="vjs-progress-holder"> + <div class="vjs-load-progress"></div> + <div class="vjs-play-progress"></div> + </div> + </div> + <div class="vjs-time-control"> + <span class="vjs-current-time-display">00:00</span><span> / </span><span class="vjs-duration-display">00:00</span> + </div> + <div class="vjs-volume-control"> + <div> + <span></span><span></span><span></span><span></span><span></span><span></span> + </div> + </div> + <div class="vjs-fullscreen-control"> + <div> + <span></span><span></span><span></span><span></span> + </div> + </div> + </div> + */ + + // Create a div to hold the different controls + this.controls = _V_.createElement("div", { className: "vjs-controls" }); + // Add the controls to the video's container + this.box.appendChild(this.controls); + this.activateElement(this.controls, "controlBar"); + this.activateElement(this.controls, "mouseOverVideoReporter"); + + // Build the play control + this.playControl = _V_.createElement("div", { className: "vjs-play-control", innerHTML: "<span></span>" }); + this.controls.appendChild(this.playControl); + this.activateElement(this.playControl, "playToggle"); + + // Build the progress control + this.progressControl = _V_.createElement("div", { className: "vjs-progress-control" }); + this.controls.appendChild(this.progressControl); + + // Create a holder for the progress bars + this.progressHolder = _V_.createElement("div", { className: "vjs-progress-holder" }); + this.progressControl.appendChild(this.progressHolder); + this.activateElement(this.progressHolder, "currentTimeScrubber"); + + // Create the loading progress display + this.loadProgressBar = _V_.createElement("div", { className: "vjs-load-progress" }); + this.progressHolder.appendChild(this.loadProgressBar); + this.activateElement(this.loadProgressBar, "loadProgressBar"); + + // Create the playing progress display + this.playProgressBar = _V_.createElement("div", { className: "vjs-play-progress" }); + this.progressHolder.appendChild(this.playProgressBar); + this.activateElement(this.playProgressBar, "playProgressBar"); + + // Create the progress time display (00:00 / 00:00) + this.timeControl = _V_.createElement("div", { className: "vjs-time-control" }); + this.controls.appendChild(this.timeControl); + + // Create the current play time display + this.currentTimeDisplay = _V_.createElement("span", { className: "vjs-current-time-display", innerHTML: "00:00" }); + this.timeControl.appendChild(this.currentTimeDisplay); + this.activateElement(this.currentTimeDisplay, "currentTimeDisplay"); + + // Add time separator + this.timeSeparator = _V_.createElement("span", { innerHTML: " / " }); + this.timeControl.appendChild(this.timeSeparator); + + // Create the total duration display + this.durationDisplay = _V_.createElement("span", { className: "vjs-duration-display", innerHTML: "00:00" }); + this.timeControl.appendChild(this.durationDisplay); + this.activateElement(this.durationDisplay, "durationDisplay"); + + // Create the volumne control + this.volumeControl = _V_.createElement("div", { + className: "vjs-volume-control", + innerHTML: "<div><span></span><span></span><span></span><span></span><span></span><span></span></div>" + }); + this.controls.appendChild(this.volumeControl); + this.activateElement(this.volumeControl, "volumeScrubber"); + + this.volumeDisplay = this.volumeControl.children[0]; + this.activateElement(this.volumeDisplay, "volumeDisplay"); + + // Crete the fullscreen control + this.fullscreenControl = _V_.createElement("div", { + className: "vjs-fullscreen-control", + innerHTML: "<div><span></span><span></span><span></span><span></span></div>" + }); + this.controls.appendChild(this.fullscreenControl); + this.activateElement(this.fullscreenControl, "fullscreenToggle"); + }, + /* Poster Image + ================================================================================ */ + buildAndActivatePoster: function(){ + this.updatePosterSource(); + if (this.video.poster) { + this.poster = document.createElement("img"); + // Add poster to video box + this.box.appendChild(this.poster); + + // Add poster image data + this.poster.src = this.video.poster; + // Add poster styles + this.poster.className = "vjs-poster"; + this.activateElement(this.poster, "poster"); + } else { + this.poster = false; + } + }, + /* Big Play Button + ================================================================================ */ + buildBigPlayButton: function(){ + /* Creating this HTML + <div class="vjs-big-play-button"><span></span></div> + */ + this.bigPlayButton = _V_.createElement("div", { + className: "vjs-big-play-button", + innerHTML: "<span></span>" + }); + this.box.appendChild(this.bigPlayButton); + this.activateElement(this.bigPlayButton, "bigPlayButton"); + }, + /* Spinner (Loading) + ================================================================================ */ + buildAndActivateSpinner: function(){ + this.spinner = _V_.createElement("div", { + className: "vjs-spinner", + innerHTML: "<div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>" + }); + this.box.appendChild(this.spinner); + this.activateElement(this.spinner, "spinner"); + }, + /* Styles Check - Check if styles are loaded (move ot _V_) + ================================================================================ */ + // Sometimes the CSS styles haven't been applied to the controls yet + // when we're trying to calculate the height and position them correctly. + // This causes a flicker where the controls are out of place. + buildStylesCheckDiv: function(){ + this.stylesCheckDiv = _V_.createElement("div", { className: "vjs-styles-check" }); + this.stylesCheckDiv.style.position = "absolute"; + this.box.appendChild(this.stylesCheckDiv); + }, + hideStylesCheckDiv: function(){ this.stylesCheckDiv.style.display = "none"; }, + stylesHaveLoaded: function(){ + if (this.stylesCheckDiv.offsetHeight != 5) { + return false; + } else { + return true; + } + }, + /* VideoJS Box - Holds all elements + ================================================================================ */ + positionAll: function(){ + this.positionBox(); + this.positionControlBars(); + this.positionPoster(); + }, + positionBox: function(){ + // Set width based on fullscreen or not. + if (this.videoIsFullScreen) { + this.box.style.width = ""; + this.element.style.height=""; + if (this.options.controlsBelow) { + this.box.style.height = ""; + this.element.style.height = (this.box.offsetHeight - this.controls.offsetHeight) + "px"; + } + } else { + this.box.style.width = this.width() + "px"; + this.element.style.height=this.height()+"px"; + if (this.options.controlsBelow) { + this.element.style.height = ""; + // this.box.style.height = this.video.offsetHeight + this.controls.offsetHeight + "px"; + } + } + }, + /* Subtitles + ================================================================================ */ + getSubtitles: function(){ + var tracks = this.video.getElementsByTagName("TRACK"); + for (var i=0,j=tracks.length; i<j; i++) { + if (tracks[i].getAttribute("kind") == "subtitles" && tracks[i].getAttribute("src")) { + this.subtitlesSource = tracks[i].getAttribute("src"); + this.loadSubtitles(); + this.buildSubtitles(); + } + } + }, + loadSubtitles: function() { _V_.get(this.subtitlesSource, this.parseSubtitles.context(this)); }, + parseSubtitles: function(subText) { + var lines = subText.split("\n"), + line = "", + subtitle, time, text; + this.subtitles = []; + this.currentSubtitle = false; + this.lastSubtitleIndex = 0; + + for (var i=0; i<lines.length; i++) { + line = _V_.trim(lines[i]); // Trim whitespace and linebreaks + if (line) { // Loop until a line with content + + // First line - Number + subtitle = { + id: line, // Subtitle Number + index: this.subtitles.length // Position in Array + }; + + // Second line - Time + line = _V_.trim(lines[++i]); + time = line.split(" --> "); + subtitle.start = this.parseSubtitleTime(time[0]); + subtitle.end = this.parseSubtitleTime(time[1]); + + // Additional lines - Subtitle Text + text = []; + for (var j=i; j<lines.length; j++) { // Loop until a blank line or end of lines + line = _V_.trim(lines[++i]); + if (!line) { break; } + text.push(line); + } + subtitle.text = text.join('<br/>'); + + // Add this subtitle + this.subtitles.push(subtitle); + } + } + }, + + parseSubtitleTime: function(timeText) { + var parts = timeText.split(':'), + time = 0; + // hours => seconds + time += parseFloat(parts[0])*60*60; + // minutes => seconds + time += parseFloat(parts[1])*60; + // get seconds + var seconds = parts[2].split(/\.|,/); // Either . or , + time += parseFloat(seconds[0]); + // add miliseconds + ms = parseFloat(seconds[1]); + if (ms) { time += ms/1000; } + return time; + }, + + buildSubtitles: function(){ + /* Creating this HTML + <div class="vjs-subtitles"></div> + */ + this.subtitlesDisplay = _V_.createElement("div", { className: 'vjs-subtitles' }); + this.box.appendChild(this.subtitlesDisplay); + this.activateElement(this.subtitlesDisplay, "subtitlesDisplay"); + }, + + /* Player API - Translate functionality from player to video + ================================================================================ */ + addVideoListener: function(type, fn){ _V_.addListener(this.video, type, fn.rEvtContext(this)); }, + + play: function(){ + this.video.play(); + return this; + }, + onPlay: function(fn){ this.addVideoListener("play", fn); return this; }, + + pause: function(){ + this.video.pause(); + return this; + }, + onPause: function(fn){ this.addVideoListener("pause", fn); return this; }, + paused: function() { return this.video.paused; }, + + currentTime: function(seconds){ + if (seconds !== undefined) { + try { this.video.currentTime = seconds; } + catch(e) { this.warning(VideoJS.warnings.videoNotReady); } + this.values.currentTime = seconds; + return this; + } + return this.video.currentTime; + }, + onCurrentTimeUpdate: function(fn){ + this.currentTimeListeners.push(fn); + }, + + duration: function(){ + return this.video.duration; + }, + + buffered: function(){ + // Storing values allows them be overridden by setBufferedFromProgress + if (this.values.bufferStart === undefined) { + this.values.bufferStart = 0; + this.values.bufferEnd = 0; + } + if (this.video.buffered && this.video.buffered.length > 0) { + var newEnd = this.video.buffered.end(0); + if (newEnd > this.values.bufferEnd) { this.values.bufferEnd = newEnd; } + } + return [this.values.bufferStart, this.values.bufferEnd]; + }, + + volume: function(percentAsDecimal){ + if (percentAsDecimal !== undefined) { + // Force value to between 0 and 1 + this.values.volume = Math.max(0, Math.min(1, parseFloat(percentAsDecimal))); + this.video.volume = this.values.volume; + this.setLocalStorage("volume", this.values.volume); + return this; + } + if (this.values.volume) { return this.values.volume; } + return this.video.volume; + }, + onVolumeChange: function(fn){ _V_.addListener(this.video, 'volumechange', fn.rEvtContext(this)); }, + + width: function(width){ + if (width !== undefined) { + this.video.width = width; // Not using style so it can be overridden on fullscreen. + this.box.style.width = width+"px"; + this.triggerResizeListeners(); + return this; + } + return this.video.offsetWidth; + }, + height: function(height){ + if (height !== undefined) { + this.video.height = height; + this.box.style.height = height+"px"; + this.triggerResizeListeners(); + return this; + } + return this.video.offsetHeight; + }, + + supportsFullScreen: function(){ + if(typeof this.video.webkitEnterFullScreen == 'function') { + // Seems to be broken in Chromium/Chrome + if (!navigator.userAgent.match("Chrome") && !navigator.userAgent.match("Mac OS X 10.5")) { + return true; + } + } + return false; + }, + + html5EnterNativeFullScreen: function(){ + try { + this.video.webkitEnterFullScreen(); + } catch (e) { + if (e.code == 11) { this.warning(VideoJS.warnings.videoNotReady); } + } + return this; + }, + + // Turn on fullscreen (window) mode + // Real fullscreen isn't available in browsers quite yet. + enterFullScreen: function(){ + if (this.supportsFullScreen()) { + this.html5EnterNativeFullScreen(); + } else { + this.enterFullWindow(); + } + }, + + exitFullScreen: function(){ + if (this.supportsFullScreen()) { + // Shouldn't be called + } else { + this.exitFullWindow(); + } + }, + + enterFullWindow: function(){ + this.videoIsFullScreen = true; + // Storing original doc overflow value to return to when fullscreen is off + this.docOrigOverflow = document.documentElement.style.overflow; + // Add listener for esc key to exit fullscreen + _V_.addListener(document, "keydown", this.fullscreenOnEscKey.rEvtContext(this)); + // Add listener for a window resize + _V_.addListener(window, "resize", this.fullscreenOnWindowResize.rEvtContext(this)); + // Hide any scroll bars + document.documentElement.style.overflow = 'hidden'; + // Apply fullscreen styles + _V_.addClass(this.box, "vjs-fullscreen"); + // Resize the box, controller, and poster + this.positionAll(); + }, + + // Turn off fullscreen (window) mode + exitFullWindow: function(){ + this.videoIsFullScreen = false; + document.removeEventListener("keydown", this.fullscreenOnEscKey, false); + window.removeEventListener("resize", this.fullscreenOnWindowResize, false); + // Unhide scroll bars. + document.documentElement.style.overflow = this.docOrigOverflow; + // Remove fullscreen styles + _V_.removeClass(this.box, "vjs-fullscreen"); + // Resize the box, controller, and poster to original sizes + this.positionAll(); + }, + + onError: function(fn){ this.addVideoListener("error", fn); return this; }, + onEnded: function(fn){ + this.addVideoListener("ended", fn); return this; + } +}); + +//////////////////////////////////////////////////////////////////////////////// +// Element Behaviors +// Tell elements how to act or react +//////////////////////////////////////////////////////////////////////////////// + +/* Player Behaviors - How VideoJS reacts to what the video is doing. +================================================================================ */ +VideoJS.player.newBehavior("player", function(player){ + this.onError(this.playerOnVideoError); + // Listen for when the video is played + this.onPlay(this.playerOnVideoPlay); + this.onPlay(this.trackCurrentTime); + // Listen for when the video is paused + this.onPause(this.playerOnVideoPause); + this.onPause(this.stopTrackingCurrentTime); + // Listen for when the video ends + this.onEnded(this.playerOnVideoEnded); + // Set interval for load progress using buffer watching method + // this.trackCurrentTime(); + this.trackBuffered(); + // Buffer Full + this.onBufferedUpdate(this.isBufferFull); + },{ + playerOnVideoError: function(event){ + this.log(event); + this.log(this.video.error); + }, + playerOnVideoPlay: function(event){ this.hasPlayed = true; }, + playerOnVideoPause: function(event){}, + playerOnVideoEnded: function(event){ + this.currentTime(0); + this.pause(); + }, + + /* Load Tracking -------------------------------------------------------------- */ + // Buffer watching method for load progress. + // Used for browsers that don't support the progress event + trackBuffered: function(){ + this.bufferedInterval = setInterval(this.triggerBufferedListeners.context(this), 500); + }, + stopTrackingBuffered: function(){ clearInterval(this.bufferedInterval); }, + bufferedListeners: [], + onBufferedUpdate: function(fn){ + this.bufferedListeners.push(fn); + }, + triggerBufferedListeners: function(){ + this.isBufferFull(); + this.each(this.bufferedListeners, function(listener){ + (listener.context(this))(); + }); + }, + isBufferFull: function(){ + if (this.bufferedPercent() == 1) { this.stopTrackingBuffered(); } + }, + + /* Time Tracking -------------------------------------------------------------- */ + trackCurrentTime: function(){ + if (this.currentTimeInterval) { clearInterval(this.currentTimeInterval); } + this.currentTimeInterval = setInterval(this.triggerCurrentTimeListeners.context(this), 100); // 42 = 24 fps + this.trackingCurrentTime = true; + }, + // Turn off play progress tracking (when paused or dragging) + stopTrackingCurrentTime: function(){ + clearInterval(this.currentTimeInterval); + this.trackingCurrentTime = false; + }, + currentTimeListeners: [], + // onCurrentTimeUpdate is in API section now + triggerCurrentTimeListeners: function(late, newTime){ // FF passes milliseconds late as the first argument + this.each(this.currentTimeListeners, function(listener){ + (listener.context(this))(newTime || this.currentTime()); + }); + }, + + /* Resize Tracking -------------------------------------------------------------- */ + resizeListeners: [], + onResize: function(fn){ + this.resizeListeners.push(fn); + }, + // Trigger anywhere the video/box size is changed. + triggerResizeListeners: function(){ + this.each(this.resizeListeners, function(listener){ + (listener.context(this))(); + }); + } + } +); +/* Mouse Over Video Reporter Behaviors - i.e. Controls hiding based on mouse location +================================================================================ */ +VideoJS.player.newBehavior("mouseOverVideoReporter", function(element){ + // Listen for the mouse move the video. Used to reveal the controller. + _V_.addListener(element, "mousemove", this.mouseOverVideoReporterOnMouseMove.context(this)); + // Listen for the mouse moving out of the video. Used to hide the controller. + _V_.addListener(element, "mouseout", this.mouseOverVideoReporterOnMouseOut.context(this)); + },{ + mouseOverVideoReporterOnMouseMove: function(){ + this.showControlBars(); + clearInterval(this.mouseMoveTimeout); + this.mouseMoveTimeout = setTimeout(this.hideControlBars.context(this), 4000); + }, + mouseOverVideoReporterOnMouseOut: function(event){ + // Prevent flicker by making sure mouse hasn't left the video + var parent = event.relatedTarget; + while (parent && parent !== this.box) { + parent = parent.parentNode; + } + if (parent !== this.box) { + this.hideControlBars(); + } + } + } +); +/* Mouse Over Video Reporter Behaviors - i.e. Controls hiding based on mouse location +================================================================================ */ +VideoJS.player.newBehavior("box", function(element){ + this.positionBox(); + _V_.addClass(element, "vjs-paused"); + this.activateElement(element, "mouseOverVideoReporter"); + this.onPlay(this.boxOnVideoPlay); + this.onPause(this.boxOnVideoPause); + },{ + boxOnVideoPlay: function(){ + _V_.removeClass(this.box, "vjs-paused"); + _V_.addClass(this.box, "vjs-playing"); + }, + boxOnVideoPause: function(){ + _V_.removeClass(this.box, "vjs-playing"); + _V_.addClass(this.box, "vjs-paused"); + } + } +); +/* Poster Image Overlay +================================================================================ */ +VideoJS.player.newBehavior("poster", function(element){ + this.activateElement(element, "mouseOverVideoReporter"); + this.activateElement(element, "playButton"); + this.onPlay(this.hidePoster); + this.onEnded(this.showPoster); + this.onResize(this.positionPoster); + },{ + showPoster: function(){ + if (!this.poster) { return; } + this.poster.style.display = "block"; + this.positionPoster(); + }, + positionPoster: function(){ + // Only if the poster is visible + if (!this.poster || this.poster.style.display == 'none') { return; } + this.poster.style.height = this.height() + "px"; // Need incase controlsBelow + this.poster.style.width = this.width() + "px"; // Could probably do 100% of box + }, + hidePoster: function(){ + if (!this.poster) { return; } + this.poster.style.display = "none"; + }, + // Update poster source from attribute or fallback image + // iPad breaks if you include a poster attribute, so this fixes that + updatePosterSource: function(){ + if (!this.video.poster) { + var images = this.video.getElementsByTagName("img"); + if (images.length > 0) { this.video.poster = images[0].src; } + } + } + } +); +/* Control Bar Behaviors +================================================================================ */ +VideoJS.player.newBehavior("controlBar", function(element){ + if (!this.controlBars) { + this.controlBars = []; + this.onResize(this.positionControlBars); + } + this.controlBars.push(element); + _V_.addListener(element, "mousemove", this.onControlBarsMouseMove.context(this)); + _V_.addListener(element, "mouseout", this.onControlBarsMouseOut.context(this)); + },{ + showControlBars: function(){ + if (!this.options.controlsAtStart && !this.hasPlayed) { return; } + this.each(this.controlBars, function(bar){ + bar.style.display = "block"; + }); + }, + // Place controller relative to the video's position (now just resizing bars) + positionControlBars: function(){ + this.updatePlayProgressBars(); + this.updateLoadProgressBars(); + }, + hideControlBars: function(){ + if (this.options.controlsHiding && !this.mouseIsOverControls) { + this.each(this.controlBars, function(bar){ + bar.style.display = "none"; + }); + } + }, + // Block controls from hiding when mouse is over them. + onControlBarsMouseMove: function(){ this.mouseIsOverControls = true; }, + onControlBarsMouseOut: function(event){ + this.mouseIsOverControls = false; + } + } +); +/* PlayToggle, PlayButton, PauseButton Behaviors +================================================================================ */ +// Play Toggle +VideoJS.player.newBehavior("playToggle", function(element){ + if (!this.elements.playToggles) { + this.elements.playToggles = []; + this.onPlay(this.playTogglesOnPlay); + this.onPause(this.playTogglesOnPause); + } + this.elements.playToggles.push(element); + _V_.addListener(element, "click", this.onPlayToggleClick.context(this)); + },{ + onPlayToggleClick: function(event){ + if (this.paused()) { + this.play(); + } else { + this.pause(); + } + }, + playTogglesOnPlay: function(event){ + this.each(this.elements.playToggles, function(toggle){ + _V_.removeClass(toggle, "vjs-paused"); + _V_.addClass(toggle, "vjs-playing"); + }); + }, + playTogglesOnPause: function(event){ + this.each(this.elements.playToggles, function(toggle){ + _V_.removeClass(toggle, "vjs-playing"); + _V_.addClass(toggle, "vjs-paused"); + }); + } + } +); +// Play +VideoJS.player.newBehavior("playButton", function(element){ + _V_.addListener(element, "click", this.onPlayButtonClick.context(this)); + },{ + onPlayButtonClick: function(event){ this.play(); } + } +); +// Pause +VideoJS.player.newBehavior("pauseButton", function(element){ + _V_.addListener(element, "click", this.onPauseButtonClick.context(this)); + },{ + onPauseButtonClick: function(event){ this.pause(); } + } +); +/* Play Progress Bar Behaviors +================================================================================ */ +VideoJS.player.newBehavior("playProgressBar", function(element){ + if (!this.playProgressBars) { + this.playProgressBars = []; + this.onCurrentTimeUpdate(this.updatePlayProgressBars); + } + this.playProgressBars.push(element); + },{ + // Ajust the play progress bar's width based on the current play time + updatePlayProgressBars: function(newTime){ + var progress = (newTime !== undefined) ? newTime / this.duration() : this.currentTime() / this.duration(); + if (isNaN(progress)) { progress = 0; } + this.each(this.playProgressBars, function(bar){ + if (bar.style) { bar.style.width = _V_.round(progress * 100, 2) + "%"; } + }); + } + } +); +/* Load Progress Bar Behaviors +================================================================================ */ +VideoJS.player.newBehavior("loadProgressBar", function(element){ + if (!this.loadProgressBars) { this.loadProgressBars = []; } + this.loadProgressBars.push(element); + this.onBufferedUpdate(this.updateLoadProgressBars); + },{ + updateLoadProgressBars: function(){ + this.each(this.loadProgressBars, function(bar){ + if (bar.style) { bar.style.width = _V_.round(this.bufferedPercent() * 100, 2) + "%"; } + }); + } + } +); + +/* Current Time Display Behaviors +================================================================================ */ +VideoJS.player.newBehavior("currentTimeDisplay", function(element){ + if (!this.currentTimeDisplays) { + this.currentTimeDisplays = []; + this.onCurrentTimeUpdate(this.updateCurrentTimeDisplays); + } + this.currentTimeDisplays.push(element); + },{ + // Update the displayed time (00:00) + updateCurrentTimeDisplays: function(newTime){ + if (!this.currentTimeDisplays) { return; } + // Allows for smooth scrubbing, when player can't keep up. + var time = (newTime) ? newTime : this.currentTime(); + this.each(this.currentTimeDisplays, function(dis){ + dis.innerHTML = _V_.formatTime(time); + }); + } + } +); + +/* Duration Display Behaviors +================================================================================ */ +VideoJS.player.newBehavior("durationDisplay", function(element){ + if (!this.durationDisplays) { + this.durationDisplays = []; + this.onCurrentTimeUpdate(this.updateDurationDisplays); + } + this.durationDisplays.push(element); + },{ + updateDurationDisplays: function(){ + if (!this.durationDisplays) { return; } + this.each(this.durationDisplays, function(dis){ + if (this.duration()) { dis.innerHTML = _V_.formatTime(this.duration()); } + }); + } + } +); + +/* Current Time Scrubber Behaviors +================================================================================ */ +VideoJS.player.newBehavior("currentTimeScrubber", function(element){ + _V_.addListener(element, "mousedown", this.onCurrentTimeScrubberMouseDown.rEvtContext(this)); + },{ + // Adjust the play position when the user drags on the progress bar + onCurrentTimeScrubberMouseDown: function(event, scrubber){ + event.preventDefault(); + this.currentScrubber = scrubber; + + this.stopTrackingCurrentTime(); // Allows for smooth scrubbing + + this.videoWasPlaying = !this.paused(); + this.pause(); + + _V_.blockTextSelection(); + this.setCurrentTimeWithScrubber(event); + _V_.addListener(document, "mousemove", this.onCurrentTimeScrubberMouseMove.rEvtContext(this)); + _V_.addListener(document, "mouseup", this.onCurrentTimeScrubberMouseUp.rEvtContext(this)); + }, + onCurrentTimeScrubberMouseMove: function(event){ // Removeable + this.setCurrentTimeWithScrubber(event); + }, + onCurrentTimeScrubberMouseUp: function(event){ // Removeable + _V_.unblockTextSelection(); + document.removeEventListener("mousemove", this.onCurrentTimeScrubberMouseMove, false); + document.removeEventListener("mouseup", this.onCurrentTimeScrubberMouseUp, false); + if (this.videoWasPlaying) { + this.play(); + this.trackCurrentTime(); + } + }, + setCurrentTimeWithScrubber: function(event){ + var newProgress = _V_.getRelativePosition(event.pageX, this.currentScrubber); + var newTime = newProgress * this.duration(); + this.triggerCurrentTimeListeners(0, newTime); // Allows for smooth scrubbing + // Don't let video end while scrubbing. + if (newTime == this.duration()) { newTime = newTime - 0.1; } + this.currentTime(newTime); + } + } +); +/* Volume Display Behaviors +================================================================================ */ +VideoJS.player.newBehavior("volumeDisplay", function(element){ + if (!this.volumeDisplays) { + this.volumeDisplays = []; + this.onVolumeChange(this.updateVolumeDisplays); + } + this.volumeDisplays.push(element); + this.updateVolumeDisplay(element); // Set the display to the initial volume + },{ + // Update the volume control display + // Unique to these default controls. Uses borders to create the look of bars. + updateVolumeDisplays: function(){ + if (!this.volumeDisplays) { return; } + this.each(this.volumeDisplays, function(dis){ + this.updateVolumeDisplay(dis); + }); + }, + updateVolumeDisplay: function(display){ + var volNum = Math.ceil(this.volume() * 6); + this.each(display.children, function(child, num){ + if (num < volNum) { + _V_.addClass(child, "vjs-volume-level-on"); + } else { + _V_.removeClass(child, "vjs-volume-level-on"); + } + }); + } + } +); +/* Volume Scrubber Behaviors +================================================================================ */ +VideoJS.player.newBehavior("volumeScrubber", function(element){ + _V_.addListener(element, "mousedown", this.onVolumeScrubberMouseDown.rEvtContext(this)); + },{ + // Adjust the volume when the user drags on the volume control + onVolumeScrubberMouseDown: function(event, scrubber){ + // event.preventDefault(); + _V_.blockTextSelection(); + this.currentScrubber = scrubber; + this.setVolumeWithScrubber(event); + _V_.addListener(document, "mousemove", this.onVolumeScrubberMouseMove.rEvtContext(this)); + _V_.addListener(document, "mouseup", this.onVolumeScrubberMouseUp.rEvtContext(this)); + }, + onVolumeScrubberMouseMove: function(event){ + this.setVolumeWithScrubber(event); + }, + onVolumeScrubberMouseUp: function(event){ + this.setVolumeWithScrubber(event); + _V_.unblockTextSelection(); + document.removeEventListener("mousemove", this.onVolumeScrubberMouseMove, false); + document.removeEventListener("mouseup", this.onVolumeScrubberMouseUp, false); + }, + setVolumeWithScrubber: function(event){ + var newVol = _V_.getRelativePosition(event.pageX, this.currentScrubber); + this.volume(newVol); + } + } +); +/* Fullscreen Toggle Behaviors +================================================================================ */ +VideoJS.player.newBehavior("fullscreenToggle", function(element){ + _V_.addListener(element, "click", this.onFullscreenToggleClick.context(this)); + },{ + // When the user clicks on the fullscreen button, update fullscreen setting + onFullscreenToggleClick: function(event){ + if (!this.videoIsFullScreen) { + this.enterFullScreen(); + } else { + this.exitFullScreen(); + } + }, + + fullscreenOnWindowResize: function(event){ // Removeable + this.positionControlBars(); + }, + // Create listener for esc key while in full screen mode + fullscreenOnEscKey: function(event){ // Removeable + if (event.keyCode == 27) { + this.exitFullScreen(); + } + } + } +); +/* Big Play Button Behaviors +================================================================================ */ +VideoJS.player.newBehavior("bigPlayButton", function(element){ + if (!this.elements.bigPlayButtons) { + this.elements.bigPlayButtons = []; + this.onPlay(this.bigPlayButtonsOnPlay); + this.onEnded(this.bigPlayButtonsOnEnded); + } + this.elements.bigPlayButtons.push(element); + this.activateElement(element, "playButton"); + },{ + bigPlayButtonsOnPlay: function(event){ this.hideBigPlayButtons(); }, + bigPlayButtonsOnEnded: function(event){ this.showBigPlayButtons(); }, + showBigPlayButtons: function(){ + this.each(this.elements.bigPlayButtons, function(element){ + element.style.display = "block"; + }); + }, + hideBigPlayButtons: function(){ + this.each(this.elements.bigPlayButtons, function(element){ + element.style.display = "none"; + }); + } + } +); +/* Spinner +================================================================================ */ +VideoJS.player.newBehavior("spinner", function(element){ + if (!this.spinners) { + this.spinners = []; + _V_.addListener(this.video, "loadeddata", this.spinnersOnVideoLoadedData.context(this)); + _V_.addListener(this.video, "loadstart", this.spinnersOnVideoLoadStart.context(this)); + _V_.addListener(this.video, "seeking", this.spinnersOnVideoSeeking.context(this)); + _V_.addListener(this.video, "seeked", this.spinnersOnVideoSeeked.context(this)); + _V_.addListener(this.video, "canplay", this.spinnersOnVideoCanPlay.context(this)); + _V_.addListener(this.video, "canplaythrough", this.spinnersOnVideoCanPlayThrough.context(this)); + _V_.addListener(this.video, "waiting", this.spinnersOnVideoWaiting.context(this)); + _V_.addListener(this.video, "stalled", this.spinnersOnVideoStalled.context(this)); + _V_.addListener(this.video, "suspend", this.spinnersOnVideoSuspend.context(this)); + _V_.addListener(this.video, "playing", this.spinnersOnVideoPlaying.context(this)); + _V_.addListener(this.video, "timeupdate", this.spinnersOnVideoTimeUpdate.context(this)); + } + this.spinners.push(element); + },{ + showSpinners: function(){ + this.each(this.spinners, function(spinner){ + spinner.style.display = "block"; + }); + clearInterval(this.spinnerInterval); + this.spinnerInterval = setInterval(this.rotateSpinners.context(this), 100); + }, + hideSpinners: function(){ + this.each(this.spinners, function(spinner){ + spinner.style.display = "none"; + }); + clearInterval(this.spinnerInterval); + }, + spinnersRotated: 0, + rotateSpinners: function(){ + this.each(this.spinners, function(spinner){ + // spinner.style.transform = 'scale(0.5) rotate('+this.spinnersRotated+'deg)'; + spinner.style.WebkitTransform = 'scale(0.5) rotate('+this.spinnersRotated+'deg)'; + spinner.style.MozTransform = 'scale(0.5) rotate('+this.spinnersRotated+'deg)'; + }); + if (this.spinnersRotated == 360) { this.spinnersRotated = 0; } + this.spinnersRotated += 45; + }, + spinnersOnVideoLoadedData: function(event){ this.hideSpinners(); }, + spinnersOnVideoLoadStart: function(event){ this.showSpinners(); }, + spinnersOnVideoSeeking: function(event){ /* this.showSpinners(); */ }, + spinnersOnVideoSeeked: function(event){ /* this.hideSpinners(); */ }, + spinnersOnVideoCanPlay: function(event){ /* this.hideSpinners(); */ }, + spinnersOnVideoCanPlayThrough: function(event){ this.hideSpinners(); }, + spinnersOnVideoWaiting: function(event){ + // Safari sometimes triggers waiting inappropriately + // Like after video has played, any you play again. + this.showSpinners(); + }, + spinnersOnVideoStalled: function(event){}, + spinnersOnVideoSuspend: function(event){}, + spinnersOnVideoPlaying: function(event){ this.hideSpinners(); }, + spinnersOnVideoTimeUpdate: function(event){ + // Safari sometimes calls waiting and doesn't recover + if(this.spinner.style.display == "block") { this.hideSpinners(); } + } + } +); +/* Subtitles +================================================================================ */ +VideoJS.player.newBehavior("subtitlesDisplay", function(element){ + if (!this.subtitleDisplays) { + this.subtitleDisplays = []; + this.onCurrentTimeUpdate(this.subtitleDisplaysOnVideoTimeUpdate); + this.onEnded(function() { this.lastSubtitleIndex = 0; }.context(this)); + } + this.subtitleDisplays.push(element); + },{ + subtitleDisplaysOnVideoTimeUpdate: function(time){ + // Assuming all subtitles are in order by time, and do not overlap + if (this.subtitles) { + // If current subtitle should stay showing, don't do anything. Otherwise, find new subtitle. + if (!this.currentSubtitle || this.currentSubtitle.start >= time || this.currentSubtitle.end < time) { + var newSubIndex = false, + // Loop in reverse if lastSubtitle is after current time (optimization) + // Meaning the user is scrubbing in reverse or rewinding + reverse = (this.subtitles[this.lastSubtitleIndex].start > time), + // If reverse, step back 1 becase we know it's not the lastSubtitle + i = this.lastSubtitleIndex - (reverse) ? 1 : 0; + while (true) { // Loop until broken + if (reverse) { // Looping in reverse + // Stop if no more, or this subtitle ends before the current time (no earlier subtitles should apply) + if (i < 0 || this.subtitles[i].end < time) { break; } + // End is greater than time, so if start is less, show this subtitle + if (this.subtitles[i].start < time) { + newSubIndex = i; + break; + } + i--; + } else { // Looping forward + // Stop if no more, or this subtitle starts after time (no later subtitles should apply) + if (i >= this.subtitles.length || this.subtitles[i].start > time) { break; } + // Start is less than time, so if end is later, show this subtitle + if (this.subtitles[i].end > time) { + newSubIndex = i; + break; + } + i++; + } + } + + // Set or clear current subtitle + if (newSubIndex !== false) { + this.currentSubtitle = this.subtitles[newSubIndex]; + this.lastSubtitleIndex = newSubIndex; + this.updateSubtitleDisplays(this.currentSubtitle.text); + } else if (this.currentSubtitle) { + this.currentSubtitle = false; + this.updateSubtitleDisplays(""); + } + } + } + }, + updateSubtitleDisplays: function(val){ + this.each(this.subtitleDisplays, function(disp){ + disp.innerHTML = val; + }); + } + } +); + +//////////////////////////////////////////////////////////////////////////////// +// Convenience Functions (mini library) +// Functions not specific to video or VideoJS and could probably be replaced with a library like jQuery +//////////////////////////////////////////////////////////////////////////////// + +VideoJS.extend({ + + addClass: function(element, classToAdd){ + if ((" "+element.className+" ").indexOf(" "+classToAdd+" ") == -1) { + element.className = element.className === "" ? classToAdd : element.className + " " + classToAdd; + } + }, + removeClass: function(element, classToRemove){ + if (element.className.indexOf(classToRemove) == -1) { return; } + var classNames = element.className.split(/\s+/); + classNames.splice(classNames.lastIndexOf(classToRemove),1); + element.className = classNames.join(" "); + }, + createElement: function(tagName, attributes){ + return this.merge(document.createElement(tagName), attributes); + }, + + // Attempt to block the ability to select text while dragging controls + blockTextSelection: function(){ + document.body.focus(); + document.onselectstart = function () { return false; }; + }, + // Turn off text selection blocking + unblockTextSelection: function(){ document.onselectstart = function () { return true; }; }, + + // Return seconds as MM:SS + formatTime: function(secs) { + var seconds = Math.round(secs); + var minutes = Math.floor(seconds / 60); + minutes = (minutes >= 10) ? minutes : "0" + minutes; + seconds = Math.floor(seconds % 60); + seconds = (seconds >= 10) ? seconds : "0" + seconds; + return minutes + ":" + seconds; + }, + + // Return the relative horizonal position of an event as a value from 0-1 + getRelativePosition: function(x, relativeElement){ + return Math.max(0, Math.min(1, (x - this.findPosX(relativeElement)) / relativeElement.offsetWidth)); + }, + // Get an objects position on the page + findPosX: function(obj) { + var curleft = obj.offsetLeft; + while(obj = obj.offsetParent) { + curleft += obj.offsetLeft; + } + return curleft; + }, + getComputedStyleValue: function(element, style){ + return window.getComputedStyle(element, null).getPropertyValue(style); + }, + + round: function(num, dec) { + if (!dec) { dec = 0; } + return Math.round(num*Math.pow(10,dec))/Math.pow(10,dec); + }, + + addListener: function(element, type, handler){ + if (element.addEventListener) { + element.addEventListener(type, handler, false); + } else if (element.attachEvent) { + element.attachEvent("on"+type, handler); + } + }, + removeListener: function(element, type, handler){ + if (element.removeEventListener) { + element.removeEventListener(type, handler, false); + } else if (element.attachEvent) { + element.detachEvent("on"+type, handler); + } + }, + + get: function(url, onSuccess){ + if (typeof XMLHttpRequest == "undefined") { + XMLHttpRequest = function () { + try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) {} + try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (f) {} + try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (g) {} + //Microsoft.XMLHTTP points to Msxml2.XMLHTTP.3.0 and is redundant + throw new Error("This browser does not support XMLHttpRequest."); + }; + } + var request = new XMLHttpRequest(); + request.open("GET",url); + request.onreadystatechange = function() { + if (request.readyState == 4 && request.status == 200) { + onSuccess(request.responseText); + } + }.context(this); + request.send(); + }, + + trim: function(string){ return string.toString().replace(/^\s+/, "").replace(/\s+$/, ""); }, + + // DOM Ready functionality adapted from jQuery. http://jquery.com/ + bindDOMReady: function(){ + if (document.readyState === "complete") { + return VideoJS.onDOMReady(); + } + if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", VideoJS.DOMContentLoaded, false); + window.addEventListener("load", VideoJS.onDOMReady, false); + } else if (document.attachEvent) { + document.attachEvent("onreadystatechange", VideoJS.DOMContentLoaded); + window.attachEvent("onload", VideoJS.onDOMReady); + } + }, + + DOMContentLoaded: function(){ + if (document.addEventListener) { + document.removeEventListener( "DOMContentLoaded", VideoJS.DOMContentLoaded, false); + VideoJS.onDOMReady(); + } else if ( document.attachEvent ) { + if ( document.readyState === "complete" ) { + document.detachEvent("onreadystatechange", VideoJS.DOMContentLoaded); + VideoJS.onDOMReady(); + } + } + }, + + // Functions to be run once the DOM is loaded + DOMReadyList: [], + addToDOMReady: function(fn){ + if (VideoJS.DOMIsReady) { + fn.call(document); + } else { + VideoJS.DOMReadyList.push(fn); + } + }, + + DOMIsReady: false, + onDOMReady: function(){ + if (VideoJS.DOMIsReady) { return; } + if (!document.body) { return setTimeout(VideoJS.onDOMReady, 13); } + VideoJS.DOMIsReady = true; + if (VideoJS.DOMReadyList) { + for (var i=0; i<VideoJS.DOMReadyList.length; i++) { + VideoJS.DOMReadyList[i].call(document); + } + VideoJS.DOMReadyList = null; + } + } +}); +VideoJS.bindDOMReady(); + +// Allows for binding context to functions +// when using in event listeners and timeouts +Function.prototype.context = function(obj){ + var method = this, + temp = function(){ + return method.apply(obj, arguments); + }; + return temp; +}; + +// Like context, in that it creates a closure +// But insteaad keep "this" intact, and passes the var as the second argument of the function +// Need for event listeners where you need to know what called the event +// Only use with event callbacks +Function.prototype.evtContext = function(obj){ + var method = this, + temp = function(){ + var origContext = this; + return method.call(obj, arguments[0], origContext); + }; + return temp; +}; + +// Removeable Event listener with Context +// Replaces the original function with a version that has context +// So it can be removed using the original function name. +// In order to work, a version of the function must already exist in the player/prototype +Function.prototype.rEvtContext = function(obj, funcParent){ + if (this.hasContext === true) { return this; } + if (!funcParent) { funcParent = obj; } + for (var attrname in funcParent) { + if (funcParent[attrname] == this) { + funcParent[attrname] = this.evtContext(obj); + funcParent[attrname].hasContext = true; + return funcParent[attrname]; + } + } + return this.evtContext(obj); +}; + +// jQuery Plugin +if (window.jQuery) { + (function($) { + $.fn.VideoJS = function(options) { + this.each(function() { + VideoJS.setup(this, options); + }); + return this; + }; + $.fn.player = function() { + return this[0].player; + }; + })(jQuery); +} + + +// Expose to global +window.VideoJS = window._V_ = VideoJS; + +// End self-executing function +})(window); \ No newline at end of file diff --git a/typo3/sysext/cms/flexform_media.xml b/typo3/sysext/cms/flexform_media.xml index f2da19abb112183f92c2b4599be5dfaa3d316f32..61df57615001457a5a45ca719cfbfd8dbdb71ed1 100644 --- a/typo3/sysext/cms/flexform_media.xml +++ b/typo3/sysext/cms/flexform_media.xml @@ -11,13 +11,73 @@ </TCEforms> <type>array</type> <el> + <mmType> + <TCEforms> + <label>LLL:EXT:cms/locallang_ttc.xml:media.type</label> + <config> + <type>select</type> + <items> + <numIndex index="0"> + <numIndex index="0">LLL:EXT:cms/locallang_ttc.xml:media.type.video</numIndex> + <numIndex index="1">video</numIndex> + </numIndex> + <numIndex index="1"> + <numIndex index="0">LLL:EXT:cms/locallang_ttc.xml:media.type.audio</numIndex> + <numIndex index="1">audio</numIndex> + </numIndex> + </items> + </config> + </TCEforms> + </mmType> + <mmSources> + <tx_templavoila> + <title>LLL:EXT:cms/locallang_ttc.xml:media.sources</title> + </tx_templavoila> + <type>array</type> + <section>1</section> + <el> + <mmSourcesContainer> + <type>array</type> + <tx_templavoila> + <title>LLL:EXT:cms/locallang_ttc.xml:media.media.url</title> + </tx_templavoila> + <el> + <mmSource> + <TCEforms> + <label>LLL:EXT:cms/locallang_ttc.xml:media.url</label> + <config> + <type>input</type> + <size>60</size> + <eval>trim,required</eval> + <default></default> + <wizards type="array"> + <_PADDING>2</_PADDING> + <link type="array"> + <type>popup</type> + <title>LLL:EXT:cms/locallang_ttc.xml:media.browseUrlTitle</title> + <icon>link_popup.gif</icon> + <script>browse_links.php?mode=wizard&act=file|url</script> + <params type="array"> + <blindLinkOptions>page,folder,mail,spec</blindLinkOptions> + <allowedExtensions>asf,avi,class,dcr,flv,mov,mpg,mp4,m4a,m4v,ogg,ogv,swf,webm</allowedExtensions> + </params> + <JSopenParams>height=300,width=500,status=0,menubar=0,scrollbars=1</JSopenParams> + </link> + </wizards> + </config> + </TCEforms> + </mmSource> + </el> + </mmSourcesContainer> + </el> + </mmSources> <mmFile> <TCEforms> - <label>LLL:EXT:cms/locallang_ttc.xml:media.url</label> + <label>LLL:EXT:cms/locallang_ttc.xml:media.fallbackUrl</label> <config> <type>input</type> <size>60</size> - <eval>trim</eval> + <eval>trim,required</eval> <default></default> <wizards type="array"> <_PADDING>2</_PADDING> @@ -28,7 +88,7 @@ <script>browse_links.php?mode=wizard&act=file|url</script> <params type="array"> <blindLinkOptions>page,folder,mail,spec</blindLinkOptions> - <allowedExtensions>class,swf,swa,dcr,wav,avi,au,mov,asf,mpg,wmv,mp3,mp4,m4v,m4a,flv</allowedExtensions> + <allowedExtensions>class,swa,dcr,wav,avi,au,mov,asf,mpg,wmv,mp3,mp4,m4v,m4a,flv,ogg,ogv,swf,webm</allowedExtensions> </params> <JSopenParams>height=300,width=500,status=0,menubar=0,scrollbars=1</JSopenParams> </link> @@ -36,39 +96,98 @@ </config> </TCEforms> </mmFile> - <mmforcePlayer> + <mmCaption> <TCEforms> - <label>LLL:EXT:cms/locallang_ttc.xml:media.forcePlayer</label> + <label>LLL:EXT:cms/locallang_ttc.xml:media.captionUrl</label> <config> - <type>check</type> - <default>1</default> - <items type="array"> - <numIndex index="1" type="array"> - <numIndex index="0">LLL:EXT:lang/locallang_core.xml:labels.enabled</numIndex> - <numIndex index="1">1</numIndex> - </numIndex> - </items> + <type>input</type> + <size>60</size> + <eval>trim</eval> + <default></default> + <wizards type="array"> + <_PADDING>2</_PADDING> + <link type="array"> + <type>popup</type> + <title>LLL:EXT:cms/locallang_ttc.xml:media.browseUrlTitle</title> + <icon>link_popup.gif</icon> + <script>browse_links.php?mode=wizard&act=file|url</script> + <params type="array"> + <blindLinkOptions>page,folder,mail,spec</blindLinkOptions> + <allowedExtensions>srt</allowedExtensions> + </params> + <JSopenParams>height=300,width=500,status=0,menubar=0,scrollbars=1</JSopenParams> + </link> + </wizards> </config> </TCEforms> - </mmforcePlayer> - <mmType> + </mmCaption> + <mmAudioSources> + <tx_templavoila> + <title>LLL:EXT:cms/locallang_ttc.xml:media.audioSources</title> + </tx_templavoila> + <type>array</type> + <section>1</section> + <el> + <mmAudioSourcesContainer> + <type>array</type> + <tx_templavoila> + <title>LLL:EXT:cms/locallang_ttc.xml:media.media.url</title> + </tx_templavoila> + <el> + <mmAudioSource> + <TCEforms> + <label>LLL:EXT:cms/locallang_ttc.xml:media.url</label> + <config> + <type>input</type> + <size>60</size> + <eval>trim,required</eval> + <default></default> + <wizards type="array"> + <_PADDING>2</_PADDING> + <link type="array"> + <type>popup</type> + <title>LLL:EXT:cms/locallang_ttc.xml:media.browseUrlTitle</title> + <icon>link_popup.gif</icon> + <script>browse_links.php?mode=wizard&act=file|url</script> + <params type="array"> + <blindLinkOptions>page,folder,mail,spec</blindLinkOptions> + <allowedExtensions>au,asf,mp3,m4a,oga,ogg, wav,webm,wmv</allowedExtensions> + </params> + <JSopenParams>height=300,width=500,status=0,menubar=0,scrollbars=1</JSopenParams> + </link> + </wizards> + </config> + </TCEforms> + </mmAudioSource> + </el> + </mmAudioSourcesContainer> + </el> + </mmAudioSources> + <mmAudioFallback> <TCEforms> - <label>LLL:EXT:cms/locallang_ttc.xml:media.type</label> + <label>LLL:EXT:cms/locallang_ttc.xml:media.audioFallbackUrl</label> <config> - <type>select</type> - <items> - <numIndex index="0"> - <numIndex index="0">LLL:EXT:cms/locallang_ttc.xml:media.type.video</numIndex> - <numIndex index="1">video</numIndex> - </numIndex> - <numIndex index="1"> - <numIndex index="0">LLL:EXT:cms/locallang_ttc.xml:media.type.audio</numIndex> - <numIndex index="1">audio</numIndex> - </numIndex> - </items> + <type>input</type> + <size>60</size> + <eval>trim</eval> + <default></default> + <wizards type="array"> + <_PADDING>2</_PADDING> + <link type="array"> + <type>popup</type> + <title>LLL:EXT:cms/locallang_ttc.xml:media.browseUrlTitle</title> + <icon>link_popup.gif</icon> + <script>browse_links.php?mode=wizard&act=file|url</script> + <params type="array"> + <blindLinkOptions>page,folder,mail,spec</blindLinkOptions> + <allowedExtensions>au,asf,mp3,m4a,oga,swa,wav,webm,wmv</allowedExtensions> + </params> + <JSopenParams>height=300,width=500,status=0,menubar=0,scrollbars=1</JSopenParams> + </link> + </wizards> </config> </TCEforms> - </mmType> + </mmAudioFallback> <mmWidth> <TCEforms> <label>LLL:EXT:cms/locallang_ttc.xml:media.width</label> @@ -98,12 +217,12 @@ <type>select</type> <items> <numIndex index="0"> - <numIndex index="0">LLL:EXT:cms/locallang_ttc.xml:media.renderType.auto</numIndex> + <numIndex index="0">LLL:EXT:cms/locallang_ttc.xml:media.renderType.preferHtml5OverFlash</numIndex> <numIndex index="1">auto</numIndex> </numIndex> <numIndex index="1"> - <numIndex index="0">LLL:EXT:cms/locallang_ttc.xml:media.renderType.swf</numIndex> - <numIndex index="1">swf</numIndex> + <numIndex index="0">LLL:EXT:cms/locallang_ttc.xml:media.renderType.preferFlashOverHtml5</numIndex> + <numIndex index="1">preferFlashOverHtml5</numIndex> </numIndex> <numIndex index="2"> <numIndex index="0">LLL:EXT:cms/locallang_ttc.xml:media.renderType.qt</numIndex> @@ -161,6 +280,26 @@ <numIndex index="0">LLL:EXT:cms/locallang_ttc.xml:media.params.allowFullScreen</numIndex> <numIndex index="1">allowFullScreen</numIndex> </numIndex> + <numIndex index="6"> + <numIndex index="0">LLL:EXT:cms/locallang_ttc.xml:media.params.preload</numIndex> + <numIndex index="1">preload</numIndex> + </numIndex> + <numIndex index="7"> + <numIndex index="0">LLL:EXT:cms/locallang_ttc.xml:media.params.controlsBelow</numIndex> + <numIndex index="1">controlsBelow</numIndex> + </numIndex> + <numIndex index="8"> + <numIndex index="0">LLL:EXT:cms/locallang_ttc.xml:media.params.controlsAtStart</numIndex> + <numIndex index="1">controlsAtStart</numIndex> + </numIndex> + <numIndex index="9"> + <numIndex index="0">LLL:EXT:cms/locallang_ttc.xml:media.params.controlsHiding</numIndex> + <numIndex index="1">controlsHiding</numIndex> + </numIndex> + <numIndex index="10"> + <numIndex index="0">LLL:EXT:cms/locallang_ttc.xml:media.params.defaultVolume</numIndex> + <numIndex index="1">defaultVolume</numIndex> + </numIndex> </items> <itemsProcFunc>tx_cms_mediaItems->customMediaParams</itemsProcFunc> </config> diff --git a/typo3/sysext/cms/locallang_ttc.xlf b/typo3/sysext/cms/locallang_ttc.xlf index 217bea84554c3c2652287403a9e07490745bab6b..f8f065e33a557c2af503eb662f83ae475fbe531b 100644 --- a/typo3/sysext/cms/locallang_ttc.xlf +++ b/typo3/sysext/cms/locallang_ttc.xlf @@ -828,6 +828,21 @@ <trans-unit id="media.url" xml:space="preserve"> <source>Path or URL</source> </trans-unit> + <trans-unit id="media.fallbackUrl" xml:space="preserve"> + <source>Path or URL to fallback video source (Flash or QuickTime)</source> + </trans-unit> + <trans-unit id="media.sources" xml:space="preserve"> + <source>Video sources</source> + </trans-unit> + <trans-unit id="media.captionUrl" xml:space="preserve"> + <source>Path or URL to captions file</source> + </trans-unit> + <trans-unit id="media.audioSources" xml:space="preserve"> + <source>Audio sources</source> + </trans-unit> + <trans-unit id="media.audioFallbackUrl" xml:space="preserve"> + <source>Path or URL to fallback audio source (Flash or QuickTime)</source> + </trans-unit> <trans-unit id="media.browseUrlTitle" xml:space="preserve"> <source>Select File or URL</source> </trans-unit> @@ -858,6 +873,12 @@ <trans-unit id="media.renderType.swf" xml:space="preserve"> <source>Flash Browser Plugin</source> </trans-unit> + <trans-unit id="media.renderType.preferHtml5OverFlash" xml:space="preserve"> + <source>HTML5 video/audio tag with fallback to Flash</source> + </trans-unit> + <trans-unit id="media.renderType.preferFlashOverHtml5" xml:space="preserve"> + <source>Flash with fallback to HTML5 video/audio tag</source> + </trans-unit> <trans-unit id="media.renderType.qt" xml:space="preserve"> <source>QuickTime Browser Plugin</source> </trans-unit> @@ -909,6 +930,21 @@ <trans-unit id="media.params.allowFullScreen" xml:space="preserve"> <source>Allow Fullscreen</source> </trans-unit> + <trans-unit id="media.params.preload" xml:space="preserve"> + <source>Preload media</source> + </trans-unit> + <trans-unit id="media.params.controlsBelow" xml:space="preserve"> + <source>Display controls below video</source> + </trans-unit> + <trans-unit id="media.params.controlsAtStart" xml:space="preserve"> + <source>Make controls visible when page loads</source> + </trans-unit> + <trans-unit id="media.params.controlsHiding" xml:space="preserve"> + <source>Hide controls when not over the video</source> + </trans-unit> + <trans-unit id="media.params.defaultVolume" xml:space="preserve"> + <source>Default volume</source> + </trans-unit> <trans-unit id="media.alternativeContent" xml:space="preserve"> <source>Alternative Content</source> </trans-unit> @@ -921,6 +957,12 @@ <trans-unit id="media.noFile" xml:space="preserve"> <source>ERROR: Missing URL or File!</source> </trans-unit> + <trans-unit id="media.needFlashPlugin" xml:space="preserve"> + <source>You need a Flash plugin to view this content.</source> + </trans-unit> + <trans-unit id="media.downloadFlash" xml:space="preserve"> + <source>Click here to download the latest version.</source> + </trans-unit> <trans-unit id="sys_language_uid_formlabel" xml:space="preserve"> <source>Language</source> </trans-unit> diff --git a/typo3/sysext/cms/tslib/content/class.tslib_content_media.php b/typo3/sysext/cms/tslib/content/class.tslib_content_media.php index e7cf96f79aafa85bbdf5a0080910ef4b915e23f3..a7a194f2982dca7ff7b19e92fb226e5312770891 100644 --- a/typo3/sysext/cms/tslib/content/class.tslib_content_media.php +++ b/typo3/sysext/cms/tslib/content/class.tslib_content_media.php @@ -42,103 +42,213 @@ class tslib_content_Media extends tslib_content_Abstract { */ public function render($conf = array()) { $content = ''; + // Add flex parameters to configuration $flexParams = isset($conf['flexParams.']) ? $this->cObj->stdWrap($conf['flexParams'], $conf['flexParams.']) : $conf['flexParams']; if (substr($flexParams, 0, 1) === '<') { - // it is a content element + // It is a content element rather a TS object $this->cObj->readFlexformIntoConf($flexParams, $conf['parameter.']); - $url = isset($conf['file.']) - ? $this->cObj->stdWrap($conf['parameter.']['mmFile'], $conf['file.']) - : $conf['parameter.']['mmFile']; - $mmFile = $url; + } + // Type is video or audio + $mmType = isset($conf['parameter.']['mmType.']) + ? $this->cObj->stdWrap($conf['parameter.']['mmType'], $conf['parameter.']['mmType.']) + : $conf['parameter.']['mmType']; + $type = isset($conf['type.']) + ? $this->cObj->stdWrap($conf['type'], $conf['type.']) + : $conf['type']; + $conf['type'] = $mmType ? $mmType : $type; + + // Video sources + $sources = isset($conf['sources.']) + ? $this->cObj->stdWrap($conf['sources'], $conf['sources.']) + : $conf['sources']; + $mmSources = isset($conf['parameter.']['mmSources.']['mmSourcesContainer.']) + ? $this->cObj->stdWrap($conf['parameter.']['mmSources.']['mmSourcesContainer'], $conf['parameter.']['mmSources.']['mmSourcesContainer.']) + : $conf['parameter.']['mmSources']['mmSourcesContainer']; + $sources = $mmSources ? $mmSources : $sources; + if (is_array($sources) && count($sources)) { + $conf['sources'] = array(); + foreach ($sources as $key => $source) { + if (isset($source['mmSource'])) { + $source = $source['mmSource']; + if (is_file(PATH_site . $source)) { + $conf['sources'][$key] = $GLOBALS['TSFE']->tmpl->getFileName($source); + } else { + // Use media wizard to extract file from URL + $mediaWizard = tslib_mediaWizardManager::getValidMediaWizardProvider($source); + if ($mediaWizard !== NULL) { + $source = $mediaWizard->rewriteUrl($source); + } + $conf['sources'][$key] = $this->cObj->typoLink_URL(array( + 'parameter' => $source + )); + } + } + } + } else { - // it is a TS object - $url = isset($conf['file.']) - ? $this->cObj->stdWrap($conf['file'], $conf['file.']) - : $conf['file']; + unset($conf['sources']); + } + // Video fallback and backward compatibility file + $videoFallback = isset($conf['file.']) + ? $this->cObj->stdWrap($conf['file'], $conf['file.']) + : $conf['file']; + $mmVideoFallback = isset($conf['parameter.']['mmFile.']) + ? $this->cObj->stdWrap($conf['parameter.']['mmFile'], $conf['parameter.']['mmFile.']) + : $conf['parameter.']['mmFile']; + $videoFallback = $mmVideoFallback ? $mmVideoFallback : $videoFallback; + // Backward compatibility file + $url = $videoFallback; + if ($videoFallback) { + if (is_file(PATH_site . $videoFallback)) { + $conf['file'] = $GLOBALS['TSFE']->tmpl->getFileName($videoFallback); + } else { + // Use media wizard to extract file from URL + $mediaWizard = tslib_mediaWizardManager::getValidMediaWizardProvider($videoFallback); + if ($mediaWizard !== NULL) { + $videoFallback = $mediaWizard->rewriteUrl($videoFallback); + } + $conf['file'] = $this->cObj->typoLink_URL(array( + 'parameter' => $videoFallback + )); + } + } else { + unset($conf['file']); } - $mode = is_file(PATH_site . $url) ? 'file' : 'url'; - if ($mode === 'file') { - // render FILE - $filename = $GLOBALS['TSFE']->tmpl->getFileName($url); - $fileinfo = t3lib_div::split_fileref($filename); - $conf['file'] = $filename; + // Audio sources + $audioSources = isset($conf['audioSources.']) + ? $this->cObj->stdWrap($conf['audioSources'], $conf['audioSources.']) + : $conf['audioSources']; + $mmAudioSources = isset($conf['parameter.']['mmAudioSources.']['mmAudioSourcesContainer.']) + ? $this->cObj->stdWrap($conf['parameter.']['mmAudioSources.']['mmAudioSourcesContainer'], $conf['parameter.']['mmAudioSources.']['mmAudioSourcesContainer.']) + : $conf['parameter.']['mmAudioSources']['mmAudioSourcesContainer']; + $audioSources = $mmAudioSources ? $mmAudioSources : $audioSources; + if (is_array($audioSources) && count($audioSources)) { + $conf['audioSources'] = array(); + foreach ($audioSources as $key => $source) { + if (isset($source['mmAudioSource'])) { + $source = $source['mmAudioSource']; + if (is_file(PATH_site . $source)) { + $conf['audioSources'][$key] = $GLOBALS['TSFE']->tmpl->getFileName($source); + } else { + // Use media wizard to extract file from URL + $mediaWizard = tslib_mediaWizardManager::getValidMediaWizardProvider($source); + if ($mediaWizard !== NULL) { + $source = $mediaWizard->rewriteUrl($source); + } + $conf['audioSources'][$key] = $this->cObj->typoLink_URL(array( + 'parameter' => $source + )); + } + } + } + } else { - // render URL - // use media wizard to extract video from URL - $mediaWizard = tslib_mediaWizardManager::getValidMediaWizardProvider($url); - if ($mediaWizard !== NULL) { - $url = $mediaWizard->rewriteUrl($url); + unset($conf['audioSources']); + } + + // Audio fallback + $audioFallback = isset($conf['audioFallback.']) + ? $this->cObj->stdWrap($conf['audioFallback'], $conf['audioFallback.']) + : $conf['audioFallback']; + $mmAudioFallback = isset($conf['parameter.']['mmAudioFallback.']) + ? $this->cObj->stdWrap($conf['parameter.']['mmAudioFallback'], $conf['parameter.']['mmAudioFallback.']) + : $conf['parameter.']['mmAudioFallback']; + $audioFallback = $mmAudioFallback ? $mmAudioFallback : $audioFallback; + if ($audioFallback) { + if (is_file(PATH_site . $audioFallback)) { + $conf['audioFallback'] = $GLOBALS['TSFE']->tmpl->getFileName($audioFallback); + } else { + // Use media wizard to extract file from URL + $mediaWizard = tslib_mediaWizardManager::getValidMediaWizardProvider($audioFallback); + if ($mediaWizard !== NULL) { + $audioFallback = $mediaWizard->rewriteUrl($audioFallback); + } + $conf['audioFallback'] = $this->cObj->typoLink_URL(array( + 'parameter' => $audioFallback + )); } - $conf['file'] = $this->cObj->typoLink_URL(array( - 'parameter' => $url - )); + } else { + unset($conf['audioFallback']); + } + // Backward compatibility + if ($conf['type'] === 'audio' && !isset($conf['audioFallback'])) { + $conf['audioFallback'] = $conf['file']; } + // Caption file + $caption = isset($conf['caption.']) + ? $this->cObj->stdWrap($conf['caption'], $conf['caption.']) + : $conf['caption']; + $mmCaption = isset($conf['parameter.']['mmCaption.']) + ? $this->cObj->stdWrap($conf['parameter.']['mmCaption'], $conf['parameter.']['mmCaption.']) + : $conf['parameter.']['mmCaption']; + $caption = $mmCaption ? $mmCaption : $caption; + if ($caption) { + if (is_file(PATH_site . $caption)) { + $conf['caption'] = $GLOBALS['TSFE']->tmpl->getFileName($caption); + } else { + // Use media wizard to extract file from URL + $mediaWizard = tslib_mediaWizardManager::getValidMediaWizardProvider($caption); + if ($mediaWizard !== NULL) { + $caption = $mediaWizard->rewriteUrl($caption); + } + $conf['caption'] = $this->cObj->typoLink_URL(array( + 'parameter' => $caption + )); + } + } else { + unset($conf['caption']); + } + // Establish render type $renderType = isset($conf['renderType.']) ? $this->cObj->stdWrap($conf['renderType'], $conf['renderType.']) : $conf['renderType']; $mmRenderType = isset($conf['parameter.']['mmRenderType.']) ? $this->cObj->stdWrap($conf['parameter.']['mmRenderType'], $conf['parameter.']['mmRenderType.']) : $conf['parameter.']['mmRenderType']; - if ($mmRenderType) { - $renderType = $mmRenderType; + $renderType = $mmRenderType ? $mmRenderType : $renderType; + if ($renderType === 'preferFlashOverHtml5') { + $conf['preferFlashOverHtml5'] = 1; + $renderType = 'auto'; } if ($renderType === 'auto') { - // default renderType is swf + // Default renderType is swf $renderType = 'swf'; $handler = array_keys($conf['fileExtHandler.']); + if ($conf['type'] === 'video') { + $fileinfo = t3lib_div::split_fileref($conf['file']); + } else { + $fileinfo = t3lib_div::split_fileref($conf['audioFallback']); + } if (in_array($fileinfo['fileext'], $handler)) { $renderType = strtolower($conf['fileExtHandler.'][$fileinfo['fileext']]); } } - $mmForcePlayer = isset($conf['parameter.']['mmforcePlayer.']) - ? $this->cObj->stdWrap($conf['parameter.']['mmforcePlayer'], $conf['parameter.']['mmforcePlayer.']) - : $conf['parameter.']['mmforcePlayer']; - - $forcePlayer = $mmFile ? intval($mmForcePlayer) : $conf['forcePlayer']; - $conf['forcePlayer'] = isset($conf['forcePlayer.']) - ? $this->cObj->stdWrap($forcePlayer, $conf['forcePlayer.']) - : $forcePlayer; - - $mmType = isset($conf['parameter.']['mmType.']) - ? $this->cObj->stdWrap($conf['parameter.']['mmType'], $conf['parameter.']['mmType.']) - : $conf['parameter.']['mmType']; - - $type = isset($conf['type.']) - ? $this->cObj->stdWrap($conf['type'], $conf['type.']) - : $conf['type']; - - $conf['type'] = $mmType ? $mmType : $type; $mime = $renderType . 'object'; $typeConf = $conf['mimeConf.'][$mime . '.'][$conf['type'] . '.'] ? $conf['mimeConf.'][$mime . '.'][$conf['type'] . '.'] : array(); $conf['predefined'] = array(); - $width = isset($conf['parameter.']['mmWidth.']) + // Width and height + $width = isset($conf['width.']) + ? intval($this->cObj->stdWrap($conf['width'], $conf['width.'])) + : intval($conf['width']); + $width = $width ? $width : $typeConf['defaultWidth']; + $mmWidth = isset($conf['parameter.']['mmWidth.']) ? intval($this->cObj->stdWrap($conf['parameter.']['mmWidth'], $conf['parameter.']['mmWidth.'])) : intval($conf['parameter.']['mmWidth']); - $height = isset($conf['parameter.']['mmHeight.']) + $conf['width'] = $mmWidth ? $mmWidth : $width; + $height = isset($conf['height.']) + ? intval($this->cObj->stdWrap($conf['height'], $conf['height.'])) + : intval($conf['height']); + $height = $height ? $height : $typeConf['defaultHeight']; + $mmHeight = isset($conf['parameter.']['mmHeight.']) ? intval($this->cObj->stdWrap($conf['parameter.']['mmHeight'], $conf['parameter.']['mmHeight.'])) : intval($conf['parameter.']['mmHeight']); - if ($width) { - $conf['width'] = $width; - } else { - $width = isset($conf['width.']) - ? intval($this->cObj->stdWrap($conf['width'], $conf['width.'])) - : intval($conf['width']); - $conf['width'] = $width ? $width : $typeConf['defaultWidth']; - } - if ($height) { - $conf['height'] = $height; - } else { - $height = isset($conf['height.']) - ? intval($this->cObj->stdWrap($conf['height'], $conf['height.'])) - : intval($conf['height']); - $conf['height'] = $height ? $height : $typeConf['defaultHeight']; - } + $conf['height'] = $mmHeight ? $mmHeight : $height; if (is_array($conf['parameter.']['mmMediaOptions'])) { $params = array(); @@ -184,23 +294,13 @@ class tslib_content_Media extends tslib_content_Abstract { } } - // render MEDIA - if ($mode == 'url' && !$forcePlayer) { - // url is called direct, not with player - if ($url == '' && !$conf['allowEmptyUrl']) { - return '<p style="background-color: yellow;">' . $GLOBALS['TSFE']->sL('LLL:EXT:cms/locallang_ttc.xml:media.noFile', TRUE) . '</p>'; - } - $conf = array_merge((array) $conf['mimeConf.']['swfobject.'], $conf); - $conf[$conf['type'] . '.']['player'] = strpos($url, '://') === FALSE ? 'http://' . $url : $url; - $conf['installUrl'] = 'null'; - $conf['flashvars'] = array_merge((array) $conf['flashvars'], $conf['predefined']); - } - switch ($renderType) { case 'swf' : $conf[$conf['type'] . '.'] = array_merge((array) $conf['mimeConf.']['swfobject.'][$conf['type'] . '.'], $typeConf); $conf = array_merge((array) $conf['mimeConf.']['swfobject.'], $conf); unset($conf['mimeConf.']); + $conf['attributes.'] = array_merge((array) $conf['attributes.'], $conf['predefined']); + $conf['params.'] = array_merge((array) $conf['params.'], $conf['predefined']); $conf['flashvars.'] = array_merge((array) $conf['flashvars.'], $conf['predefined']); $content = $this->cObj->SWFOBJECT($conf); break; @@ -224,7 +324,7 @@ class tslib_content_Media extends tslib_content_Abstract { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/hooks/class.tx_cms_mediaitems.php']['customMediaRender'] as $classRef) { $hookObj = t3lib_div::getUserObj($classRef); $conf['file'] = $url; - $conf['mode'] = $mode; + $conf['mode'] = is_file(PATH_site . $url) ? 'file' : 'url'; $content = $hookObj->customMediaRender($renderType, $conf, $this); } } diff --git a/typo3/sysext/cms/tslib/content/class.tslib_content_shockwaveflashobject.php b/typo3/sysext/cms/tslib/content/class.tslib_content_shockwaveflashobject.php index 261ed18ecdfefc0b25d661147c4cedd838a4c135..6b136c32998a90184d2288a2c6d5e61530febef8 100644 --- a/typo3/sysext/cms/tslib/content/class.tslib_content_shockwaveflashobject.php +++ b/typo3/sysext/cms/tslib/content/class.tslib_content_shockwaveflashobject.php @@ -34,11 +34,176 @@ */ class tslib_content_ShockwaveFlashObject extends tslib_content_Abstract { + /** + * File extension to mime type + */ + public $mimeTypes = array( + 'aif' => array( + 'audio' => 'audio/aiff', + ), + 'au' => array( + 'audio' => 'audio/x-au', + ), + 'avi' => array( + 'audio' => 'video/x-msvideo', + ), + 'asf' => array( + 'video' => 'video/x-ms-asf', + ), + 'class' => array( + 'audio' => 'application/java', + 'video' => 'application/java', + ), + 'dcr' => array( + 'video' => 'application/x-director', + ), + 'flac' => array( + 'audio' => 'audio/flac', + ), + 'flv' => array( + 'video' => 'video/x-flv', + ), + 'mp3' => array( + 'audio' => 'audio/mpeg', + ), + 'mp4' => array( + 'video' => 'video/mp4', + ), + 'oga' => array( + 'audio' => 'audio/ogg', + ), + 'ogg' => array( + 'audio' => 'audio/ogg', + 'video' => 'video/ogg', + ), + 'ogv' => array( + 'video' => 'video/ogg', + ), + 'swa' => array( + 'audio' => 'audio/x-m4a', + ), + 'mov' => array( + 'video' => 'video/quicktime', + ), + 'm4a' => array( + 'audio' => 'audio/mp4a-latm', + ), + 'm4v' => array( + 'video' => 'video/x-m4v', + ), + 'qt' => array( + 'video' => 'video/quicktime', + ), + 'swa' => array( + 'audio' => 'application/x-director', + ), + 'swf' => array( + 'audio' => 'application/x-shockwave-flash', + 'video' => 'application/x-shockwave-flash', + ), + 'wav' => array( + 'audio' => 'audio/wave', + ), + 'webm' => array( + 'audio' => 'audio/webm', + 'video' => 'video/webm', + ), + 'wmv' => array( + 'audio' => 'audio/x-ms-wmv', + ) + ); + + /** + * VideoJS options + */ + public $videoJsOptions = array( + // Use the browser's controls (iPhone) + 'useBuiltInControls', + // Display control bar below video vs. in front of + 'controlsBelow', + // Make controls visible when page loads + 'controlsAtStart', + // Hide controls when not over the video + 'controlsHiding', + // Will be overridden by localStorage volume if available + 'defaultVolume', + // Players and order to use them + 'playerFallbackOrder', + ); + + /** + * htlm5 tag attributes + */ + public $html5TagAttributes = array( + 'autoPlay', + 'controls', + 'loop', + 'preload', + ); + + /** + * Flowplayer captions plugin configuration + */ + public $flowplayerCaptionsConfig = array( + 'plugins' => array( + // The captions plugin + 'captions' => array( + 'url' => 'flowplayer.captions-3.2.3.swf', + // Pointer to a content plugin (see below) + 'captionTarget' => 'content' + ), + // Configure a content plugin so that it looks good for showing captions + 'content' => array( + 'url' => 'flowplayer.content-3.2.0.swf', + 'bottom' => 5, + 'height' => 40, + 'backgroundColor' => 'transparent', + 'backgroundGradient' => 'none', + 'border' => 0, + 'textDecoration' => 'outline', + 'style' => array( + 'body' => array( + 'fontSize' => 14, + 'fontFamily' => 'Arial', + 'textAlign' => 'center', + 'color' => '#ffffff' + ) + ) + ), + ), + ); + + /** + * Flowplayer audio configuration + */ + public $flowplayerAudioConfig = array( + 'provider' => 'audio', + 'plugins' => array( + 'audio' => array( + 'url' => 'flowplayer.audio-3.2.2.swf' + ), + 'controls' => array( + 'autoHide' => FALSE, + 'fullscreen' => FALSE, + ), + ), + ); + + /** + * Flowplayer configuration for the audio description + */ + public $flowplayerAudioDescriptionConfig = array( + // The controls plugin + 'plugins' => array( + 'controls' => NULL, + ), + ); + /** * Rendering the cObject, SWFOBJECT * - * @param array Array of TypoScript properties - * @return string Output + * @param array $conf Array of TypoScript properties + * @return string Output */ public function render($conf = array()) { $prefix = ''; @@ -49,51 +214,114 @@ class tslib_content_ShockwaveFlashObject extends tslib_content_Abstract { $prefix = $GLOBALS['TSFE']->absRefPrefix; } ; + // Initialize content + $replaceElementIdString = uniqid('mmswf'); + $GLOBALS['TSFE']->register['MMSWFID'] = $replaceElementIdString; + + $layout = isset($conf['layout.']) + ? $this->cObj->stdWrap($conf['layout'], $conf['layout.']) + : $conf['layout']; + $content = str_replace('###ID###', $replaceElementIdString, $layout); $type = isset($conf['type.']) ? $this->cObj->stdWrap($conf['type'], $conf['type.']) : $conf['type']; $typeConf = $conf[$type . '.']; - //add SWFobject js-file - $GLOBALS['TSFE']->getPageRenderer()->addJsFile(TYPO3_mainDir . 'contrib/flashmedia/swfobject/swfobject.js'); + // Add Flowplayer js-file + $GLOBALS['TSFE']->getPageRenderer()->addJsFile(TYPO3_mainDir . 'contrib/flowplayer/example/flowplayer-3.2.6.min.js'); + // Add Flowpayer css for exprss install + $GLOBALS['TSFE']->getPageRenderer()->addCssFile(TYPO3_mainDir . '../t3lib/js/flowplayer/express-install.css'); + // Add videoJS js-file + $GLOBALS['TSFE']->getPageRenderer()->addJsFile(TYPO3_mainDir . 'contrib/videojs/video-js/video.js'); + // Add videoJS js-file + $GLOBALS['TSFE']->getPageRenderer()->addJsFile(TYPO3_mainDir . 'contrib/videojs/video-js/video.js'); + // Add videoJS css-file + $GLOBALS['TSFE']->getPageRenderer()->addCssFile(TYPO3_mainDir . 'contrib/videojs/video-js/video-js.css'); + // Add extended videoJS control bar + $GLOBALS['TSFE']->getPageRenderer()->addJsFile(TYPO3_mainDir . '../t3lib/js/videojs/control-bar.js'); + $GLOBALS['TSFE']->getPageRenderer()->addCssFile(TYPO3_mainDir . '../t3lib/js/videojs/control-bar.css'); + // Build Flash configuration $player = isset($typeConf['player.']) ? $this->cObj->stdWrap($typeConf['player'], $typeConf['player.']) : $typeConf['player']; - + if (!$player) { + $player = $prefix . TYPO3_mainDir . 'contrib/flowplayer/flowplayer-3.2.7.swf'; + } $installUrl = isset($conf['installUrl.']) ? $this->cObj->stdWrap($conf['installUrl'], $conf['installUrl.']) : $conf['installUrl']; - if(!$installUrl) { - $installUrl = $prefix . TYPO3_mainDir . 'contrib/flashmedia/swfobject/expressInstall.swf'; + if (!$installUrl) { + $installUrl = $prefix . TYPO3_mainDir . 'contrib/flowplayer/expressinstall.swf'; + } + $flashVersion = isset($conf['flashVersion.']) + ? $this->cObj->stdWrap($conf['flashVersion'], $conf['flashVersion.']) + : $conf['flashVersion']; + if (!$flashVersion) { + $flashVersion = array(9,115); } + $flashConfiguration = array( + // Flowplayer component + 'src' => $player, + // Express install url + 'expressInstall' => $installUrl, + // Require at least this Flash version + 'version' => $flashVersion, + // Older versions will see a message + 'onFail' => '###ONFAIL###' + ); + $flashDownloadUrl = 'http://www.adobe.com/go/getflashplayer'; + $onFail = 'function() { + if (!(flashembed.getVersion()[0] > 0)) { + var message = "<p>" + "' . $GLOBALS['TSFE']->sL('LLL:EXT:cms/locallang_ttc.xlf:media.needFlashPlugin') . '" + "</p>" + "<p>" + "<a href=\"' . $flashDownloadUrl . '\">' . $GLOBALS['TSFE']->sL('LLL:EXT:cms/locallang_ttc.xlf:media.downloadFlash') . '</a>" + "</p>"; + document.getElementById("' . $replaceElementIdString . '_flash_install_info").innerHTML = "<div class=\"message\">" + message + "</div>"; + } + }'; + $flashConfiguration = json_encode($flashConfiguration); + $flashConfiguration = str_replace('"###ONFAIL###"', $onFail, $flashConfiguration); + $filename = isset($conf['file.']) ? $this->cObj->stdWrap($conf['file'], $conf['file.']) : $conf['file']; - $forcePlayer = isset($conf['forcePlayer.']) - ? $this->cObj->stdWrap($conf['forcePlayer'], $conf['forcePlayer.']) - : $conf['forcePlayer']; - if ($filename && $forcePlayer) { + if ($filename) { if (strpos($filename, '://') !== FALSE) { - $conf['flashvars.']['file'] = $filename; + $conf['flashvars.']['url'] = $filename; } else { if ($prefix) { - $conf['flashvars.']['file'] = $prefix . $filename; + $conf['flashvars.']['url'] = $prefix . $filename; } else { - $conf['flashvars.']['file'] = str_repeat('../', substr_count($player, '/')) . $filename; + $conf['flashvars.']['url'] = str_repeat('../', substr_count($player, '/')) . $filename; + } + } + } + if (is_array($conf['sources'])) { + foreach ($conf['sources'] as $key => $source) { + if (strpos($source, '://') === FALSE) { + $conf['sources'][$key] = $prefix . $source; } - } - } else { - $player = $filename; } + if (is_array($conf['audioSources'])) { + foreach ($conf['audioSources'] as $key => $source) { + if (strpos($source, '://') === FALSE) { + $conf['audioSources'][$key] = $prefix . $source; + } + } + } + if (isset($conf['audioFallback']) && strpos($conf['audioFallback'], '://') === FALSE) { + $conf['audioFallback'] = $prefix . $conf['audioFallback']; + } + if (isset($conf['caption']) && strpos($conf['caption'], '://') === FALSE) { + $conf['caption'] = $prefix . $conf['caption']; + } + // Write calculated values in conf for the hook - $conf['player'] = $player; + $conf['player'] = $player ? $player : $filename; $conf['installUrl'] = $installUrl; - $conf['filename'] = $filename; + $conf['filename'] = $conf['flashvars.']['url']; $conf['prefix'] = $prefix; // merge with default parameters @@ -108,62 +336,463 @@ class tslib_content_ShockwaveFlashObject extends tslib_content_Abstract { t3lib_div::callUserFunction($classRef, $conf, $this); } } + + // Flowplayer config + $flowplayerVideoConfig = array(); + $flowplayerAudioConfig = array(); if (is_array($conf['flashvars.'])) { t3lib_div::remapArrayKeys($conf['flashvars.'], $typeConf['mapping.']['flashvars.']); + } else { + $conf['flashvars.'] = array(); } - $flashvars = 'var flashvars = ' . (count($conf['flashvars.']) ? json_encode($conf['flashvars.']) : '{}') . ';'; + $conf['videoflashvars'] = $conf['flashvars.']; + $conf['audioflashvars'] = $conf['flashvars.']; + $conf['audioflashvars']['url'] = $conf['audioFallback']; - if (is_array($conf['params.'])) { - t3lib_div::remapArrayKeys($conf['params.'], $typeConf['mapping.']['params.']); + // Render video sources + $videoSources = ''; + if (is_array($conf['sources'])) { + foreach ($conf['sources'] as $source) { + $fileinfo = t3lib_div::split_fileref($source); + $mimeType = $this->mimeTypes[$fileinfo['fileext']]['video']; + $videoSources .= '<source src="' . $source . '"' . ($mimeType ? ' type="' . $mimeType . '"' : '') . ' />' . LF; + } } - $params = 'var params = ' . (count($conf['params.']) ? json_encode($conf['params.']) : '{}') . ';'; - if (is_array($conf['attributes.'])) { - t3lib_div::remapArrayKeys($conf['attributes.'], $typeConf['attributes.']['params.']); + // Render audio sources + $audioSources = ''; + if (is_array($conf['audioSources'])) { + foreach ($conf['audioSources'] as $source) { + $fileinfo = t3lib_div::split_fileref($source); + $mimeType = $this->mimeTypes[$fileinfo['fileext']]['audio']; + $audioSources .= '<source src="' . $source . '"' . ($mimeType ? ' type="' . $mimeType . '"' : '') . ' />' . LF; + } } - $attributes = 'var attributes = ' . (count($conf['attributes.']) ? json_encode($conf['attributes.']) : '{}') . ';'; - $flashVersion = isset($conf['flashVersion.']) - ? $this->cObj->stdWrap($conf['flashVersion'], $conf['flashVersion.']) - : $conf['flashVersion']; + // Configure captions + if ($conf['type'] === 'video' && isset($conf['caption'])) { + // Assemble captions track tag + $videoCaptions = '<track id="' . $replaceElementIdString . '_captions_track" kind="captions" src="' . $conf['caption'] . '"></track>' . LF; + // Add videoJS extension for captions + $GLOBALS['TSFE']->getPageRenderer()->addJsFile(TYPO3_mainDir . '../t3lib/js/videojs/captions.js'); + // Flowplayer captions + $conf['videoflashvars']['captionUrl'] = $conf['caption']; + // Flowplayer captions plugin configuration + $flowplayerVideoConfig = array_merge_recursive($flowplayerVideoConfig, $this->flowplayerCaptionsConfig); + } - if (!$flashVersion) { - $flashVersion = '9'; + // Configure flowplayer audio fallback + if (isset($conf['audioFallback'])) { + $flowplayerAudioConfig = array_merge_recursive($flowplayerAudioConfig, $this->flowplayerAudioConfig); } - $replaceElementIdString = uniqid('mmswf'); - $GLOBALS['TSFE']->register['MMSWFID'] = $replaceElementIdString; + // Configure audio description + if ($conf['type'] == 'video') { + if (is_array($conf['audioSources']) && count($conf['audioSources'])) { + // Add videoJS audio description toggle + $GLOBALS['TSFE']->getPageRenderer()->addJsFile(TYPO3_mainDir . '../t3lib/js/videojs/audio-description.js'); + } + if (isset($conf['audioFallback'])) { + // Audio description flowplayer config (remove controls) + $flowplayerAudioConfig = array_merge_recursive($flowplayerAudioConfig, $this->flowplayerAudioDescriptionConfig); + } + } - $alternativeContent = isset($conf['alternativeContent.']) - ? $this->cObj->stdWrap($conf['alternativeContent'], $conf['alternativeContent.']) - : $conf['alternativeContent']; + // Assemble Flowplayer configuration + if (count($conf['videoflashvars'])) { + $flowplayerVideoConfig = array_merge_recursive($flowplayerVideoConfig, array('clip' => $conf['videoflashvars'])); + } + $flowplayerVideoJsonConfig = str_replace(array('"true"', '"false"'), array('true', 'false'), json_encode($flowplayerVideoConfig)); + if (count($conf['audioflashvars'])) { + $flowplayerAudioConfig = array_merge_recursive($flowplayerAudioConfig, array('clip' => $conf['audioflashvars'])); + } + $flowplayerAudioJsonConfig = str_replace(array('"true"', '"false"'), array('true', 'false'), json_encode($flowplayerAudioConfig)); + // Assemble param tags (required?) + if (is_array($conf['params.'])) { + t3lib_div::remapArrayKeys($conf['params.'], $typeConf['mapping.']['params.']); + } + $videoFlashParams = ''; + if (is_array($conf['params.'])) { + foreach ($conf['params.'] as $name => $value) { + $videoFlashParams .= '<param name="' . $name . '" value="' . $value . '" />' . LF; + } + } + $audioFlashParams = $videoFlashParams; - $layout = isset($conf['layout.']) - ? $this->cObj->stdWrap($conf['layout'], $conf['layout.']) - : $conf['layout']; - $content = str_replace('###ID###', $replaceElementIdString, $layout); - $content = str_replace('###SWFOBJECT###', '<div id="' . $replaceElementIdString . '">' . $alternativeContent . '</div>', $content); + // Required param tags + $videoFlashParams .= '<param name="movie" value="' . $player . '" />' . LF; + $videoFlashParams .= '<param name="flashvars" value=\'config=' . $flowplayerVideoJsonConfig . '\' />' . LF; + $audioFlashParams .= '<param name="movie" value="' . $player . '" />' . LF; + $audioFlashParams .= '<param name="flashvars" value=\'config=' . $flowplayerAudioJsonConfig . '\' />' . LF; + // Assemble audio/video tag attributes + $attributes = ''; + if (is_array($conf['attributes.'])) { + t3lib_div::remapArrayKeys($conf['attributes.'], $typeConf['attributes.']['params.']); + } + foreach ($this->html5TagAttributes as $attribute) { + if ($conf['attributes.'][$attribute] === 'true' || $conf['attributes.'][$attribute] === strToLower($attribute) || $conf['attributes.'][$attribute] === $attribute) { + $attributes .= strToLower($attribute) . '="' . strToLower($attribute) . '" '; + } + } + + // Media dimensions $width = isset($conf['width.']) ? $this->cObj->stdWrap($conf['width'], $conf['width.']) : $conf['width']; - if(!$width) { + if (!$width) { $width = $conf[$type . '.']['defaultWidth']; } - $height = isset($conf['height.']) + $height = isset($conf['height.']) ? $this->cObj->stdWrap($conf['height'], $conf['height.']) : $conf['height']; - if(!$height) { + if (!$height) { $height = $conf[$type . '.']['defaultHeight']; } + // Alternate content + $alternativeContent = isset($conf['alternativeContent.']) + ? $this->cObj->stdWrap($conf['alternativeContent'], $conf['alternativeContent.']) + : $conf['alternativeContent']; - $embed = 'swfobject.embedSWF("' . $conf['player'] . '", "' . $replaceElementIdString . '", "' . $width . '", "' . $height . '", - "' . $flashVersion . '", "' . $installUrl . '", ' . $conf['embedParams'] . ');'; + // Render video + if ($conf['type'] === 'video') { + if ($conf['preferFlashOverHtml5']) { + // Flash with video tag fallback + $conf['params.']['playerFallbackOrder'] = array('flash', 'html5'); + $flashDivContent = $videoFlashParams . LF . + '<video id="' . $replaceElementIdString . '_video_js" class="video-js" ' . $attributes . 'controls="controls" mediagroup="' . $replaceElementIdString . '" width="' . $width . '" height="' . $height . '">' . LF . + $videoSources . + $videoCaptions . + $alternativeContent . LF . + '</video>' . LF; + $divContent = ' + <div id="' . $replaceElementIdString . '_flash_install_info" class="flash-install-info"></div>' . LF . + '<noscript>' . LF . + '<object id="' . $replaceElementIdString . '_vjs_flash" type="application/x-shockwave-flash" data="' . $player . '" width="' . $width . '" height="' . $height . '">' . LF . + $flashDivContent . + '</object>' . LF . + '</noscript>' . LF; + $content = str_replace('###SWFOBJECT###', '<div id="' . $replaceElementIdString . '_video" class="flashcontainer" style="width:' . $width . 'px; height:' . $height . 'px;">' . LF . $divContent . '</div>', $content); + } else { + // Video tag with Flash fallback + $conf['params.']['playerFallbackOrder'] = array('html5', 'flash'); + $videoTagContent = $videoSources . $videoCaptions; + if (isset($conf['videoflashvars']['url'])) { + $videoTagContent .= ' + <noscript>' . LF . + '<object class="vjs-flash-fallback" id="' . $replaceElementIdString . '_vjs_flash_fallback" type="application/x-shockwave-flash" data="' . $player . '" width="' . $width . '" height="' . $height . '">' . LF . + $videoFlashParams . LF . + $alternativeContent . LF . + '</object>' . LF . + '</noscript>'; + } + $divContent = ' + <div id="' . $replaceElementIdString . '_flash_install_info" class="flash-install-info"></div>' . LF . + '<video id="' . $replaceElementIdString . '_video_js" class="video-js" ' . $attributes . 'controls="controls" mediagroup="' . $replaceElementIdString . '" width="' . $width . '" height="' . $height . '">' . LF . + $videoTagContent . + '</video>'; + $content = str_replace('###SWFOBJECT###', '<div id="' . $replaceElementIdString . '_video" class="video-js-box" style="width:' . $width . 'px; height:' . $height . 'px;">' . LF . $divContent . '</div>', $content); + } + } + // Render audio + if ($conf['type'] === 'audio' || $audioSources || isset($conf['audioFallback'])) { + if ($conf['preferFlashOverHtml5']) { + // Flash with audio tag fallback + $flashDivContent = $audioFlashParams . LF . + '<audio id="' . $replaceElementIdString . '_audio_element"' . $attributes . ($conf['type'] === 'video' ? ' mediagroup="' . $replaceElementIdString . 'style="position:absolute;left:-10000px;"' : ' controls="controls"') . ' style="width:' . $width . 'px; height:' . $height . 'px;">' . LF . + $audioSources . + $alternativeContent . LF . + '</audio>' . LF; + $divContent = ($conf['type'] === 'video' ? '' : '<div id="' . $replaceElementIdString . '_flash_install_info" class="flash-install-info"></div>' . LF) . + '<noscript>' . LF . + '<object id="' . $replaceElementIdString . '_audio_flash" type="application/x-shockwave-flash" data="' . $player . '" width="' . ($conf['type'] === 'video' ? 0 : $width) . '" height="' . ($conf['type'] === 'video' ? 0 : $height) . '">' . LF . + $flashDivContent . + '</object>' . LF . + '</noscript>' . LF; + $audioContent = '<div id="' . $replaceElementIdString . '_audio_box" class="audio-flash-container" style="width:' . ($conf['type'] === 'video' ? 0 : $width) . 'px; height:' . ($conf['type'] === 'video' ? 0 : $height) . 'px;">' . LF . $divContent . '</div>'; + } else { + // Audio tag with Flash fallback + $audioTagContent = $audioSources; + if (isset($conf['audioflashvars']['url'])) { + $audioTagContent .= ' + <noscript>' . LF . + '<object class="audio-flash-fallback" id="' . $replaceElementIdString . '_audio_flash" type="application/x-shockwave-flash" data="' . $player . '" width="' . $width . '" height="' . $height . '">' . LF . + $audioFlashParams . LF . + $alternativeContent . LF . + '</object>' . LF . + '</noscript>'; + } + $divContent = ($conf['type'] === 'video' ? '' : '<div id="' . $replaceElementIdString . '_flash_install_info" class="flash-install-info"></div>' . LF) . + '<audio id="' . $replaceElementIdString . '_audio_element" class="audio-element"' . $attributes . ($conf['type'] === 'video' ? ' mediagroup="' . $replaceElementIdString . '" style="position:absolute;left:-10000px;"' : ' controls="controls"') . '>' . LF . + $audioTagContent . + '</audio>' . LF . + $audioSourcesEmbeddingJsScript; + $audioContent = '<div id="' . $replaceElementIdString . '_audio_box" class="audio-box" style="width:' . ($conf['type'] === 'video' ? 0 : $width) . 'px; height:' . ($conf['type'] === 'video' ? 0 : $height) . 'px;">' . LF . $divContent . '</div>'; + } + if ($conf['type'] === 'audio') { + $content = str_replace('###SWFOBJECT###', $audioContent, $content); + } else { + $content .= LF . $audioContent; + } + } - $script = $flashvars . $params . $attributes . $embed; - $GLOBALS['TSFE']->getPageRenderer()->addJsInlineCode($replaceElementIdString, $script); + // Assemble inline JS code + $videoJsSetup = ''; + $flowplayerHandlers = ''; + if ($conf['type'] === 'video') { + // Assemble videoJS options + $videoJsOptions = array(); + foreach ($this->videoJsOptions as $videoJsOption) { + if (isset($conf['params.'][$videoJsOption])) { + $videoJsOptions[$videoJsOption] = $conf['params.'][$videoJsOption]; + } + } + $videoJsOptions = count($videoJsOptions) ? json_encode($videoJsOptions) : '{}'; + + // videoJS setup and videoJS listeners for audio description synchronisation + if ($audioSources || isset($conf['audioFallback'])) { + $videoJsSetup = ' + var ' . $replaceElementIdString . '_video = VideoJS.setup("' . $replaceElementIdString . '_video_js", ' . $videoJsOptions . '); + var ' . $replaceElementIdString . '_video_element = document.getElementById("' . $replaceElementIdString . '_video_js"); + var ' . $replaceElementIdString . '_audio_element = document.getElementById("' . $replaceElementIdString . '_audio_element"); + if (!!' . $replaceElementIdString . '_video_element && !!' . $replaceElementIdString . '_audio_element) { + ' . $replaceElementIdString . '_audio_element.muted = true; + VideoJS.addListener(' . $replaceElementIdString . '_video_element, "pause", function () { document.getElementById("' . $replaceElementIdString . '_audio_element").pause(); }); + VideoJS.addListener(' . $replaceElementIdString . '_video_element, "play", function () { try {document.getElementById("' . $replaceElementIdString . '_audio_element").currentTime = document.getElementById("' . $replaceElementIdString . '_video_js").currentTime} catch(e) {}; document.getElementById("' . $replaceElementIdString . '_audio_element").play(); }); + VideoJS.addListener(' . $replaceElementIdString . '_video_element, "seeked", function () { document.getElementById("' . $replaceElementIdString . '_audio_element").currentTime = document.getElementById("' . $replaceElementIdString . '_video_js").currentTime; }); + VideoJS.addListener(' . $replaceElementIdString . '_video_element, "volumechange", function () { document.getElementById("' . $replaceElementIdString . '_audio_element").volume = document.getElementById("' . $replaceElementIdString . '_video_js").volume; }); + }'; + } else { + $videoJsSetup = ' + var ' . $replaceElementIdString . '_video = VideoJS.setup("' . $replaceElementIdString . '_video_js", ' . $videoJsOptions . '); + '; + } + // Prefer Flash or fallback to Flash + $videoSourcesEmbedding = ''; + // If we have a video file for Flash + if (isset($conf['filename'])) { + // If we prefer Flash + if ($conf['preferFlashOverHtml5']) { + $videoTagAssembly = ''; + // Create "source" elements + if (is_array($conf['sources']) && count($conf['sources'])) { + foreach ($conf['sources'] as $source) { + $fileinfo = t3lib_div::split_fileref($source); + $mimeType = $this->mimeTypes[$fileinfo['fileext']]['video']; + $videoTagAssembly .= ' + ' . $replaceElementIdString . '_video_js.appendChild($f.extend(document.createElement("source"), { + src: "' . $source . '", + type: "' . $mimeType . '" + }));'; + } + // Create "track" elements + if (isset($conf['caption'])) { + // Assemble captions track tag + // It will take a while before the captions are loaded and parsed... + $videoTagAssembly .= ' + var track = document.createElement("track"); + track.setAttribute("src", "' . $conf['caption'] . '"); + track.setAttribute("id", "' . $replaceElementIdString . '_captions_track"); + track.setAttribute("kind", "captions"); + ' . $replaceElementIdString . '_video_js.appendChild(track);'; + } + $videoTagAssembly .= ' + $f.extend(' . $replaceElementIdString . '_video_js, { + id: "' . $replaceElementIdString . '_video_js", + className: "video-js", + controls: "controls", + mediagroup: "' . $replaceElementIdString . '", + preload: "none", + width: "' . $width . '", + height: "' . $height. '" + }); + ' . $replaceElementIdString . '_video.appendChild(' . $replaceElementIdString . '_video_js); + ' . $replaceElementIdString . '_video.className = "video-js-box";'; + $videoTagAssembly .= $videoJsSetup; + } + $videoSourcesEmbedding = ' + var ' . $replaceElementIdString . '_video = document.getElementById("' . $replaceElementIdString . '_video"); + var ' . $replaceElementIdString . '_video_js = document.createElement("video"); + if (flashembed.getVersion()[0] > 0) { + // Flash is available + var videoPlayer = flowplayer("' . $replaceElementIdString . '_video", ' . $flashConfiguration . ', ' . $flowplayerVideoJsonConfig . ').load(); + videoPlayer.onBeforeUnload(function () { return false; }); + } else if (!!' . $replaceElementIdString . '_video_js.canPlayType) { + // Flash is not available: fallback to videoJS if video tag is supported + ' . $videoTagAssembly . ' + } else { + // Neither Flash nor video is available: offer to install Flash + flashembed("' . $replaceElementIdString . '_video", ' . $flashConfiguration . '); + }'; + } elseif (is_array($conf['sources'])) { + // HTML5 is the preferred rendering method + // Test whether the browser supports any of types of the provided sources + $supported = array(); + foreach ($conf['sources'] as $source) { + $fileinfo = t3lib_div::split_fileref($source); + $mimeType = $this->mimeTypes[$fileinfo['fileext']]['video']; + $supported[] = $replaceElementIdString . '_videoTag.canPlayType("' . $mimeType . '") != ""'; + } + // Testing whether the browser supports the video tag with any of the provided source types + // If no support, embed flowplayer + $videoSourcesEmbedding = ' + var ' . $replaceElementIdString . '_videoTag = document.createElement(\'video\'); + var ' . $replaceElementIdString . '_video_box = document.getElementById("' . $replaceElementIdString . '_video"); + if (' . $replaceElementIdString . '_video_box) { + if (!' . $replaceElementIdString . '_videoTag || !' . $replaceElementIdString . '_videoTag.canPlayType || !(' . (count($supported) ? implode( ' || ', $supported) : 'false') . ')) { + // Avoid showing an empty video element + if (document.getElementById("' . $replaceElementIdString . '_video_js")) { + document.getElementById("' . $replaceElementIdString . '_video_js").style.display = "none"; + } + if (flashembed.getVersion()[0] > 0) { + // Flash is available + var videoPlayer = flowplayer("' . $replaceElementIdString . '_video", ' . $flashConfiguration . ', ' . $flowplayerVideoJsonConfig . ').load(); + videoPlayer.onBeforeUnload(function () { return false; }); + } else { + // Neither Flash nor video is available: offer to install Flash + flashembed("' . $replaceElementIdString . '_video", ' . $flashConfiguration . '); + } + } else {' . $videoJsSetup . ' + } + }'; + } + } + } + // Audio fallback to Flash + $audioSourcesEmbedding = ''; + // If we have an audio file for Flash + if (isset($conf['audioFallback'])) { + // If we prefer Flash in + if ($conf['preferFlashOverHtml5']) { + $audioTagAssembly = ''; + // Create "source" elements + if (is_array($conf['audioSources']) && count($conf['audioSources'])) { + foreach ($conf['audioSources'] as $source) { + $fileinfo = t3lib_div::split_fileref($source); + $mimeType = $this->mimeTypes[$fileinfo['fileext']]['audio']; + $audioTagAssembly .= ' + ' . $replaceElementIdString . '_audio_element.appendChild($f.extend(document.createElement("source"), { + src: "' . $source . '", + type: "' . $mimeType . '" + }));'; + } + $audioTagAssembly .= ' + $f.extend(' . $replaceElementIdString . '_audio_element, { + id: "' . $replaceElementIdString . '_audio_element", + className: "audio-element", + controls: "' . ($conf['type'] === 'video' ? '' : 'controls') . '", + mediagroup: "' . $replaceElementIdString . '", + preload: "none", + width: "' . ($conf['type'] === 'video' ? 0 : $width) . 'px", + height: "' . ($conf['type'] === 'video' ? 0 : $height) . 'px" + }); + ' . $replaceElementIdString . '_audio_box.appendChild(' . $replaceElementIdString . '_audio_element); + ' . $replaceElementIdString . '_audio_box.className = "audio-box";'; + } + $audioSourcesEmbedding = ' + var ' . $replaceElementIdString . '_audio_box = document.getElementById("' . $replaceElementIdString . '_audio_box"); + var ' . $replaceElementIdString . '_audio_element = document.createElement("audio"); + if (flashembed.getVersion()[0] > 0) { + // Flash is available + var audioPlayer = flowplayer("' . $replaceElementIdString . '_audio_box", ' . $flashConfiguration . ', ' . $flowplayerAudioJsonConfig . ').load(); + audioPlayer.onBeforeUnload(function () { return false; }); + ' . ($conf['type'] === 'video' ? 'audioPlayer.mute();' : '') . ' + } else if (!!' . $replaceElementIdString . '_audio_element.canPlayType) { + // Flash is not available: fallback to audio element if audio tag is supported + ' . $audioTagAssembly . ' + } else { + // Neither Flash nor audio is available: offer to install Flash if this is not an audio description of a video + ' . ($conf['type'] === 'video' ? '' : 'flashembed("' . $replaceElementIdString . '_audio_box", ' . $flashConfiguration . ');') . ' + }'; + } elseif (is_array($conf['audioSources'])) { + // HTML5 is the preferred rendering method + // Test whether the browser supports any of types of the provided sources + $supported = array(); + foreach ($conf['audioSources'] as $source) { + $fileinfo = t3lib_div::split_fileref($source); + $mimeType = $this->mimeTypes[$fileinfo['fileext']]['audio']; + $supported[] = $replaceElementIdString . '_audioTag.canPlayType("' . $mimeType . '") != ""'; + } + // Testing whether the browser supports the audio tag with any of the provided source types + // If no support, embed flowplayer + $audioSourcesEmbedding = ' + var ' . $replaceElementIdString . '_audioTag = document.createElement(\'audio\'); + var ' . $replaceElementIdString . '_audio_box = document.getElementById("' . $replaceElementIdString . '_audio_box"); + if (' . $replaceElementIdString . '_audio_box) { + if (!' . $replaceElementIdString . '_audioTag || !' . $replaceElementIdString . '_audioTag.canPlayType || !(' . (count($supported) ? implode( ' || ', $supported) : 'false') . ')) { + // Avoid showing an empty audio element + if (document.getElementById("' . $replaceElementIdString . '_audio_element")) { + document.getElementById("' . $replaceElementIdString . '_audio_element").style.display = "none"; + } + if (flashembed.getVersion()[0] > 0) { + var audioPlayer = flowplayer("' . $replaceElementIdString . '_audio_box", ' . $flashConfiguration . ', ' . $flowplayerAudioJsonConfig . ').load(); + audioPlayer.onBeforeUnload(function () { return false; }); + ' . ($conf['type'] === 'video' ? 'audioPlayer.mute()' : '') . ' + } else { + // Neither Flash nor audio is available: offer to install Flash if this is not an audio description of a video + ' . ($conf['type'] === 'video' ? '' : 'flashembed("' . $replaceElementIdString . '_audio_box", ' . $flashConfiguration . ');') . ' + } + } + }'; + } + // Flowplayer eventHandlers for audio description synchronisation + $flowplayerHandlers = ''; + if ($conf['type'] === 'video') { + $flowplayerHandlers = ' + if (flashembed.getVersion()[0] > 0) { + // Flash is available + var videoPlayer = flowplayer("' . $replaceElementIdString . '_video"); + if (videoPlayer) { + // Control audio description through video control bar + videoPlayer.onVolume(function (volume) { flowplayer("' . $replaceElementIdString . '_audio_box").setVolume(volume); }); + videoPlayer.onMute(function () { flowplayer("' . $replaceElementIdString . '_audio_box").mute(); }); + videoPlayer.onUnmute(function () { flowplayer("' . $replaceElementIdString . '_audio_box").unmute(); }); + videoPlayer.onPause(function () { flowplayer("' . $replaceElementIdString . '_audio_box").pause(); }); + videoPlayer.onResume(function () { flowplayer("' . $replaceElementIdString . '_audio_box").resume(); }); + videoPlayer.onStart(function () { flowplayer("' . $replaceElementIdString . '_audio_box").play(); }); + videoPlayer.onStop(function () { flowplayer("' . $replaceElementIdString . '_audio_box").stop(); }); + videoPlayer.onSeek(function (clip, seconds) { flowplayer("' . $replaceElementIdString . '_audio_box").seek(seconds); }); + // Mute audio description on start + flowplayer("' . $replaceElementIdString . '_audio_box").onStart(function () { this.mute()}); + // Audio description toggle + var videoContainer = document.getElementById("' . $replaceElementIdString . '_video"); + var buttonContainer = document.createElement("div"); + $f.extend(buttonContainer, { + id: "' . $replaceElementIdString . '_audio_description_toggle", + className: "vjs-audio-description-control" + }); + var button = document.createElement("div"); + buttonContainer.appendChild(button); + buttonContainer.style.position = "relative"; + buttonContainer.style.left = (parseInt(' . $width . ', 10)-27) + "px"; + videoContainer.parentNode.insertBefore(buttonContainer, videoContainer.nextSibling); + VideoJS.addListener(buttonContainer, "click", function () { + var buttonContainer = document.getElementById("' . $replaceElementIdString . '_audio_description_toggle"); + var state = buttonContainer.getAttribute("data-state"); + if (state == "enabled") { + buttonContainer.setAttribute("data-state", "disabled"); + flowplayer("' . $replaceElementIdString . '_audio_box").mute(); + } else { + buttonContainer.setAttribute("data-state", "enabled"); + flowplayer("' . $replaceElementIdString . '_audio_box").unmute(); + } + }); + } + }'; + } + } + // Wrap up inline JS code + $jsInlineCode = $audioSourcesEmbedding . + $videoSourcesEmbedding . + $flowplayerHandlers; + if ($jsInlineCode) { + $jsInlineCode = 'VideoJS.DOMReady(function(){' . + $jsInlineCode . LF . + '});'; + } + $GLOBALS['TSFE']->getPageRenderer()->addJsInlineCode($replaceElementIdString, $jsInlineCode); if (isset($conf['stdWrap.'])) { $content = $this->cObj->stdWrap($content, $conf['stdWrap.']); @@ -171,12 +800,9 @@ class tslib_content_ShockwaveFlashObject extends tslib_content_Abstract { return $content; } - } - if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/content/class.tslib_content_shockwaveflashobject.php'])) { include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/content/class.tslib_content_shockwaveflashobject.php']); } - ?> \ No newline at end of file diff --git a/typo3/sysext/css_styled_content/static/constants.txt b/typo3/sysext/css_styled_content/static/constants.txt index c875eb380a022fce1c2d2d112751e0dde6784710..86ded64dfeaf95371173ab54af269a38033f04ed 100644 --- a/typo3/sysext/css_styled_content/static/constants.txt +++ b/typo3/sysext/css_styled_content/static/constants.txt @@ -120,17 +120,17 @@ styles.content.searchresult { styles.content.media { # cat=content/cMedia/j1; type=; label= Video Player: configure the path to the video player - videoPlayer = typo3/contrib/flashmedia/flvplayer.swf + videoPlayer = typo3/contrib/flowplayer/flowplayer-3.2.7.swf # cat=content/cMedia/j2; type=int+; label= Media Video Width: define the default width for the media video defaultVideoWidth = 600 # cat=content/cMedia/j3; type=int+; label= Media Video Height: define the default height for the media video defaultVideoHeight = 400 # cat=content/cMedia/j4; type=; label= Audio Player: configure the path to the video player - audioPlayer = typo3/contrib/flashmedia/player.swf + audioPlayer = typo3/contrib/flowplayer/flowplayer-3.2.7.swf # cat=content/cMedia/j5; type=int+; label= Media Audio Width: define the default width for the media audio defaultAudioWidth = 300 # cat=content/cMedia/j6; type=int+; label= Media Audio Height: define the default height for the media audio - defaultAudioHeight = 30 + defaultAudioHeight = 26 } styles.content.table {