• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Manager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.microedition.media.Manager的典型用法代码示例。如果您正苦于以下问题:Java Manager类的具体用法?Java Manager怎么用?Java Manager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Manager类属于javax.microedition.media包,在下文中一共展示了Manager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createPlayer

import javax.microedition.media.Manager; //导入依赖的package包/类
public static MMAPIPlayer createPlayer(InputStream stream, String mimeType, Runnable onCompletion) throws IOException {
    try {
        Player p = Manager.createPlayer(stream, mimeType);
        p.realize();
        MMAPIPlayer m = new MMAPIPlayer(p);
        m.bindPlayerCleanupOnComplete(p, stream, onCompletion);
        return m;
    } catch (MediaException ex) {
        if ("audio/mpeg".equals(mimeType)) {
            return createPlayer(stream, "audio/mp3", onCompletion);
        }

        ex.printStackTrace();
        throw new IOException(ex.toString());
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:17,代码来源:MMAPIPlayer.java


示例2: createPlayer

import javax.microedition.media.Manager; //导入依赖的package包/类
public static MMAPIPlayer createPlayer(InputStream stream, String mimeType, Runnable onCompletion) throws IOException {
    try {
        Player p = Manager.createPlayer(stream, mimeType);
        p.realize();
        MMAPIPlayer m = new MMAPIPlayer(p);
        m.bindPlayerCleanupOnComplete(p, stream, onCompletion);
        return m;
    } catch (MediaException ex) {
        if("audio/mpeg".equals(mimeType)) {
            return createPlayer(stream, "audio/mp3", onCompletion);
        }

        ex.printStackTrace();
        throw new IOException(ex.toString());
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:17,代码来源:MMAPIPlayer.java


示例3: showCamera

import javax.microedition.media.Manager; //导入依赖的package包/类
private void showCamera() {
    try {
        mPlayer = Manager.createPlayer("capture://video");
        mPlayer.realize();

        mVideoControl = (VideoControl) mPlayer.getControl("VideoControl");

        //    Command mExitCommand = new Command("Exit", Command.EXIT, 0);
        //    Command mCameraCommand = new Command("Camera", Command.SCREEN, 0);
        mBackCommand = new Command("Back", Command.BACK, 0);
        mCaptureCommand = new Command("Capture", Command.SCREEN, 0);

        Canvas canvas = new CameraCanvas(null, mVideoControl);
        canvas.addCommand(mBackCommand);
        canvas.addCommand(mCaptureCommand);
        canvas.setCommandListener(this);

        J2MEDisplay.setView(canvas);
        mPlayer.start();
    } catch (IOException ioe) {
        handleException(ioe);
    } catch (MediaException me) {
        handleException(me);
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:26,代码来源:ImageCaptureState.java


示例4: open

import javax.microedition.media.Manager; //导入依赖的package包/类
public void open(String path){
  try
  {
    player = Manager.createPlayer(path);
  } catch (Exception e) {
    e.printStackTrace();
    Midlet.midlet.f.append("\nPlayer method open: " + e.getMessage());
  }
}
 
开发者ID:NeiroNext,项目名称:JccAPV,代码行数:10,代码来源:Player.java


示例5: playTone

import javax.microedition.media.Manager; //导入依赖的package包/类
public void playTone(int note, int duration, int volume) {
  try {
    Manager.playTone(note, duration, volume);
  } catch (Exception e) {
    e.printStackTrace();
    Midlet.midlet.f.append("\nPlayer method playTone: " + e.getMessage());
  }
}
 
开发者ID:NeiroNext,项目名称:JccAPV,代码行数:9,代码来源:Player.java


示例6: MediaRecorder

import javax.microedition.media.Manager; //导入依赖的package包/类
public MediaRecorder(String path) throws IOException {
    try {
        String [] supportedContentType = Manager.getSupportedContentTypes("capture");
        boolean amrSupported = false;
        for (int i = 0; i < supportedContentType.length; i++) {
            if(supportedContentType[i].equals("audio/amr")){
                amrSupported = true;
            }
        }
        if(amrSupported){
            try {
                //some j2me devices will report they supports amr, but they are actually 
                //don't so we will try to realize the player and if fails the
                //fallback would be to create it with the default capture encoding
                recorder = Manager.createPlayer("capture://audio?encoding=audio/amr");                                
                recorder.realize();
            } catch (Exception e) {
                recorder = Manager.createPlayer("capture://audio");
                recorder.realize();
            }
        }else{
            recorder = Manager.createPlayer("capture://audio");
            recorder.realize();
        }
        rc = (RecordControl) recorder.getControl("RecordControl");
        out = FileSystemStorage.getInstance().openOutputStream(path);
        rc.setRecordStream(out);
    } catch (MediaException ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:32,代码来源:MediaRecorder.java


示例7: MediaRecorder

import javax.microedition.media.Manager; //导入依赖的package包/类
public MediaRecorder(String path, String mimeType) throws IOException {
    try {
        //recorder = Manager.createPlayer("capture://audio?encoding=audio/amr&bitrate=12200&voipMode=true");
        recorder = Manager.createPlayer("capture://audio?encoding="+mimeType);            
        recorder.realize();
        rc = (RecordControl) recorder.getControl("RecordControl");
        out = FileSystemStorage.getInstance().openOutputStream(path);
        rc.setRecordStream(out);
    } catch (MediaException ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:13,代码来源:MediaRecorder.java


示例8: startScan

import javax.microedition.media.Manager; //导入依赖的package包/类
public void startScan() {
    try {
        System.gc();

        player = Manager.createPlayer("capture://video");
        player.realize();
        multimediaManager.setZoom(player);
        multimediaManager.setExposure(player);
        multimediaManager.setFlash(player);
        player.start();
        videoControl = (VideoControl) player.getControl("VideoControl");

        viewFinder = (Field) videoControl.initDisplayMode(
                VideoControl.USE_GUI_PRIMITIVE,
                "net.rim.device.api.ui.Field");

        if (videoControl != null) {
            viewFinderScreen = new ViewFinderScreen();
            UiApplication.getUiApplication().invokeLater(new Runnable() {

                public void run() {
                    UiApplication.getUiApplication().pushScreen(
                            viewFinderScreen);
                    viewFinder.setFocus();

                }
            });
            videoControl.setVisible(true);
            videoControl.setDisplayFullScreen(true);
            task = new BarcodeScanTask();
            // create timer every 3 seconds, get a screenshot
            timer = new Timer();
            timer.schedule(task, 0, 3000); // once every 3 seconds 
        } else {
            throw new MediaException("Video Control is not initialized");
        }
    } catch (Exception e) {
        callback.scanError(-1, e.getMessage());
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:41,代码来源:CodeScannerImpl.java


示例9: getPlayerLoose

import javax.microedition.media.Manager; //导入依赖的package包/类
public static Player getPlayerLoose(Reference reference) throws MediaException, IOException {
    Player thePlayer;

    try{
        thePlayer = Manager.createPlayer(reference.getLocalURI());
        final String uri = reference.getLocalURI();
        thePlayer.addPlayerListener(new PlayerListener() {
            public void playerUpdate(Player player, String event, Object eventData) {
                logEvent(event, uri);
            }
        });
        return thePlayer;
    } catch(MediaException e) {
        if(!FormManagerProperties.LOOSE_MEDIA_YES.equals(PropertyManager._().getSingularProperty(FormManagerProperties.LOOSE_MEDIA))) {
            throw e;
        }
        Reference[] refs = reference.probeAlternativeReferences();
        for(Reference ref : refs) {
            if(ref.doesBinaryExist()) {
                try{
                    //TODO: Make sure you create a player of the right type somehow (video/audio), don't want
                    //to accidentally send back an audio player of a video file
                    thePlayer = Manager.createPlayer(ref.getLocalURI());
                    return thePlayer;
                }catch(MediaException oe) {
                    //also bad file, keep trying
                }
            }
        }
        throw e;
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:33,代码来源:MediaUtils.java


示例10: addCameraViewer

import javax.microedition.media.Manager; //导入依赖的package包/类
private void addCameraViewer() throws MediaException, IOException {
    String refForCamera = "";
    //#if polish.identifier.motorola/v3xx
    refForCamera = "capture://camera";
    //#elif polish.group.series60e3
    refForCamera = "capture://devcam0";
    //#else
    refForCamera = "capture://video";
    //#endif

    String[] contentTypes = Manager.getSupportedContentTypes("capture");
    if (contentTypes == null || contentTypes.length == 0) {
        throw new MediaException("capture not supported");
    }

    for (int i = 0; i < contentTypes.length; i++) {
        String contentType = contentTypes[i];

        if ("image".equals(contentType)) { // this is the case on Series 40,
            // for example
            refForCamera = "capture://image";
        }
    }

    System.out.println("Starting player");
    player = Manager.createPlayer(refForCamera);
    player.realize();
    videoControl = (VideoControl) player.getControl("VideoControl");

    videoItem = (javax.microedition.lcdui.Item) videoControl
            .initDisplayMode(GUIControl.USE_GUI_PRIMITIVE, null);
    showVideoScreen();

}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:35,代码来源:ImageCaptureScreen.java


示例11: startPlayback

import javax.microedition.media.Manager; //导入依赖的package包/类
public void startPlayback() throws AudioException
{
    try
    {
        try
        {
            audioDataStream = fileService.getFileOutputStream(recordFileName);
            recordedInputStream = fileService.getFileDataStream(recordFileName);
        }
        catch(FileException fe)
        {
            audioDataStream = null;
            recordedInputStream = null;
            System.err.println("An error occurred while obtaining the file data stream.");
            fe.printStackTrace();
        }
        if(audioDataStream == null || recordingDeleted)
        {
            throw new AudioException("No audio data recorded!");
        }
        playP = Manager.createPlayer(recordedInputStream, "audio/x-wav");

        playP.prefetch();
        playP.start();

        serviceState = AudioCaptureService.PLAYBACK_STARTED;
    }
    catch(MediaException me)
    {
        throw new AudioException(me.getMessage());
    }
    catch(IOException ioe)
    {
        System.err.println(ioe.getMessage());
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:37,代码来源:J2MEAudioCaptureService.java


示例12: isMediaSupported

import javax.microedition.media.Manager; //导入依赖的package包/类
/**
 * Returns boolean indication is media mimetype supported by the Device.
 * 
 * @param mimeType
 *            String as media mime-type
 * @return boolean is supported
 */
public boolean isMediaSupported(String mimeType) {
    String[] types = Manager.getSupportedContentTypes(null);
    for (int i = 0; i < types.length; i++) {
        if (mimeType.toLowerCase().equals(types[i].toLowerCase())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:17,代码来源:PlayerPool.java


示例13: init

import javax.microedition.media.Manager; //导入依赖的package包/类
private void init() {
    String apiVersion = System.getProperty("microedition.media.version");
    append("MM API version:" + apiVersion + "\n");
    append("Mixing supported: " + System.getProperty("supports.mixing") + "\n");
    append("Audio capture supported: " + System.getProperty("supports.audio.capture") + "\n");
    append("Video capture supported: " + System.getProperty("supports.video.capture") + "\n");
    append("Recording supported: " + System.getProperty("supports.recording") + "\n");
    append("Supported audio encodings: " + System.getProperty("audio.encodings") + "\n");
    append("Supported video encodings: " + System.getProperty("video.encodings") + "\n");
    append("Supported video snaphot encodings: " + System.getProperty("video.snapshot.encodings") + "\n");
    append("\n");
    String streamable = System.getProperty("streamable.contents");
    if (streamable == null) {
        append("Streaming: not supported.\n");
    } else {
        append("Streamable contents: " + streamable);
        String[] rtp = Manager.getSupportedContentTypes("rtp");
        if (rtp != null && rtp.length > 0) {
            append("RTP protocol supported.");
        }
        String rtsp[] = Manager.getSupportedContentTypes("rtsp");
        if (rtsp != null && rtsp.length > 0) {
            append("RTSP protocol supported.");
        }
    }
    String[] contentTypes = Manager.getSupportedContentTypes(null);
    if (contentTypes != null) {
        append("\n\nAll supported content types:\n");
        for (int i = 0; i < contentTypes.length; i++) {
            append(contentTypes[i] + "\n");
        }
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:34,代码来源:SupportForm.java


示例14: restartPlayer

import javax.microedition.media.Manager; //导入依赖的package包/类
public synchronized void restartPlayer() {
    try {
        fireStatusEvent("Wait...");
        IN.nextChunk();

        // Free old player
        if (player != null) {
            for (int n = 0; n < listeners.size(); n++) {
                this.player.removePlayerListener((PlayerListener) listeners.elementAt(n));
            }
            this.player.close();
            this.player = null;
        }

        fireStatusEvent("Create Player...");
        this.player = Manager.createPlayer(IN, IN.getContentType());
        this.player.realize();

        // Make sure radio is audible; this causes an VOLUME_CHANGED event
        VolumeControl vcon = (VolumeControl) this.player.getControl("VolumeControl");
        vcon.setMute(false);
        vcon.setLevel(50);

        for (int n = 0; n < listeners.size(); n++) {
            this.player.addPlayerListener((PlayerListener) listeners.elementAt(n));
        }

        fireStatusEvent("Starting...");
        this.player.start();
    } catch (Exception ex) {
        fireExecptionOccurredEvent(ex);
    }
}
 
开发者ID:cli,项目名称:rdio,代码行数:34,代码来源:RadioPlayer.java


示例15: say

import javax.microedition.media.Manager; //导入依赖的package包/类
/**
 * Diz o valor da nota
 */
void say(int value){
    
    String valueSoundFile = null;
    
    switch (value){
        case 1:
            valueSoundFile = "01.wav";
            break;
        case 2:
            valueSoundFile = "02.wav";
            break;
        case 5:
            valueSoundFile = "05.wav";
            break;
        case 10:
            valueSoundFile = "10.wav";
            break;
        case 20:
            valueSoundFile = "20.wav";
            break;
        case 50:
            valueSoundFile = "50.wav";
            break;
        case 100:
            valueSoundFile = "100.wav";
            break;
        default:
            valueSoundFile = "unknown.wav";
            break;
    }
    
    try {
        InputStream is = getClass().getResourceAsStream(valueSoundFile);
        Player audioPlayer = Manager.createPlayer(is, "audio/X-wav");
        audioPlayer.start();
    } catch (IOException ioe) {
    } catch (MediaException me) { }
}
 
开发者ID:gstiebler,项目名称:tio_patinhas,代码行数:42,代码来源:UTioPatinhas.java


示例16: getMusicPlayer

import javax.microedition.media.Manager; //导入依赖的package包/类
public final Player getMusicPlayer(String var1, String var2) {
    Player player = null;

    try {
        (player = Manager.createPlayer(getClass().getResourceAsStream(var1), var2)).realize();
        player.prefetch();
        player.setLoopCount(1);
    } catch (Exception e) {
        e.printStackTrace();
    }

    return player;
}
 
开发者ID:NaikSoftware,项目名称:Blitzkrieg,代码行数:14,代码来源:GameCanvas.java


示例17: CameraImage

import javax.microedition.media.Manager; //导入依赖的package包/类
/** Creates a new instance of CameraImage
 * @param imgListener
 */
public CameraImage(VirtualList parentList, CameraImageListener imgListener/*, String sizes*/) {
    this.imgListener = imgListener;
    this.parentList = parentList;

    //if (sizes!=null) this.sizes=sizes;
    
    int exp=0;
    try {
        String uri= Config.getInstance().NokiaS40 ? "capture://image" : "capture://video";
        player = Manager.createPlayer(uri);
        player.realize();
        
        videoControl = (VideoControl)player.getControl("VideoControl");
        
        Form form = new Form("Camera");
        Item item = (Item)videoControl.initDisplayMode(
                GUIControl.USE_GUI_PRIMITIVE, null);
        form.append(item);
        form.addCommand(cmdShot);
        form.addCommand(cmdCancel);
        form.setCommandListener(this);
        midlet.BombusMod.getInstance().setDisplayable(form);
        
        player.start();
    } catch (Exception e) {
    }
}
 
开发者ID:BombusMod,项目名称:BombusMod,代码行数:31,代码来源:CameraImage.java


示例18: run

import javax.microedition.media.Manager; //导入依赖的package包/类
public void run(){
    try {
        for (int i=0; i<tone.length(); ) {
            int note=(tone.charAt(i++)-'A')+12*(tone.charAt(i++)-'0');
            int duration=150;
            Manager.playTone(note, duration, sndVolume);
            Thread.sleep(duration);
        }
    } catch (Exception e) { }
}
 
开发者ID:BombusMod,项目名称:BombusMod,代码行数:11,代码来源:EventNotify.java


示例19: startRecord

import javax.microedition.media.Manager; //导入依赖的package包/类
public void startRecord() throws AudioException
{
    try
    {
        recordP = Manager.createPlayer("capture://audio");
        recordP.realize();
        recordControl = (RecordControl)recordP.getControl("RecordControl");
        try
        {
            recordFileName = null; //Reset file name to prevent concatenation of previous recordFileName twice
            createFileName(recordFileName);
            System.err.println("Recorded Filename=" + recordFileName);
            audioDataStream = fileService.getFileOutputStream(recordFileName);
        }
        catch(FileException fe)
        {
            audioDataStream = null;
            System.err.println("Error obtaining audio output stream.");
            fe.printStackTrace();
        }
        if(audioDataStream == null)
        {
            throw new AudioException("Could not record audio due to null audio output stream!");
        }

        recordControl.setRecordStream(audioDataStream);
        recordControl.startRecord();

        recordingCreated = true;
        recordingDeleted = false;
        recordP.start();

   /*
    * If the method does not die before here,
    * then the capture has officially started.
    */
        serviceState = AudioCaptureService.CAPTURE_STARTED;
    }
    catch(MediaException me)
    {
        throw new AudioException(me.getMessage());
    }
    catch(IOException ioe)
    {
        System.err.println(ioe.getMessage());
    }
    ++counter;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:49,代码来源:J2MEAudioCaptureService.java


示例20: createTonePlayer

import javax.microedition.media.Manager; //导入依赖的package包/类
/**
 * Creates and initializes the Player
 * 
 * @param sequence -
 *            tone sequence data in byte array
 * @return realized tone sequence Player
 * @throws MediaException
 *             thrown by the system while creating the player
 * @throws IOException
 *             thrown by the system while creating the player
 */
private Player createTonePlayer(byte[] sequence) throws MediaException, IOException {
    Player player = Manager.createPlayer(Manager.TONE_DEVICE_LOCATOR);
    player.addPlayerListener(this);
    player.realize();
    ToneControl tc = (ToneControl) (player.getControl("ToneControl"));
    tc.setSequence(sequence);
    return player;
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:20,代码来源:PlayerPool.java



注:本文中的javax.microedition.media.Manager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SlackMessagePosted类代码示例发布时间:2022-05-22
下一篇:
Java XmppStringUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap