当前位置: 首页>>代码示例>>Java>>正文


Java Manager.createPlayer方法代码示例

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


在下文中一共展示了Manager.createPlayer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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.createPlayer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。