Java Code Examples for android.media.midi.MidiDeviceInfo#getPorts()
The following examples show how to use
android.media.midi.MidiDeviceInfo#getPorts() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MidiPrinter.java From media-samples with Apache License 2.0 | 6 votes |
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") .append("[") .append(port.getPortNumber()) .append("] = \"") .append(port.getName()).append("\"\n"); } } return sb.toString(); }
Example 2
Source File: MidiPrinter.java From android-MidiScope with Apache License 2.0 | 6 votes |
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") .append("[") .append(port.getPortNumber()) .append("] = \"") .append(port.getName()).append("\"\n"); } } return sb.toString(); }
Example 3
Source File: MidiPrinter.java From android-midisuite with Apache License 2.0 | 6 votes |
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(); }
Example 4
Source File: MidiOutputPortProviderImpl.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
public List<MidiOutputPort> listPorts() { if( this.ports == null ) { this.ports = new ArrayList<MidiOutputPort>(); } else { this.ports.clear(); } if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M ) { TGActivity activity = TGActivityController.getInstance(this.context).getActivity(); if( activity != null && activity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_MIDI)) { MidiManager midiManager = (MidiManager) activity.getSystemService(Context.MIDI_SERVICE); MidiDeviceInfo[] infos = midiManager.getDevices(); for(MidiDeviceInfo info : infos) { if( info.getInputPortCount() > 0 ) { MidiDeviceInfo.PortInfo[] portInfos = info.getPorts(); for(MidiDeviceInfo.PortInfo portInfo : portInfos) { if( portInfo.getType() == MidiDeviceInfo.PortInfo.TYPE_INPUT) { this.ports.add(new MidiOutputPortImpl(this.context, info, portInfo)); } } } } } } return this.ports; }