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


Java MidiDeviceInfo类代码示例

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


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

示例1: formatDeviceInfo

import android.media.midi.MidiDeviceInfo; //导入依赖的package包/类
public static String formatDeviceInfo(MidiDeviceInfo info) {
    StringBuilder sb = new StringBuilder();
    if (info != null) {
        Bundle properties = info.getProperties();
        for (String key : properties.keySet()) {
            Object value = properties.get(key);
            sb.append(key).append(" = ").append(value).append('\n');
        }
        for (PortInfo port : info.getPorts()) {
            sb.append((port.getType() == PortInfo.TYPE_INPUT) ? "input"
                    : "output");
            sb.append("[").append(port.getPortNumber()).append("] = \"").append(port.getName()
                    + "\"\n");
        }
    }
    return sb.toString();
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:18,代码来源:MidiPrinter.java

示例2: onPortSelected

import android.media.midi.MidiDeviceInfo; //导入依赖的package包/类
@Override
public void onPortSelected(final MidiPortWrapper wrapper) {
    close();
    final MidiDeviceInfo info = wrapper.getDeviceInfo();
    if (info != null) {
        mMidiManager.openDevice(info, new MidiManager.OnDeviceOpenedListener() {
                @Override
            public void onDeviceOpened(MidiDevice device) {
                if (device == null) {
                    Log.e(MidiConstants.TAG, "could not open " + info);
                } else {
                    mOpenDevice = device;
                    mInputPort = mOpenDevice.openInputPort(
                            wrapper.getPortIndex());
                    if (mInputPort == null) {
                        Log.e(MidiConstants.TAG, "could not open input port on " + info);
                    }
                }
            }
        }, null);
        // Don't run the callback on the UI thread because openInputPort might take a while.
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:24,代码来源:MidiInputPortSelector.java

示例3: findDevice

import android.media.midi.MidiDeviceInfo; //导入依赖的package包/类
/**
 * @return a device that matches the manufacturer and product or null
 */
public static MidiDeviceInfo findDevice(MidiManager midiManager,
        String manufacturer, String product) {
    for (MidiDeviceInfo info : midiManager.getDevices()) {
        String deviceManufacturer = info.getProperties()
                .getString(MidiDeviceInfo.PROPERTY_MANUFACTURER);
        if ((manufacturer != null)
                && manufacturer.equals(deviceManufacturer)) {
            String deviceProduct = info.getProperties()
                    .getString(MidiDeviceInfo.PROPERTY_PRODUCT);
            if ((product != null) && product.equals(deviceProduct)) {
                return info;
            }
        }
    }
    return null;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:20,代码来源:MidiTools.java

示例4: updateString

import android.media.midi.MidiDeviceInfo; //导入依赖的package包/类
private void updateString() {
    if (mInfo == null) {
        mString = "- - - - - -";
    } else {
        StringBuilder sb = new StringBuilder();
        String name = mInfo.getProperties()
                .getString(MidiDeviceInfo.PROPERTY_NAME);
        if (name == null) {
            name = mInfo.getProperties()
                    .getString(MidiDeviceInfo.PROPERTY_MANUFACTURER) + ", "
                    + mInfo.getProperties()
                            .getString(MidiDeviceInfo.PROPERTY_PRODUCT);
        }
        sb.append("#" + mInfo.getId());
        sb.append(", ").append(name);
        PortInfo portInfo = findPortInfo();
        sb.append("[" + mPortIndex + "]");
        if (portInfo != null) {
            sb.append(", ").append(portInfo.getName());
        } else {
            sb.append(", null");
        }
        mString = sb.toString();
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:26,代码来源:MidiPortWrapper.java

示例5: findMidiDevice

import android.media.midi.MidiDeviceInfo; //导入依赖的package包/类
private void findMidiDevice() {
    MidiDeviceInfo[] infos = midiManager.getDevices();
    for(MidiDeviceInfo info : infos) {
        String name = info.getProperties().getString(MidiDeviceInfo.PROPERTY_NAME);
        logger.log("Found MIDI device named " + name);
        if(TEENSY_MIDI_NAME.equals(name)) {
            logger.log("^^^ using this device ^^^");
            isConnecting = true;
            midiManager.openDevice(info, new MidiManager.OnDeviceOpenedListener() {
                @Override
                public void onDeviceOpened(MidiDevice device) {
                    if (device == null) {
                        logger.log("Error, unable to open MIDI device");
                    } else {
                        logger.log("Opened MIDI device successfully!");
                        midiDevice = device;
                    }
                    isConnecting = false;
                }
            }, null);
            break;
        }
    }
}
 
开发者ID:google,项目名称:walt,代码行数:25,代码来源:MidiTest.java

示例6: onDeviceAdded

import android.media.midi.MidiDeviceInfo; //导入依赖的package包/类
@Override
public void onDeviceAdded(final MidiDeviceInfo device) {
    // Call all of the locally registered callbacks.
    for(Map.Entry<DeviceCallback, Handler> item : mCallbacks.entrySet()) {
        final DeviceCallback callback = item.getKey();
        Handler handler = item.getValue();
        if(handler == null) {
            callback.onDeviceAdded(device);
        } else {
            handler.post(new Runnable() {
                @Override
                public void run() {
                    callback.onDeviceAdded(device);
                }
            });
        }
    }
}
 
开发者ID:philburk,项目名称:android-midisuite,代码行数:19,代码来源:MidiDeviceMonitor.java

示例7: onDeviceRemoved

import android.media.midi.MidiDeviceInfo; //导入依赖的package包/类
@Override
public void onDeviceRemoved(final MidiDeviceInfo device) {
    for(Map.Entry<DeviceCallback, Handler> item : mCallbacks.entrySet()) {
        final DeviceCallback callback = item.getKey();
        Handler handler = item.getValue();
        if(handler == null) {
            callback.onDeviceRemoved(device);
        } else {
            handler.post(new Runnable() {
                @Override
                public void run() {
                    callback.onDeviceRemoved(device);
                }
            });
        }
    }
}
 
开发者ID:philburk,项目名称:android-midisuite,代码行数:18,代码来源:MidiDeviceMonitor.java

示例8: registerDeviceAddedCallback

import android.media.midi.MidiDeviceInfo; //导入依赖的package包/类
private void registerDeviceAddedCallback(final MidiManager midiManager) {
    midiManager.registerDeviceCallback(new MidiManager.DeviceCallback() {
        @Override
        public void onDeviceAdded(MidiDeviceInfo device) {
            if (device.getOutputPortCount() > 0) {
                midiManager.unregisterDeviceCallback(this);
                openDevice(midiManager, device);
            }
        }
    }, null);
}
 
开发者ID:joshschriever,项目名称:LiveNotes,代码行数:12,代码来源:MidiReceiver.java

示例9: onDeviceOpened

import android.media.midi.MidiDeviceInfo; //导入依赖的package包/类
@Override
public void onDeviceOpened(MidiDevice device) {
    this.device = device;
    stream(device.getInfo().getPorts())
            .filter(port -> port.getType() == MidiDeviceInfo.PortInfo.TYPE_OUTPUT).findFirst()
            .ifPresent(port -> device.openOutputPort(port.getPortNumber()).connect(this));
}
 
开发者ID:joshschriever,项目名称:LiveNotes,代码行数:8,代码来源:MidiReceiver.java

示例10: onPortSelected

import android.media.midi.MidiDeviceInfo; //导入依赖的package包/类
@Override
public void onPortSelected(final MidiPortWrapper wrapper) {
    Log.i(MidiConstants.TAG, "onPortSelected: " + wrapper);
    close();

    final MidiDeviceInfo info = wrapper.getDeviceInfo();
    if (info != null) {
        mMidiManager.openDevice(info, new MidiManager.OnDeviceOpenedListener() {

                @Override
            public void onDeviceOpened(MidiDevice device) {
                if (device == null) {
                    Log.e(MidiConstants.TAG, "could not open " + info);
                } else {
                    mOpenDevice = device;
                    mOutputPort = device.openOutputPort(wrapper.getPortIndex());
                    if (mOutputPort == null) {
                        Log.e(MidiConstants.TAG,
                                "could not open output port for " + info);
                        return;
                    }
                    mOutputPort.connect(mDispatcher);
                }
            }
        }, null);
        // Don't run the callback on the UI thread because openOutputPort might take a while.
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:29,代码来源:MidiOutputPortSelector.java

示例11: onDeviceAdded

import android.media.midi.MidiDeviceInfo; //导入依赖的package包/类
@Override
public void onDeviceAdded(final MidiDeviceInfo info) {
    int portCount = getInfoPortCount(info);
    for (int i = 0; i < portCount; ++i) {
        MidiPortWrapper wrapper = new MidiPortWrapper(info, mType, i);
        mAdapter.add(wrapper);
        Log.i(MidiConstants.TAG, wrapper + " was added");
        mAdapter.notifyDataSetChanged();
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:11,代码来源:MidiPortSelector.java

示例12: onDeviceRemoved

import android.media.midi.MidiDeviceInfo; //导入依赖的package包/类
@Override
public void onDeviceRemoved(final MidiDeviceInfo info) {
    int portCount = getInfoPortCount(info);
    for (int i = 0; i < portCount; ++i) {
        MidiPortWrapper wrapper = new MidiPortWrapper(info, mType, i);
        MidiPortWrapper currentWrapper = mCurrentWrapper;
        mAdapter.remove(wrapper);
        // If the currently selected port was removed then select no port.
        if (wrapper.equals(currentWrapper)) {
            clearSelection();
        }
        mAdapter.notifyDataSetChanged();
        Log.i(MidiConstants.TAG, wrapper + " was removed");
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:16,代码来源:MidiPortSelector.java

示例13: onDeviceStatusChanged

import android.media.midi.MidiDeviceInfo; //导入依赖的package包/类
@Override
public void onDeviceStatusChanged(final MidiDeviceStatus status) {
    // If an input port becomes busy then remove it from the menu.
    // If it becomes free then add it back to the menu.
    if (mType == MidiDeviceInfo.PortInfo.TYPE_INPUT) {
        MidiDeviceInfo info = status.getDeviceInfo();
        Log.i(MidiConstants.TAG, "MidiPortSelector.onDeviceStatusChanged status = " + status
                + ", mType = " + mType
                + ", activity = " + mActivity.getPackageName()
                + ", info = " + info);
        // Look for transitions from free to busy.
        int portCount = info.getInputPortCount();
        for (int i = 0; i < portCount; ++i) {
            MidiPortWrapper wrapper = new MidiPortWrapper(info, mType, i);
            if (!wrapper.equals(mCurrentWrapper)) {
                if (status.isInputPortOpen(i)) { // busy?
                    if (!mBusyPorts.contains(wrapper)) {
                        // was free, now busy
                        mBusyPorts.add(wrapper);
                        mAdapter.remove(wrapper);
                        mAdapter.notifyDataSetChanged();
                    }
                } else {
                    if (mBusyPorts.remove(wrapper)) {
                        // was busy, now free
                        mAdapter.add(wrapper);
                        mAdapter.notifyDataSetChanged();
                    }
                }
            }
        }
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:34,代码来源:MidiPortSelector.java

示例14: MidiOutputPortConnectionSelector

import android.media.midi.MidiDeviceInfo; //导入依赖的package包/类
/**
 * @param midiManager
 * @param activity
 * @param spinnerId
 * @param type
 */
public MidiOutputPortConnectionSelector(MidiManager midiManager,
        Activity activity, int spinnerId,
        MidiDeviceInfo destinationDeviceInfo, int destinationPortIndex) {
    super(midiManager, activity, spinnerId,
            MidiDeviceInfo.PortInfo.TYPE_OUTPUT);
    mDestinationDeviceInfo = destinationDeviceInfo;
    mDestinationPortIndex = destinationPortIndex;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:15,代码来源:MidiOutputPortConnectionSelector.java

示例15: connectToDevicePort

import android.media.midi.MidiDeviceInfo; //导入依赖的package包/类
/**
 * Open a source device and connect its output port to the
 * destinationInputPort.
 *
 * @param sourceDeviceInfo
 * @param sourcePortIndex
 * @param destinationInputPort
 */
private void connectToDevicePort(final MidiDeviceInfo sourceDeviceInfo,
        final int sourcePortIndex,
        final MidiInputPort destinationInputPort,
        final OnPortsConnectedListener listener, final Handler handler) {
    mMidiManager.openDevice(sourceDeviceInfo,
            new MidiManager.OnDeviceOpenedListener() {
                @Override
                public void onDeviceOpened(MidiDevice device) {
                    if (device == null) {
                        Log.e(MidiConstants.TAG,
                                "could not open " + sourceDeviceInfo);
                        safeClose();
                        if (listener != null) {
                            listener.onPortsConnected(null);
                        }
                    } else {
                        Log.i(MidiConstants.TAG,
                                "connectToDevicePort opened "
                                        + sourceDeviceInfo);
                        // Device was opened so connect the ports.
                        mSourceDevice = device;
                        mConnection = device.connectPorts(
                                destinationInputPort, sourcePortIndex);
                        if (mConnection == null) {
                            Log.e(MidiConstants.TAG, "could not connect to "
                                    + sourceDeviceInfo);
                            safeClose();
                        }
                        if (listener != null) {
                            listener.onPortsConnected(mConnection);
                        }
                    }
                }
            }, handler);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:44,代码来源:MidiPortConnector.java


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