Case Studies from the JavaFX™ Technology World

Raghavan N. Srinivas, JavaFX Technology Evangelist

TS-7372 Agenda

ParleysFX Video Integration Showcase by Jo Voordeckers Visual JavaFX software by Jeff Martin

2008 JavaOneSM Conference | .sun.com/javaone | 2 Case Studies from the JavaFX™ Technology World ParleysFX video integration showcase

Jo Voordeckers, Technical Project Lead

TS-7372 Learn how to integrate video with Java™ and JavaFX™ technology

2008 JavaOneSM Conference | java.sun.com/javaone | 4 Agenda

Introducing Parleys.com What do we need? Java Media Framework (JMF) technology Introducing FOBS Streaming Integrating with JavaFX technology

2008 JavaOneSM Conference | java.sun.com/javaone | 5 Introducing Parleys.com

e-learning site found by Stephan Janssen • Audio/video talks from JavaPolis, SpringOne, Jazoon, EclipseCon and JavaZone

Visitors can comment, tag and vote for their favorite presentations

Uses web 2.0 features with a lightweight Java Platform, Enterprise Edition (Java EE) back-end

Flex/AIR front-end enables offline viewing and delivers a rich user experience

2008 JavaOneSM Conference | java.sun.com/javaone | 6 ParleysFX Parleys.com

2008 JavaOneSM Conference | java.sun.com/javaone | 7 What do we need?

Technology Sufficient? Platform independent Java™ Rich user experience JavaFX™ / JOGL Comm. with JavaEE backend HTML java.util.regex.* JSON JSONLib / JavaFX™ XML javax.xml.xpath.* Flash FLV Audio / Video JMF

2008 JavaOneSM Conference | java.com.sun/javaone | 8 JMF Technology is dead…right!?dead…right!

Development paralyzed since 2003

Doesn’t support any of today’s popular codecs: FlashVideo, MPEG-4 ASP (aka DiVX), MPEG-4 AVC (aka H.264)

“In the current world of YouTube, Flash, and iTunes, video has gone from a niche capability to a checkbox item that all platforms must support.” – Chet Haase

Sun’s is working on Java Media Components (JMC)

2008 JavaOneSM Conference | java.sun.com/javaone | 9 Introducing FOBS

Ffmpeg OBjectS is a set of object oriented APIs for media

C++ Wrapper around ffmpeg LGPL media library • Native libraries for Windows, Linux, Mac (x86 & PPC)

JMF API Plugin: Fobs4JMF

Add support for flv, ogg, theora, xvid, h264, … to any JMF API application

2008 JavaOneSM Conference | java.sun.com/javaone | 10 FOBS tips & tricks

Add native library in JNLP descriptor

Register Fobs4JMF plugin dynamically •@see my blog: http://javatrack.blogspot.com

2008 JavaOneSM Conference | java.sun.com/javaone | 11 Fobs4JMF + Swing™ Code Sample

FobsUtil.initFobs(); // Register plugin + load lib

Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);

Player mediaPlayer = Manager.createRealizedPlayer(url);

panel.add(mediaPlayer.getVisualComponent());

mediaPlayer.start();

2008 JavaOneSM Conference | java.sun.com/javaone | 12 Streaming Flash™ Video (FLV)

Only basic support for RTP and HTTP in JMF API and ffmpeg

Option 1: progressive download

Buffered Downloading

• Disadvantage: No seek!

Option 2: intelligent progressive download • Read FLV metadata, download specific position (HTTP Range header)

Meta Buffered Downloading

2008 JavaOneSM Conference | java.sun.com/javaone | 13 Integrating with JavaFX Platform

JMF API can render on a Swing JComponent

JavaFX platform supports wrapping Swing components • SwingWidget on the JavaFX platform Wiki • ComponentWidget (JavaFX compiler)

JavaFX platform wrapper is unaware of Swing component refreshes • @see my blog: http://javatrack.blogspot.com

// Scheduled repaint on video canvas @ 25 FPS attribute timerTick:Integer on replace { videoWidget.getComponent().repaint(); }

2008 JavaOneSM Conference | java.sun.com/javaone | 14 Summary

Java platform / JavaFX platform does rich media

JMF technology is dead but Fobs4JMF fills the gap • look out for Java Media Components API

Streaming can be simulated for the user

Mixing Swing and JavaFX platform requires redraw triggers

Parleys.com is a great eLearning site

2008 JavaOneSM Conference | java.sun.com/javaone | 15 For More Information

Contact me or read my blog • [email protected] • http://javatrack.blogspot.com

Parleys.com • BOF-4798 Parleys.com: An Adobe Flex/AIR and JavaFX™ Case Study • Web2.0 and Flex version: www.parleys.com

FOBS & Fobs4JMF • http://fobs.sourceforge.net/

JavaFX platform • http://openjfx.dev.java.net/ • http://jfx.wikia.com/

Flash Video file format • http://osflash.org/flv

2008 JavaOneSM Conference | java.sun.com/javaone | 16 Case Studies from the JavaFX™ Technology World

Jeff Martin, CEO, ReportMill Software Inc. Visual JavaFX Platform Application Design requires aspects of many applications Page Layout Word Processing Illustration Animation UI Building UI Binding Reporting Presentation And more…

2008 JavaOneSM Conference | java.sun.com/javaone | 18 Drawing JavaFX Software - Graphics Elements Draw lines, boxes, ovals Draw polygons and edit vertices Draw free-form lines with curve fitting and spline editing Add text boxes with interactive text editing and rich text support Drag and drop Images, Video and Sound files Path Geometry, 3D, Morphing, etc.

2008 JavaOneSM Conference | java.sun.com/javaone | 19 Drawing JavaFX Software - Stroke, Fill and Filter Image Effects Configure stroke in stroke inspector: Line width, color, cap, join, dash Configure fill in fill inspector: Solid, Gradient, Texture Configure filter in filter inspector: Shadow, Reflection, Emboss, Blur Configure transparency in Paint/Fill inspector

2008 JavaOneSM Conference | java.sun.com/javaone | 20 Drawing JavaFX Software - Animation

Configure attributes at first time Configure attributes at another time Rio automatically interpolates values Location, Size, Rotation, Scale, Skew, Stroke, Fill, Opacity, etc. Set interpolation: Linear, Ease In/Out, Bounce, Periodic Draw animation path for selected object

2008 JavaOneSM Conference | java.sun.com/javaone | 21 Drawing JavaFX Software - Application Components Drag & drop components: Buttons, Sliders, Text, ComboBox, Table, Tree, etc. Group in containers: Panel, Tabbed-Pane, Scroll-Pane, Split-Pane Configure attributes in dedicated inspectors

2008 JavaOneSM Conference | java.sun.com/javaone | 22 Data Binding

• Create Binders for Database (JDBC), POJOs (using XML) or Collections • Drag keys to Java 2D™ API and Swing components • Attach to appropriate aspect: Value, Visible, Enabled, Location, Size, etc. • Configure expressions instead of just keys if desired

2008 JavaOneSM Conference | java.sun.com/javaone | 23 Deployment

One-Click Applet Generation One-Click Stand-Alone application preview (in any platform Look and Feel) Copy XML file to server Add Java Rivlet - provides hook to customize loading, setting and responding

2008 JavaOneSM Conference | java.sun.com/javaone | 24 Client Viewer

Viewer supports application pages and document pages Supports document save, print Supports document move, text selection, area selection Viewer Page forward/back-tracking Interactive find Page zoom/Page navigation Animated, drop-in tool bars

Viewer with drop-in document controls

2008 JavaOneSM Conference | java.sun.com/javaone | 25 Raghavan N. Srinivas, Technology Evangelism Jo Voordeckers, Technical Project Lead Jeff Martin, CEO, ReportMill Software Inc.

TS-7372

2008 JavaOneSM Conference | java.sun.com/javaone | 26