android.media.midi.MidiDeviceStatus#isInputPortOpen ( )源码实例Demo

下面列出了android.media.midi.MidiDeviceStatus#isInputPortOpen ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: 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 ---");
        }
    }
}
 
源代码2 项目: 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();
                    }
                }
            }
        }
    }
}
 
源代码3 项目: 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;
    }
}
 
源代码4 项目: 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;
    }
}
 
源代码6 项目: 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();
                    }
                }
            }
        }
    }
}
 
源代码7 项目: 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 ---");
        }
    }
}
 
源代码8 项目: 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();
                    }
                }
            }
        }
    }
}
 
源代码9 项目: 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 ---");
        }
    }
}
 
源代码10 项目: 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;
    }
}
 
源代码11 项目: 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();
                    }
                }
            }
        }
    }
}
 
 同类方法