![]() |
|
|
#1 |
|
Advanced Member
Join Date: Apr 2006
Location: London
Posts: 2,154
My Garage: - BMW E46 ///M3 Convertible - BMW E39 535i - BMW E31 850CSi - BMW E36 328i - BMW E30 320i ![]() |
Skinner Info
First of all, you'll need to install Velocity. Then you'll need to get the example skin from here.
Velocity operates an asynchronous event-based model. A request is sent, and it's forgotten (you never get an immediate, synchronous response). Some data is sent back from Velocity to Flash, and this should invoke some event on Flash. It's a different way of coding, just like AJAX. But once you get your head around it, it does all you need. To break it up into steps, it's as follows: Request 1. Flash sends a request to Velocity 2. Velocity will deal with that request Asynchronous Response 1. Velocity sends some data to Flash 2. Flash responds to that event For example, if the play button is pressed on some media playback screen, the following sequence of events happens: Request 1. Flash sends the play command to the media plug-in in Velocity 2. Velocity tells the media plug-in to play (which tells mplayer to play) At this point, mplayer is playing the vide and doesn’t' really care about anything else. Velocity is monitoring all the outputs of mplayer and keeping track of field changes, such as bitrate, track position, track name, etc. Initially, all this data is sent to Flash, but as the media plays, only a few things change, so only those are sent back to Flash, like the current position in the track, and perhaps the bitrate. All this data is sent back to Flash and is held in native Flash objects, which you can watch for changes, and respond accordingly. Here's are the steps of a response: Asynchronous Reponse 1. Media plug-in sends current position, media length, etc. to Flash 2. Flash monitors changes to variables (using watch), and responds accordingly (updates the label that shows the current time/media length) The asynchronous responses can happen at any time. Which means any labels/visuals that depends on the state of the underlying plug-in, should always be hooked directly to the data that is send from Velocity. And that's the essence of Velocity. The skin tells Velocity what to do, and the skin displays the state of the underlying plug-ins. Other than that, you can do what you like with the skins, transitions etc. And now for some info, on how to actually call the methods, and how to pull data out. There are two AS classes that you need to include. which are Velocity.as and JSON.as. These are in a package called com.hatoum.velocity. You then need to initialise the Flash-side Velocity plug-in, and this is a little hairy because of the way Flash loads classes, and Velcoity heavily uses static classes. So if you look at the first Frame, it has a call to: import com.hatoum.velocity.Velocity; Velocity.initialize(3); which tells velocity to connect to the Java server, and then jump to the designated frame when it's done. If it fails, it will just continue playing. So in the above example, Flash starts at frame 1, tries to initialise, if it fails, it'll show frame 2 (which says "there has been a problem" etc), and if it succeeds, then it will just to frame 3, which will show controls etc. So let's say we got to frame 3, and it's all connected and running. Imagine we just have one "play" button for now. Code:
play_btn.onRelease = function() {
Velocity.getPlugin("Media").invoke("play" + " c:/mysong.mp3" );
};
It's worth noting at this point that every plug-in has a corresponding accessBean, which is a DTO (data transfer object). This is where the state of a plug-in is held. So for the Media plug-in, this will contain the current track name, its length, the playlist entries, and so forth. In a similar way to getting the plug-in to do something, we can also get properties from its accessBean by doing this: Code:
var length = Velocity.getAccessBean("Media").length;
Code:
// setup a method that does what we want, which is to update the time label int his case
var currentTimeWatcher:Function = function (prop, oldVal, newVal) {
var _length:Number = Velocity.getAccessBean("Media").length;
var _time_seconds:Number = newVal%60;
_time_lbl.text = _time_seconds+"/"+_length;
};
// then add a watcher to the desired variable, and give it the method we setup above
Velocity.getAccessBean("Media").watch("timePos", currentTimeWatcher);
The same principle applies to list boxes. To add a change listener to the playlist for example, you do: Code:
var playlistWatcher:Function = function (prop, oldVal, newVal) {
playlist_ls.dataProvider = newVal;
};
Velocity.getAccessBean("Media").watch("playlist", playlistWatcher);
A list of the available plug-ins, methods and fields can be seen in the threads below. I think the above should be enough to get the ball rolling. I appreciate that the methods are not all 100% self explanatory, and that it makes 100% sense only in my head, so please fire any questions this way. You can put the Flash plugin into a more verbose debug mode, by setting the _debug field tio true, in com/hatoum/velocity/Velocity.as |
|
__________________
Current: [BMW Nav Research]|[BMW E46 ///M3 Convertible] Previous: [BMW E31 850CSi]|[BMW E39 535i]|[BMW HVAC Research]|[IBUS Scrolling Text]|[BMPuter]|[Velocity]|[TomTom]|[Vision]|[Space Navigator Driver]|[Super Fast Boot] Last edited by Sama; 18-06-2007 at 11:17 PM. |
|
|
|
|
|
|
#2 |
|
Advanced Member
Join Date: Apr 2006
Location: London
Posts: 2,154
My Garage: - BMW E46 ///M3 Convertible - BMW E39 535i - BMW E31 850CSi - BMW E36 328i - BMW E30 320i ![]() |
THE MEDIA PLUGIN
Properties playlist currentPosition fileName percentPos timePos length videoCodec videoBitrate videoResolutionX videoResolutionY audioCodec audioBitrate audioSamplesFrequency audioSamplesChannels metaTitle metaArtist metaAlbum metaYear metaComment metaTrack metaGenre voFullscreen subVisibility isPlaying Commands arbitaryCommand(string) osd(value) osdShowText(text) keyDownEvent(key) subSelect(value) subVisibility(subVisible) switchAudio(audioTrack) switchRatio(ratio) frameStep() seek(position) seek(position, relative) audioDelay(delay, relative) pause() mute() clearList() play() play(fileOrIndex) remove(indexOrIndices) moveUp(indexOrIndices) savePlaylist(listName) moveDown(indexOrIndices) addRecursively(aDirectory) addAll(aDirectory) add(aFile) previous() next() stop() volume(volValue, relative) toggleFullScreen() speedSet(speed) contrast(contrast, relative) gamma(gamma, relative) brightness(brightness, relative) hue(hue, relative) saturation(saturation, relative) Note: The relative parameter is either a 0 or a 1, to indicate if the value change you're applying is a relative one. That means, if the volume was currently at 50% and you set the volume like this: Code:
volu = 10; // this would normally come from a button or something;
Velocity.getPlugin("Media").invoke("volume " + volu + "," + "0");
But if you change the relative bit like this: Code:
volu = 10; // this would normally come from a button or something
Velocity.getPlugin("Media").invoke("volume " + volu + "," + "1");
|
|
__________________
Current: [BMW Nav Research]|[BMW E46 ///M3 Convertible] Previous: [BMW E31 850CSi]|[BMW E39 535i]|[BMW HVAC Research]|[IBUS Scrolling Text]|[BMPuter]|[Velocity]|[TomTom]|[Vision]|[Space Navigator Driver]|[Super Fast Boot] Last edited by Sama; 18-06-2007 at 11:34 PM. |
|
|
|
|
|
|
#3 |
|
Advanced Member
Join Date: Apr 2006
Location: London
Posts: 2,154
My Garage: - BMW E46 ///M3 Convertible - BMW E39 535i - BMW E31 850CSi - BMW E36 328i - BMW E30 320i ![]() |
THE FILE BROWSER PLUGIN
Properties refreshRoots() selectDirectory(input) select(input) filter(filter) clearFilters() refresh() Commands roots currentDirectory currentFile directoriesView filesView mixedView currentFileStale |
|
__________________
Current: [BMW Nav Research]|[BMW E46 ///M3 Convertible] Previous: [BMW E31 850CSi]|[BMW E39 535i]|[BMW HVAC Research]|[IBUS Scrolling Text]|[BMPuter]|[Velocity]|[TomTom]|[Vision]|[Space Navigator Driver]|[Super Fast Boot] Last edited by Sama; 18-06-2007 at 11:37 PM. |
|
|
|
|
|
|
#4 |
|
Advanced Member
Join Date: Apr 2006
Location: London
Posts: 2,154
My Garage: - BMW E46 ///M3 Convertible - BMW E39 535i - BMW E31 850CSi - BMW E36 328i - BMW E30 320i ![]() |
Reserved For Future Plugins
|
|
__________________
Current: [BMW Nav Research]|[BMW E46 ///M3 Convertible] Previous: [BMW E31 850CSi]|[BMW E39 535i]|[BMW HVAC Research]|[IBUS Scrolling Text]|[BMPuter]|[Velocity]|[TomTom]|[Vision]|[Space Navigator Driver]|[Super Fast Boot] Last edited by Sama; 18-06-2007 at 11:40 PM. |
|
|
|
|
|
|
#5 |
|
Advanced Member
Join Date: Apr 2006
Location: London
Posts: 2,154
My Garage: - BMW E46 ///M3 Convertible - BMW E39 535i - BMW E31 850CSi - BMW E36 328i - BMW E30 320i ![]() |
Reserved For Future Plugins
|
|
__________________
Current: [BMW Nav Research]|[BMW E46 ///M3 Convertible] Previous: [BMW E31 850CSi]|[BMW E39 535i]|[BMW HVAC Research]|[IBUS Scrolling Text]|[BMPuter]|[Velocity]|[TomTom]|[Vision]|[Space Navigator Driver]|[Super Fast Boot] Last edited by Sama; 18-06-2007 at 11:40 PM. |
|
|
|
|
|
|
#6 |
|
Advanced Member
Join Date: Apr 2006
Location: London
Posts: 2,154
My Garage: - BMW E46 ///M3 Convertible - BMW E39 535i - BMW E31 850CSi - BMW E36 328i - BMW E30 320i ![]() |
Reserved For Future Plugins
|
|
__________________
Current: [BMW Nav Research]|[BMW E46 ///M3 Convertible] Previous: [BMW E31 850CSi]|[BMW E39 535i]|[BMW HVAC Research]|[IBUS Scrolling Text]|[BMPuter]|[Velocity]|[TomTom]|[Vision]|[Space Navigator Driver]|[Super Fast Boot] Last edited by Sama; 18-06-2007 at 11:40 PM. |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
|