⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guicontroller.java

📁 j2me手机看交通监视器实时录像源码,包含文档说明
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		public static final byte EVENT_SETTINGS		    = 9;//进入设置界面
		public static final byte EVENT_DOWNLOADDATA		= 10;//说明当前开始下载数据
		public static final byte EVENT_DOWNLOADING	    = 11;//说明当前正在下载数据
		public static final byte EVENT_DOWNLOADDATA_ERROR    = 12;//说明当前正在下载数据时发生了错误
		public static final byte EVENT_DOWNLOADDATA_SUCC     = 13;//说明当前成功下载数据
		public static final byte EVENT_START_PLAY_3GP     = 14;//开始播放3gp媒体文件
		public static final byte EVENT_PLAYAGAIN    		 = 15;//重新播放刚才的3gp媒体文件
    }
	
    
	/**********************************************************
	//	 GUIController::handleEvent
	//
	//	 Description:
	//	  对传入的事件进行处理
	//
	//	 Parameters:
	//	 Return Values:
	//   Remark:
	 * 
	//	 Author:
	//	      zhengyun@ultrapower 2005.10.07
	//
	**********************************************************/
	public void handleEventNoThrows( int eventID,Object[] args){   
		try{
			handleEvent(eventID, args);
		}
		catch(Exception exc){}
	}
    public void handleEvent( int eventID,Object[] args){   
		System.out.println("Controller::handleEvent eventID>>" + eventID);
		
    	switch (eventID)
        {   
    	    case EventID.EVENT_EXIT:
    	    {
				m_bStopDownloadData = true;
				// 清理RMS
				RmsFacade.shutdown();
				System.gc();     // 通知进行垃圾收集
				Thread.yield();  // 本线程暂停一下,使得GC可以马上获得机会运行
				m_trafficcamMidlet.exit(false);
    	    	break;
    	    }
    	    case EventID.EVENT_SHOWWEBCAM:
    	    {
				try
				{
					m_camForm.ShowWebcamDownload();
				}
				catch(Exception exc)
				{
				
				}
				setCurrent(m_camForm);
    	        break;
    	    }
			case EventID.EVENT_SETTINGS:
    	    {
				m_settingForm.initSettingsTextFields();
				setCurrent(m_settingForm);
    	        break;
    	    }
    	    case EventID.EVENT_STARTWEBCAM:
    	    {
				m_bStopDownloadData = false;
				m_camForm.StartWebcamDownload();
				//setCurrent(m_camForm);
    	    	break;
    	    }
			case EventID.EVENT_STOPWEBCAM:
    	    {
				m_bStopDownloadData = true;
				m_camForm.StopWebcamDownload();
				setCurrent(m_camForm);
    	    	break;
    	    }
			case EventID.EVENT_WEBCAM_BACK:
			{
				m_bStopDownloadData = true;
				// 必须先保证摄像头已经关闭的,而且不再抓取数据
				m_camForm.StopWebcamDownload();
			}
    	    case EventID.EVENT_ABOUT_BACK:
    	    case EventID.EVENT_SETTINGS_BACK: 
    	    {
    	    	setCurrent(m_listMenu);
    	    	break;
    	    }
    	    case EventID.EVENT_SETTINGS_SAVE:
    	    {
				/*
				 * 存储当前设置页面上的所有参数进入RMS
				 */
				String mmsurl = (String)args[0];
				String converturl = (String)args[1];
				String timelimit = (String)args[2];
				
    	        m_Settings.save(mmsurl,
						timelimit,
						converturl);
				setCurrent(m_settingForm);
				
    	        break;
    	    }
    	    case EventID.EVENT_ABOUT:
    	    {
    	        setCurrent(m_about);
    	        break;
    	    }
    	    case EventID.EVENT_DOWNLOADDATA:
			{
				/*
				 * 设置FormWebcam界面下方的文字,表明当前传输图像的总字节数:
				 */
				try{
					// 告知用户总字节数目:				
					String sProgress = String.valueOf(
							CommandResources.getChars(CommandResources.TXT_WAITTITLE));
					m_camForm.setProgress(sProgress 
								+ m_sPostDataTotalLength, "");
				}
				catch(Exception exc)
				{
					setCurrent(
							new Alert(
									String.valueOf(
											CommandResources.getChars(CommandResources.TXT_WAITTITLE)), 
											exc.getMessage() + "/" + exc.getClass(), null, AlertType.ERROR),
							(Displayable)m_camForm);
				}
				break;
			}
			case EventID.EVENT_DOWNLOADING:
			{
				/*
				 * 设置FormWebcam界面下方的文字,表明当前传输图像的进度
				 * 告知用户剩余字节数目
				 */
				try{
					String sProgress = String.valueOf(
							CommandResources.getChars(CommandResources.TXT_WAITMESSAGE));
					String sProgressTitle = String.valueOf(
							CommandResources.getChars(CommandResources.TXT_WAITTITLE));
					m_camForm.setProgress(sProgressTitle + m_sPostDataTotalLength,
							sProgress + m_sPostingDataLength);
				}
				catch(Exception exc)
				{
					setCurrent(
							new Alert(
									String.valueOf(
											CommandResources.getChars(CommandResources.TXT_WAITTITLE)), 
											exc.getMessage() + "/" + exc.getClass(), null, AlertType.ERROR),
							(Displayable)m_camForm);
				}
				break;
			}
			case EventID.EVENT_DOWNLOADDATA_ERROR:
			{
				try{
					m_camForm.StopWebcamDownload();
					setCurrent(
							new Alert(
									String.valueOf(
											CommandResources.getChars(CommandResources.TXT_POSTERROR_TITLE)), 
											String.valueOf(
													CommandResources.getChars(CommandResources.TXT_POSTERROR_MSG))
													+ m_sPlayerException, null, AlertType.ERROR),
							(Displayable)m_camForm);
				}
				catch(Exception exc)
				{
					setCurrent(
							new Alert(
									String.valueOf(
											CommandResources.getChars(CommandResources.TXT_WAITTITLE)), 
											exc.getMessage() + "/" + exc.getClass(), null, AlertType.ERROR),
							(Displayable)m_camForm);
				}
				break;
			}
			case EventID.EVENT_DOWNLOADDATA_SUCC:
			{
				try{
					m_camForm.StopWebcamDownload();
					setCurrent(
							new Alert(
									String.valueOf(
											CommandResources.getChars(CommandResources.TXT_POSTSUCC_TITLE)), 
											String.valueOf(
													CommandResources.getChars(CommandResources.TXT_POSTSUCC_MSG))
													, null, AlertType.ERROR),
							(Displayable)m_camForm);
				}
				catch(Exception exc)
				{
					setCurrent(
							new Alert(
									String.valueOf(
											CommandResources.getChars(CommandResources.TXT_WAITTITLE)), 
											exc.getMessage() + "/" + exc.getClass(), null, AlertType.ERROR),
							(Displayable)m_camForm);
				}
				break;
			}
			case EventID.EVENT_PLAYAGAIN:
			{
				try
				{
					/*InputStream is = 
						getClass().getResourceAsStream
						(String.valueOf(
								CommandResources.getChars(CommandResources.TXT_DEMO_3GPFILE)));

					Player player = (Player)Manager.createPlayer(is, "video/3gpp");
					player.realize();
					System.out.println("3");
					m_video = (VideoControl)player.getControl("VideoControl");
					System.out.println("4");
					if(m_video != null)
			        {
						// the player can start with the smallest latency
						player.prefetch();
						
						System.out.println("/** 已经得到了VideoControl!");
					
						// Display Video as a Form item
						//
						Item itemVideoWindow;
						// 在USE_GUI_PRIMITIVE模式下,默认是可见的,而在USE_DIRECT_VIDEO模式下,
						// 默认是不可见的,需要通过方法setVisible(boolean visible)来设置
						(itemVideoWindow = (Item)m_video.initDisplayMode
							(VideoControl.USE_GUI_PRIMITIVE, null)).setLayout(3);
						m_camForm.append(itemVideoWindow);
						player.start();
						System.out.println("/** 启动Player!");
	
			        }
			        */
					m_camForm.PlayAgain();
				}
				catch(Exception exc)
				{
					exc.printStackTrace();
					setCurrent(
							new Alert(
									String.valueOf(
											CommandResources.getChars(CommandResources.TXT_WAITTITLE)), 
											exc.getMessage() + "/" + exc.getClass(), null, AlertType.ERROR),
							(Displayable)m_camForm);
				}
			}
         	default:
         	    break;
        }
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -