MEDIA_ENGINE_IMPL_MAIN_R0: MEDIA_ENGINE_IMPL_MAIN_R0-28.04.2009.patch
File MEDIA_ENGINE_IMPL_MAIN_R0-28.04.2009.patch, 8.7 KB (added by nenko, 16 years ago) |
---|
-
src/main/java/org/sophie2/main/media/fobs/JMFVideoEngine.java
### Eclipse Workspace Patch 1.0 #P org.sophie2.main.media.fobs
38 38 /** 39 39 * Default constructor 40 40 */ 41 public JMFVideoEngine() { 41 public JMFVideoEngine() { 42 42 this.playerRegistry = new HashMap<Object, Player>(); 43 43 } 44 44 … … 79 79 } 80 80 ImmSize imageSize = null; 81 81 if (currentFrame!=null){ 82 System.out.println("weeeee");83 82 imageSize= new ImmSize(currentFrame.getWidth(),currentFrame.getHeight()); 84 83 }else imageSize = new ImmSize(160, 120); 85 84 player.stop(); -
src/main/java/org/sophie2/main/func/media/logic/VideoLogic.java
#P org.sophie2.main.func.media
50 50 } 51 51 52 52 @Override 53 @SuppressWarnings("cast")54 53 public boolean handle(EventR3 event) { 55 54 InsertVideoItem source = event.getSource(InsertVideoItem.class); 56 55 AppMainWindow sourceAppMainWindow = AppMainWindow.findMainWindow(source); 57 56 BookView targetBDW = (BookView)sourceAppMainWindow.booksDesktop().get().currentWindow().get(); 58 57 59 PageWorkArea targetSPWA = (PageWorkArea)targetBDW.workArea().get();58 PageWorkArea targetSPWA = targetBDW.workArea().get(); 60 59 VideoBookResource res = createVideoResource( 61 60 targetSPWA, targetBDW.book().get().get(Book.class)); 62 61 if (res==null){ 63 System.out.println("The resourse is null");62 logger().error("The resource is null"); 64 63 return false; 65 66 64 } 67 65 68 66 insertNewFrame(targetSPWA, res); -
src/main/java/org/sophie2/main/func/media/view/VideoContentView.java
12 12 import org.sophie2.main.func.media.model.resources.VideoBookResource; 13 13 14 14 /** 15 * Concrete implementation of MediaContentView for video. It constructs 16 * an videoscene element {@link VideoSceneElement} using the data from model15 * Concrete implementation of MediaContentView for video. It constructs an video 16 * scene element {@link VideoSceneElement} using the data from model 17 17 * {@link VideoFrameContent}. 18 18 * 19 19 * @author alex … … 41 41 /** 42 42 * Concrete implementation of {@link VideoSceneElement}. 43 43 */ 44 class VideoContentSceneElement extends DefaultVideoSceneElement {44 class VideoContentSceneElement extends DefaultVideoSceneElement { 45 45 @Override 46 46 protected void setupDynamic() { 47 47 if (model().get() != null 48 48 && model().get().mainResource().get() != null) { 49 VideoBookResource resource = 50 model().get().mainResource().get().get( 51 VideoBookResource.class, model().get()); 49 VideoBookResource resource = model().get().mainResource().get() 50 .get(VideoBookResource.class, model().get()); 52 51 53 52 // set MediaSource 54 53 source().set((BinDataSource) resource.source().get()); 55 54 // set MediaInfo 56 55 mediaInfo().set(resource.info().get()); 57 // request initial state - volume = 1, position = 0, playing = true 56 // request initial state - volume = 1, position = 0, playing = 57 // true 58 58 requestedState().set(new MediaState(1, -1, true)); 59 59 60 60 } … … 62 62 ImmSize dimensions = mediaInfo().get().getDimensions(); 63 63 if (dimensions != null && parent().get() != null) { 64 64 65 ImmSize contentSize = parent().get().model().get().contentSize().get(); 65 ImmSize contentSize = parent().get().model().get() 66 .contentSize().get(); 66 67 float x = contentSize.getWidth() / dimensions.getWidth(); 67 68 float y = contentSize.getHeight() / dimensions.getHeight(); 68 69 space().set(ImmMatrix.IDENTITY.scale(x, y)); -
src/main/java/org/sophie2/main/func/media/view/InsertVideoItem.java
13 13 14 14 /** 15 15 * The insert video item. 16 * 16 17 * @author milo 17 * 18 * 18 19 */ 19 20 @SkinElementId("app.menus.insert.insert-video-menu-item") 20 21 public class InsertVideoItem extends AppMenuItem { … … 22 23 @SuppressWarnings("unused") 23 24 @SkinPartDef 24 25 private static void defineSkin(ElementSkinPart part) { 25 part.add(TITLE_PROP_ID, "Video ");26 part.add(TITLE_PROP_ID, "Video..."); 26 27 part.add(TOOL_TIP_PROP_ID, "Add a video frame to the current page."); 27 28 part.add(MNEMONIC_PROP_ID, KeyEvent.VK_V); 28 29 } 30 29 31 @Override 30 32 public void clicked() { 31 33 LogicR3.fire(new EventR3(this, null, null, null, Ids.ADD_VIDEO_FRAME)); … … 39 41 /** 40 42 * The media operation supported by the video item. 41 43 * 42 */43 44 45 46 47 48 44 */ 45 public enum Ids { 46 /** 47 * A video frame should be added. 48 */ 49 @EventParams( {}) 50 ADD_VIDEO_FRAME 49 51 50 52 } 51 53 52 54 } 53 -
src/main/java/org/sophie2/main/scene/simple/SimpleSceneVisual.java
#P org.sophie2.main.scene.simple
5 5 import java.awt.Graphics2D; 6 6 import java.awt.Rectangle; 7 7 import java.awt.geom.Area; 8 import java.util.Date; 8 9 import java.util.List; 10 import java.util.Timer; 11 import java.util.TimerTask; 9 12 10 13 import javax.swing.JPanel; 14 import javax.swing.SwingUtilities; 11 15 12 16 import org.sophie2.base.commons.util.position.ImmRect; 13 17 import org.sophie2.base.scene.SceneVisual; 14 18 import org.sophie2.base.scene.helpers.ElementHelper; 15 19 import org.sophie2.base.scene.helpers.SceneHelper; 20 import org.sophie2.base.scene.interfaces.MediaSceneElement; 16 21 import org.sophie2.base.scene.interfaces.Scene; 22 import org.sophie2.base.scene.interfaces.SceneElement; 17 23 import org.sophie2.base.skins.SkinElementId; 18 24 import org.sophie2.base.visual.BaseVisualElement; 19 25 import org.sophie2.base.visual.interaction.SwingEventAdapter; … … 55 61 protected ScenePanel create() { 56 62 ScenePanel res = new ScenePanel(); 57 63 SwingEventAdapter.registerComponent(res, 58 SimpleSceneVisual.this, null, res);64 SimpleSceneVisual.this, null, res); 59 65 return res; 60 66 } 61 67 … … 101 107 return getBean().makeProp(swingComponent.class); 102 108 } 103 109 110 @SuppressWarnings("unused") 111 private Prop<Timer> sceneTimer() { 112 class sceneTimer extends ResourceProperty<Timer> { 113 114 final Runnable repaintScene = new Runnable() { 115 116 @Override 117 public void run() { 118 swingComponent().get().repaint(); 119 } 120 121 }; 122 123 class MyTimerTask extends TimerTask { 124 125 private boolean isRunning = false; 126 127 @Override 128 public void run() { 129 if (shouldRedraw(scene().get().rootElement().get())) { 130 this.isRunning = true; 131 SwingUtilities 132 .invokeLater(sceneTimer.this.repaintScene); 133 } 134 } 135 136 public boolean isRunning() { 137 return this.isRunning; 138 } 139 140 } 141 142 final MyTimerTask timerTask = new MyTimerTask(); 143 144 final boolean shouldRedraw(SceneElement root) { 145 for (SceneElement next : root.subElements().get()) { 146 if (MediaSceneElement.class.isInstance(next)) { 147 if (((MediaSceneElement) next).requestedState().get() 148 .isPlaying()) { 149 return true; 150 } 151 } 152 153 if (next != null && shouldRedraw(next)) { 154 return true; 155 } 156 } 157 158 return false; 159 } 160 161 @Override 162 protected Timer create() { 163 return new Timer("scene-repaint-timer", true); 164 } 165 166 @Override 167 protected void destroy(Timer res) { 168 // nothing... for now 169 } 170 171 @Override 172 protected void setup(Timer res) { 173 Scene scene = scene().get(); 174 if (swingComponent().get() != null && scene != null 175 && scene.rootElement().get() != null 176 && shouldRedraw(scene.rootElement().get())) { 177 if (this.timerTask.isRunning() == false) { 178 res.schedule(this.timerTask, new Date(), 1000 / 15); 179 } 180 } 181 } 182 } 183 184 return getBean().makeProp(sceneTimer.class); 185 } 186 104 187 // /** 105 188 // * @return property. 106 189 // */