类android.media.midi.MidiDeviceStatus源码实例Demo

下面列出了怎么用android.media.midi.MidiDeviceStatus的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: android-midisuite   文件: MidiDeviceMonitor.java
@Override
public void onDeviceStatusChanged(final MidiDeviceStatus status) {
    for(Map.Entry<DeviceCallback, Handler> item : mCallbacks.entrySet()) {
        final DeviceCallback callback = item.getKey();
        Handler handler = item.getValue();
        if(handler == null) {
            callback.onDeviceStatusChanged(status);
        } else {
            handler.post(new Runnable() {
                @Override
                public void run() {
                    callback.onDeviceStatusChanged(status);
                }
            });
        }
    }
}
 
源代码2 项目: media-samples   文件: MidiScope.java
/**
 * This will get called when clients connect or disconnect.
 * Log device information.
 */
@Override
public void onDeviceStatusChanged(MidiDeviceStatus status) {
    if (mScopeLogger != null) {
        if (status.isInputPortOpen(0)) {
            mScopeLogger.log("=== connected ===");
            String text = MidiPrinter.formatDeviceInfo(
                    status.getDeviceInfo());
            mScopeLogger.log(text);
        } else {
            mScopeLogger.log("--- disconnected ---");
        }
    }
}
 
源代码3 项目: media-samples   文件: MidiPortSelector.java
@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();
                    }
                }
            }
        }
    }
}
 
源代码4 项目: media-samples   文件: MidiSynthDeviceService.java
/**
 * This will get called when clients connect or disconnect.
 */
@Override
public void onDeviceStatusChanged(MidiDeviceStatus status) {
    if (status.isInputPortOpen(0) && !mSynthStarted) {
        mSynthEngine.start();
        mSynthStarted = true;
    } else if (!status.isInputPortOpen(0) && mSynthStarted) {
        mSynthEngine.stop();
        mSynthStarted = false;
    }
}
 
源代码5 项目: media-samples   文件: MidiPortSelector.java
@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();
                    }
                }
            }
        }
    }
}
 
/**
 * This will get called when clients connect or disconnect.
 */
@Override
public void onDeviceStatusChanged(MidiDeviceStatus status) {
    if (status.isInputPortOpen(0) && !mSynthStarted) {
        mSynthEngine.start();
        mSynthStarted = true;
    } else if (!status.isInputPortOpen(0) && mSynthStarted) {
        mSynthEngine.stop();
        mSynthStarted = false;
    }
}
 
源代码7 项目: android-MidiSynth   文件: MidiPortSelector.java
@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();
                    }
                }
            }
        }
    }
}
 
源代码8 项目: android-MidiScope   文件: MidiScope.java
/**
 * This will get called when clients connect or disconnect.
 * Log device information.
 */
@Override
public void onDeviceStatusChanged(MidiDeviceStatus status) {
    if (mScopeLogger != null) {
        if (status.isInputPortOpen(0)) {
            mScopeLogger.log("=== connected ===");
            String text = MidiPrinter.formatDeviceInfo(
                    status.getDeviceInfo());
            mScopeLogger.log(text);
        } else {
            mScopeLogger.log("--- disconnected ---");
        }
    }
}
 
源代码9 项目: android-MidiScope   文件: MidiPortSelector.java
@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();
                    }
                }
            }
        }
    }
}
 
源代码10 项目: android-midisuite   文件: MidiScope.java
/**
 * This will get called when clients connect or disconnect.
 * Log device information.
 */
@Override
public void onDeviceStatusChanged(MidiDeviceStatus status) {
    if (mScopeLogger != null) {
        if (status.isInputPortOpen(0)) {
            mScopeLogger.log("=== connected ===");
            String text = MidiPrinter.formatDeviceInfo(
                    status.getDeviceInfo());
            mScopeLogger.log(text);
        } else {
            mScopeLogger.log("--- disconnected ---");
        }
    }
}
 
源代码11 项目: android-midisuite   文件: MidiSynthDeviceService.java
/**
 * This will get called when clients connect or disconnect.
 */
@Override
public void onDeviceStatusChanged(MidiDeviceStatus status) {
    if (status.isInputPortOpen(0) && !mSynthStarted) {
        mSynthEngine.start();
        mSynthStarted = true;
    } else if (!status.isInputPortOpen(0) && mSynthStarted){
        mSynthEngine.stop();
        mSynthStarted = false;
    }
}
 
源代码12 项目: android-midisuite   文件: MidiPortSelector.java
@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();
                    }
                }
            }
        }
    }
}
 
 类所在包
 类方法
 同包方法