94 * from initDisplayMode function. |
94 * from initDisplayMode function. |
95 */ |
95 */ |
96 // Global??? yes because we need to remove it from player listener, while finalizer will be called |
96 // Global??? yes because we need to remove it from player listener, while finalizer will be called |
97 private VideoItem iVideoItem; |
97 private VideoItem iVideoItem; |
98 |
98 |
|
99 ESWTinitializeListener iESWTinitializeListener; |
99 |
100 |
100 /** |
101 /** |
101 * Constructor of VideoControl |
102 * Constructor of VideoControl |
102 * @param player |
103 * @param player |
103 */ |
104 */ |
104 public VideoControl(Player player) |
105 public VideoControl(Player player) |
105 { |
106 { |
106 this.iPlayer=player; |
107 this.iPlayer=player; |
|
108 iESWTinitializeListener=(AnimationPlayer)iPlayer; |
107 } |
109 } |
108 /** |
110 /** |
109 * |
111 * |
110 */ |
112 */ |
111 private Finalizer mFinalizer = new Finalizer() |
113 private Finalizer mFinalizer = new Finalizer() |
224 if (iStatus == NOT_INITIALIZED) |
226 if (iStatus == NOT_INITIALIZED) |
225 { |
227 { |
226 throw new IllegalStateException( |
228 throw new IllegalStateException( |
227 "VideoControl.initDisplayMode() not called yet"); |
229 "VideoControl.initDisplayMode() not called yet"); |
228 } |
230 } |
229 Image image=((AnimationPlayer)iPlayer).getCurrentFrame(aImageType); |
231 String supportedFormat=System.getProperty("video.snapshot.encodings"); |
230 byte bytArry[]= null;//getByteArray(image); |
232 if (aImageType==null) |
231 // TODO Enable the permission check |
233 { |
232 // Commented out below line, because I was getting exception |
234 aImageType=supportedFormat.substring(0, supportedFormat.indexOf(' ')); |
233 // Check the permission here, so 'the moment' is not lost? |
235 } |
234 //Security.ensurePermission(PERMISSION, PERMISSION, PERM_ARGS); |
236 else if (supportedFormat.indexOf(aImageType)==-1) |
|
237 { |
|
238 throw new MediaException("Unsupported image type: " + aImageType); |
|
239 } |
|
240 byte data[]=((AnimationPlayer)iPlayer).getCurrentFrame(aImageType); |
|
241 //TODO before returning the check permissions here |
|
242 // we are making late check here, so that moment should not be lost. |
|
243 |
235 // ApplicationUtils appUtils = ApplicationUtils.getInstance(); |
244 // ApplicationUtils appUtils = ApplicationUtils.getInstance(); |
236 // PlayerPermission per = new PlayerPermission("audio/video recording","snapshot"); |
245 // PlayerPermission per = new PlayerPermission("audio/video recording","snapshot"); |
237 // appUtils.checkPermission(per); |
246 // appUtils.checkPermission(per); |
238 return bytArry; |
247 return data; |
239 } |
248 } |
240 |
249 |
241 /** |
250 /** |
242 * Return the height of the source video. The height must be a positive number. |
251 * Return the height of the source video. The height must be a positive number. |
243 * @return the height of the source video. |
252 * @return the height of the source video. |
285 if (aArg!=null && aArg.equals(Control.class.getName())) |
294 if (aArg!=null && aArg.equals(Control.class.getName())) |
286 { |
295 { |
287 // Following line will return the same Display object |
296 // Following line will return the same Display object |
288 // Which is created in Midlet |
297 // Which is created in Midlet |
289 iDisplay =Display.getDefault(); |
298 iDisplay =Display.getDefault(); |
|
299 iESWTinitializeListener.notifyDisplayAvailable(iDisplay); |
290 } |
300 } |
291 else |
301 else |
292 { |
302 { |
293 // Get the Display object of ESWT |
303 // Get the Display object of ESWT |
294 iDisplay = com.nokia.mj.impl.nokialcdui.LCDUIInvoker.getEswtDisplay(); |
304 iDisplay = com.nokia.mj.impl.nokialcdui.LCDUIInvoker.getEswtDisplay(); |
|
305 iESWTinitializeListener.notifyDisplayAvailable(iDisplay); |
295 } |
306 } |
296 if (aMode == USE_GUI_PRIMITIVE) |
307 if (aMode == USE_GUI_PRIMITIVE) |
297 { |
308 { |
298 Object guiObject = null; |
309 Object guiObject = null; |
299 if (aArg == null) |
310 if (aArg == null) |
310 { |
321 { |
311 guiObject = initDynamicDisplayMode(aArg); |
322 guiObject = initDynamicDisplayMode(aArg); |
312 // Since it is eswtControl itself so no need of LCDUIInvoker here |
323 // Since it is eswtControl itself so no need of LCDUIInvoker here |
313 // assign it in iControl and return immediately from here |
324 // assign it in iControl and return immediately from here |
314 iControl=(Control)guiObject; |
325 iControl=(Control)guiObject; |
|
326 iESWTinitializeListener.notifyControlAvailable(iControl); |
315 // Now we will change the status, when MIDlet developer will call the setParent |
327 // Now we will change the status, when MIDlet developer will call the setParent |
316 iStatus = USE_GUI_PRIMITIVE; |
328 iStatus = USE_GUI_PRIMITIVE; |
317 return iControl; |
329 return iControl; |
318 } |
330 } |
319 } |
331 } |
346 throw new java.lang.IllegalArgumentException( |
358 throw new java.lang.IllegalArgumentException( |
347 "For USE_DIRECT_VIDEO mode argument should not be null"); |
359 "For USE_DIRECT_VIDEO mode argument should not be null"); |
348 } |
360 } |
349 iControl = com.nokia.mj.impl.nokialcdui.LCDUIInvoker |
361 iControl = com.nokia.mj.impl.nokialcdui.LCDUIInvoker |
350 .getEswtControl(aArg); |
362 .getEswtControl(aArg); |
351 |
363 //in this case Control will be provided immediately |
|
364 iESWTinitializeListener.notifyControlAvailable(iControl); |
352 //If USE_DIRECT_VIDEO is set, the video by default is not |
365 //If USE_DIRECT_VIDEO is set, the video by default is not |
353 //shown when the canvas is displayed until setVisible(true) is called |
366 //shown when the canvas is displayed until setVisible(true) is called |
354 //iIsControlVisible variable of AnimationPlayer class decides, whether |
367 //iIsControlVisible variable of AnimationPlayer class decides, whether |
355 //animation should be visible or not, and by default it is true; |
368 //animation should be visible or not, and by default it is true; |
356 //So making it false here. |
369 //So making it false here. |
370 * Creates the VideoItem object of size of image(gif) |
383 * Creates the VideoItem object of size of image(gif) |
371 * @return VideoItem(a CustomItem ) object |
384 * @return VideoItem(a CustomItem ) object |
372 */ |
385 */ |
373 private Object initLCDUI() |
386 private Object initLCDUI() |
374 { |
387 { |
375 final String DEBUG_STR="VideoControl::initLCDUI()"; |
|
376 Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR+"+"); |
|
377 iVideoItem = new VideoItem(((AnimationPlayer)iPlayer).getImageDimension()); |
388 iVideoItem = new VideoItem(((AnimationPlayer)iPlayer).getImageDimension()); |
378 iPlayer.addPlayerListener(iVideoItem); |
389 iPlayer.addPlayerListener(iVideoItem); |
379 iStatus = USE_GUI_PRIMITIVE; |
390 iStatus = USE_GUI_PRIMITIVE; |
380 Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR+"-"); |
|
381 return iVideoItem; |
391 return iVideoItem; |
382 } |
392 } |
383 |
393 |
384 /** |
394 /** |
385 * Initializes USE_GUI_PRIMITIVE mode when null parameter is given to |
395 * Initializes USE_GUI_PRIMITIVE mode when null parameter is given to |
516 { |
526 { |
517 throw new IllegalStateException( |
527 throw new IllegalStateException( |
518 "VideoControl.initDisplayMode() not called yet"); |
528 "VideoControl.initDisplayMode() not called yet"); |
519 } |
529 } |
520 //if this is in case of form, return silently |
530 //if this is in case of form, return silently |
|
531 // No need to display the CustomItem in full screen mode |
521 //This is as per earlier NOKIA implementation, |
532 //This is as per earlier NOKIA implementation, |
522 if (iVideoItem!=null) |
533 if (iVideoItem!=null) |
523 { |
534 { |
524 return; |
535 return; |
525 } |
536 } |
552 /* (non-Javadoc) |
563 /* (non-Javadoc) |
553 * @see javax.microedition.media.control.VideoControl#setDisplayLocation(int, int) |
564 * @see javax.microedition.media.control.VideoControl#setDisplayLocation(int, int) |
554 */ |
565 */ |
555 public void setDisplayLocation(int aX, int aY) |
566 public void setDisplayLocation(int aX, int aY) |
556 { |
567 { |
|
568 if (iStatus == USE_GUI_PRIMITIVE) |
|
569 { |
|
570 // In USE_GUI_PRIMITIVE mode, this call will be ignored. |
|
571 return; |
|
572 } |
|
573 if (iStatus != USE_DIRECT_VIDEO) |
|
574 { |
|
575 // This method only works when the USE_DIRECT_VIDEO mode is set. |
|
576 throw new IllegalStateException(); |
|
577 } |
557 // Need to ignore this call in case of USE_GUI_PRIMITIVE |
578 // Need to ignore this call in case of USE_GUI_PRIMITIVE |
558 // in case of customItem, we are getting canvasExtension as control |
579 // in case of customItem, we are getting canvasExtension as control |
559 // and in this case we need to ignore the setDisplayLocation call. |
580 // and in this case we need to ignore the setDisplayLocation call. |
560 // it is also possible that iControl may be null( it will be null until and unless |
581 // it is also possible that iControl may be null( it will be null until and unless |
561 // notifyControlAvailable function is not get called) |
582 // notifyControlAvailable function is not get called) |
562 System.out.println("VideoControl::setDisplayLocation() curretn status is "+iStatus); |
583 if (iControl==null)// || (iControl instanceof org.eclipse.swt.internal.extension.CanvasExtension)) |
563 if (iControl==null || (iControl instanceof org.eclipse.swt.internal.extension.CanvasExtension)) |
|
564 return ; |
584 return ; |
565 ((AnimationPlayer)iPlayer).setDisplayLocation(aX, aY); |
585 ((AnimationPlayer)iPlayer).setDisplayLocation(aX, aY); |
566 } |
586 } |
567 |
587 |
568 /** |
588 /** |
630 } |
650 } |
631 /*******************************FOLLOWING FUNCTIONS ARE USED FOR INTERNAL PURPOSE***********************/ |
651 /*******************************FOLLOWING FUNCTIONS ARE USED FOR INTERNAL PURPOSE***********************/ |
632 /** |
652 /** |
633 * |
653 * |
634 * @return Display object retrieved from ESWT |
654 * @return Display object retrieved from ESWT |
635 */ |
655 // */ |
636 Display getiDisplay() |
656 // Display getiDisplay() |
637 { |
657 // { |
638 return iDisplay; |
658 // return iDisplay; |
639 } |
659 // } |
640 |
660 |
641 /** |
661 /** |
642 * |
662 * |
643 * @return |
663 * @return |
644 */ |
664 */ |
645 Control getControl() |
665 // Control getControl() |
646 { |
666 // { |
647 return iControl; |
667 // return iControl; |
648 } |
668 // } |
649 /** |
669 /** |
650 * Function of ItemStateChangeListener |
670 * Function of ItemStateChangeListener |
651 * Notified by LCDUI implementation |
671 * Notified by LCDUI implementation |
652 * @param ctrl |
672 * @param ctrl |
653 * @param item |
673 * @param item |
654 */ |
674 */ |
655 public void notifyControlAvailable(Control ctrl,Item item) |
675 public void notifyControlAvailable(Control ctrl,Item item) |
656 { |
676 { |
657 final String DEBUG_STR= "VideoControl::notifyControlAvailable(Control ctrl,Item item)"; |
677 final String DEBUG_STR= "VideoControl::notifyControlAvailable(Control ctrl,Item item)"; |
658 iControl=ctrl; |
678 iControl=ctrl; |
|
679 iESWTinitializeListener.notifyControlAvailable(iControl); |
659 Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo, DEBUG_STR+"Control is "+ctrl.hashCode()+ " Item is "+item); |
680 Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo, DEBUG_STR+"Control is "+ctrl.hashCode()+ " Item is "+item); |
660 //TODO is it proper here to put the below line in try/catch?, remove if we can. |
|
661 // Otherwise it may deteriorate the performance, as in case of CustomItem on each |
|
662 // repaint, eSWT control is getting destroyed, and reconstructed |
|
663 ((AnimationPlayer)iPlayer).addPaintListener(iControl); |
|
664 } |
681 } |
665 /** |
682 /** |
666 * Function of ItemStateChangeListener |
683 * Function of ItemStateChangeListener |
667 * We don't need to do anything in this function |
684 * We don't need to do anything in this function |
668 * |
685 * |