Analysis
Overview
The media engine is responsible for rendering audio and video. Write a module that implements the video and audio interfaces found in org.sophie2.main.media.fobs.
Audio should play regardless of whether it is being used by a scene or not. Video does not render directly to the screen. Instead the frame should be grabbed from the Player in order for the scene to display it.
It seems as if JMF is a good place to start for implementing the engine. Start by looking at:
http://java.sun.com/javase/technologies/desktop/media/jmf/reference/faqs/index.html#what
You will also create an extension point that wraps the class and provides a mechanism for the scene to get the audio or video handler.
Task requirements
- Write a module for media playback
- Start with JMF
- Expose an extension point for access to the handlers
- Implement the Interface found in org.sophie2.main.media.fobs
- Force the scene to repaint on playing. The grabbing of the frame should happen by equal intervals.
Task result
The result of this task is source code.
Implementation idea
- Note that JMF can only do mp3 on windows, so we need to figure out what to do about this because supporting mp3 is important for other platforms as well.
Related
How to demo
- Insert a video frame and watch the video.
- It should play smoothly.
Design
The implementation so far has the following design:
- there is a module named - org.sophie2.base.media, which defines the model for the media and two extension points - one for Video and one for Audio
- MediaInfo is the class which holds meta data for the media
- MediaState describes the current state of the media - is it playing, what is the volume, etc.
- MediaSource defines the source for the media - is has an URL and media data which is binary *there is a module named - org.sophie2.main.media.fobs, which add two extension for the presently described extension points - one for Video and one for Audio. The engine used is JMF
We need to now the MediaState throughout media's playing (useful for buttons' appearance and slide bar) and the scene should also repaint while media is playing (for videos).
- Video is providing ImmImages that are drawn while playing. We should force manually the Scene to obtain these images.
- The MediaState should also be kept somewhere and the storing of the MediaState should also go forced manually.
To create this functionality we should use a Timer which will set the MediaState and kept the Scene in sync. There will be a single Timer that iterates over the media players and sets the media state for every one of them.
- Create a class PlayerEntry that is a descendant of BaseProObject and it will be a class representing an entry for the player registry. It should keep consistent media ID, player and MediaState. The media sate should be updated manually so that it stays consistent with the current state of the player. The player registry HashMap should be changed to a ProList containing player entries. The MediaState will be set by the Timer.
The Timer instance will be in JMFVideoEngine and it will update (force redraw of the Scene and change the MediaState of every PlayerEntry) 15 times in a second. The update will happen only if there's a runnig video.
- We should iterate over the player entries and set the state for every player.
- In the SimpleSceneVisual we should take the current state for every VideoSceneElement which is also the media id for the video it displays.
This is a link to a reference video: http://www.sophie2.org/trac/browser/trunk/sophie2-platform/modules/org.sophie2.base.media/src/test/resources/demo.avi
How to demo is described in the Analysis section...you should have an implementation though
Implementation
Implementation is done according to the desing. Changesets:
The code was merged to the trunk in [2604] along with the MEDIA_FRAME_CONTROLS_R0 code.
Testing
Comments
Alex, http://java.sun.com/javase/technologies/desktop/media/jmf/reference/faqs/index.html#what might be a good place to start? - Steve
desc("making the main engine better ")
Is this task about rendering media, such as video and audio? How should it work with scenes and content objects?
Publish extension for playing video handler and audio handler
org.sophie2.main.media.fobs is the interface for the engine
audio should play even if grab frames is not called
wrap jmf class in an extension and publish it
Attachments
- SimpleSceneRedrawVideoDemoTest.java (3.5 KB) - added by nenko 16 years ago.
-
MEDIA_ENGINE_IMPL_MAIN_R0-28.04.2009.patch
(8.7 KB) -
added by nenko 16 years ago.
Implementation patch
- MEDIA_ENGINE_IMPL_MAIN_R0-28.04.2009-fixed-test.patch (8.5 KB) - added by nenko 16 years ago.