blog.Ring.idv.tw

Articles

WiiremoteJ - 用Wii來做互動

WiiRemoteJ is a free Java API and library for interacting with a 
Nintendo(R) Wii(tm) Remote through Bluetooth(R). WiiRemoteJ aims to do 
two things: first, it aims to create an easily accessible interface for 
Java developers wanting to work with the Wii Remote. Second, it aims to 
provide tools for developers using the Wii Remote to speed development. 
WiiRemoteJ comes with a complete (to my knowledge) javadoc, detailing 
every public class, field, and method. In addition, WiiRemoteJ aims to 
duplicate many of the same ideologies and methods used in the main Java 
libraries. This should allow developers to jump into the development 
process relatively quickly.

WiiremoteJ提供了一套Java API可以讓我們藉此來開發Wii的互動程式,而在這當中的傳輸必須仰賴Bluetooth,聽學弟說只有MSI的Bluetooth有支援而已~ 有興趣的人不妨玩玩看!

參考資源:

1.WiiremoteJ

2.WiiLi.org WiiremoteJ

2007-09-11 10:05:54 | Comments (2)

Working with the Java ME FileConnection API on Physical Devices

Working with the Java ME FileConnection API on Physical Devices

提供了一個利用FileConnection來存取本機照片並可藉由Servlet上傳至伺服端的範例,有興趣的人不妨研究研究~

2007-09-04 17:49:29 | Add Comment

影音轉檔工具-FFmpeg

簡單且快速的安裝方式如下:

Step 1.下載LAME MP3 Encoder

Step 2.組態設定並安裝

./configure --enable-shared --prefix=/usr
make
make install

Step 3.取得FFmpeg原始碼

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg

Step 4.組態設定並安裝

./configure --enable-gpl --enable-libmp3lame --enable-shared --prefix=/usr
make
make install

Step 5.進行轉檔

ffmpeg -i blue.avi -ar 22050 -ab 32 -f flv -s 320x240 blue.flv

參考資料:

One-stop Installation Guide for Create a Linux Server-side FLV conversion environment

FFmpeg usage command

http://soenkerohde.com/tutorials/ffmpeg

ffmpeg和Mencoder使用实例小全

泛用型 ffmpeg 安裝攻略

2007-08-26 19:12:43 | Add Comment

Adobe AIR update for Flash CS3 Professional Beta 1

想要在Flash CS3底下開發Adobe AIR嗎?想要「Ctrl+Enter」就發佈成AIR嗎?

官方已經釋出 AIR:Flash CS3 Professional Update,趕緊去下載來試試看吧~

目前是beta 1版~ 我想等到Adobe AIR正式版問世後~ 這也應該會同步發佈成正式版的~

文件說明:

Using the Adobe AIR™update for Flash

Getting Started with Adobe AIR™ for Flash CS3 Professional

2007-08-21 10:20:23 | Add Comment

Flash Webcam 線上拍照存檔!~

.2008/12/10 新增範例下載

今天試著用Flash CS3寫一個Flash Webcam 線上拍照存檔的範例~

大致上分成兩部份來處理~一部份為Flash的前端,用來截取Webcam的畫面並將它存進BitmapData中,以供透過URLRequest來上傳處理~

而這部份比較關鍵的是,我們利用「as3corelib」所提供的「JPGEncoder」來進行壓縮,以增進傳送速度~

想當然而,後端就是直接將它讀出並存進一個影像檔即可。

程式碼如下所示:

ActionScript 3

import com.adobe.images.JPGEncoder;

var camera:Camera = Camera.getCamera("0");
camera.setMode(320,240,30);
var video = new Video(320, 240);
video.attachCamera(camera);
stage.addChild(video);
stage.addEventListener(MouseEvent.MOUSE_DOWN,clickHandler);
function clickHandler(event:MouseEvent)
{
	var bd:BitmapData = new BitmapData(320, 240);
	bd.draw(video);
	var encoder:JPGEncoder = new JPGEncoder(100);
	var bytes:ByteArray = encoder.encode(bd);
	var req:URLRequest = new URLRequest("http://localhost/WebCamHandler.as3");
	req.data = bytes;
	req.method = URLRequestMethod.POST;
	req.contentType = "application/octet-stream";
	var loader:URLLoader = new URLLoader();			
	loader.addEventListener(Event.COMPLETE, completeHandler);
	loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
	loader.load(req);
}
function completeHandler(event:Event):void
{
	trace("上傳成功");
}
function errorHandler(event:IOErrorEvent):void
{
	trace("上傳失敗");
}

Servlet

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class WebCamHandler extends HttpServlet
{
    private String base;
    
    public void init(ServletConfig sc) throws ServletException
    {
        ServletContext sco = sc.getServletContext();
        base = sco.getRealPath("/");
    }
    public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    {   
        int readed;
        try
        {
            String filePath = base+new Date().getTime()+".jpg";
            BufferedInputStream bis = new BufferedInputStream(req.getInputStream());
            FileOutputStream fos = new FileOutputStream(new File(filePath));
            byte[] bytes = new byte[2048];
            while((readed=bis.read(bytes)) != -1)
            {
                fos.write(bytes, 0, readed);
            }
            fos.close();
            bis.close();
            
        } catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

範例下載

.WebCamHandler(CS4、Webapp)

2007-08-19 15:19:20 | Comments (17)

Next Posts~:::~Previous Posts
Copyright (C) Ching-Shen Chen. All rights reserved.

::: 分類 :::

::: 最新文章 :::

::: 最新回應 :::