在大多数情况下,这似乎是使用系统默认设备处理的。
有没有办法像在ExoPlayer / MediaPlayer的AudioTrack.setPrerredDevice(AudioDeviceInfo info)中手动设置视频的输出设备一样?
如果没有其他选择,我可以这样做吗?
答案 0 :(得分:1)
为了解决我的问题,我必须下载Exoplayer的源代码,并公开一种将硬件设置为正轨的方法:
DefaultAudioSink.Java
var dbTable = localStorage.getItem('dbTable');
var ddlb = '';
var ddlb2 = '';
$.ajax({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
url: "laporan/header",
type: "POST",
data: {
table: dbTable
},
beforeSend: function () {
$("#kondisiHeader").empty();
ddlb = ddlb + '<br>Filter<br>';
ddlb2 = ddlb2 + '<br>Filter<br>';
ddlb = ddlb + '<div><div id="filterDiv1">';
ddlb2 = ddlb2 + '<div><div id="filterDiv2">';
},
success: function (result) {
ddlb = ddlb + '<select name="filter1" id="kondisiSelect1">';
ddlb2 = ddlb2 + '<select name="filter2" id="kondisiSelect2">';
$.each(result, function (e, item) {
ddlb = ddlb + '<option value="' + item.column_name + '">' + item.column_name + '</option>';
ddlb2 = ddlb2 + '<option value="' + item.column_name + '">' + item.column_name + '</option>';
});
ddlb = ddlb + '</select>';
ddlb2 = ddlb2 + '</select>';
ddlb = ddlb + '<select name="kondisi1" id="kondisi1">';
ddlb2 = ddlb2 + '<select name="kondisi2" id="kondisi2">';
ddlb = ddlb + '<option value="like">like</option>';
ddlb2 = ddlb2 + '<option value="like">like</option>';
ddlb = ddlb + '<option value="=">=</option>';
ddlb2 = ddlb2 + '<option value="=">=</option>';
ddlb = ddlb + '<option value="!=">!=</option>';
ddlb2 = ddlb2 + '<option value="!=">!=</option>';
ddlb = ddlb + '<option value=">">></option>';
ddlb2 = ddlb2 + '<option value=">">></option>';
ddlb = ddlb + '<option value="<"><</option>';
ddlb2 = ddlb2 + '<option value="<"><</option>';
ddlb = ddlb + '</select>';
ddlb2 = ddlb2 + '</select>';
ddlb = ddlb + '<input type="text" name="valueKondisi1">';
ddlb2 = ddlb2 + '<input type="text" name="valueKondisi2">';
ddlb = ddlb + '<select name="kondisiAndOr1" id="andKondisi1">';
ddlb2 = ddlb2 + '<select name="kondisiAndOr2" id="andKondisi2">';
ddlb = ddlb + '<option value="">-</option>';
ddlb2 = ddlb2 + '<option value="">-</option>';
ddlb = ddlb + '<option value="and">AND</option>';
ddlb2 = ddlb2 + '<option value="and">AND</option>';
ddlb = ddlb + '<option value="or">OR</option>';
ddlb2 = ddlb2 + '<option value="or">OR</option>';
ddlb = ddlb + '</select>';
ddlb2 = ddlb2 + '</select>';
ddlb = ddlb + '</div>';
ddlb2 = ddlb2 + '</div>';
ddlb = ddlb + '<div id="kondisiHeader2"></div></div>';
ddlb2 = ddlb2 + '<div id="kondisiHeader2"></div></div>';
block_to_insert = document.createElement('div');
block_to_insert.innerHTML = ddlb;
container_block = document.getElementById('kondisiHeader');
container_block.appendChild( block_to_insert );
localStorage.setItem('ddlb2', ddlb2);
localStorage.setItem('dbTable', dbTable);
}
});
});
$("#kondisiHeader").on('change', function (e) {
var ddlb2 = localStorage.getItem('ddlb2');
block_to_insert2 = document.createElement('div');
block_to_insert2.innerHTML = ddlb2;
container_block2 = document.getElementById('kondisiHeader2');
container_block2.appendChild( block_to_insert2 );
});
内部if语句已添加到上述代码中。
AudioAttributes.Java
private AudioTrack initializeAudioTrack() throws InitializationException {
AudioTrack audioTrack;
if (Util.SDK_INT >= 21) {
audioTrack = createAudioTrackV21();
if (audioAttributes.device != null && Util.SDK_INT >= 23) {
audioTrack.setPreferredDevice(audioAttributes.device);
}
}
这添加了一个公共生成器元素,以允许在AudioAttributes上设置首选设备。
public Builder setPreferredDevice(AudioDeviceInfo device) {
this.playbackDevice = device;
return this;
}
public AudioAttributes build() {
return new AudioAttributes(contentType, flags, usage, playbackDevice);
}
已将AudioDeviceInfo变量添加到AudioAttributes构造函数。
public AudioDeviceInfo device;
private @Nullable android.media.AudioAttributes audioAttributesV21;
private android.media.AudioAttributes audioAttributesV21;
private AudioAttributes(@C.AudioContentType int contentType, @C.AudioFlags int flags,
@C.AudioUsage int usage) {
@C.AudioUsage int usage, AudioDeviceInfo device) {
this.contentType = contentType;
this.flags = flags;
this.usage = usage;
this.device = device;
}
添加了源格式化检查,以等于该设备的替代:&& this.device == other.device
这使我可以编译项目,并像往常一样添加为库,但是还可以将所需的设备设置为构建器的一部分。好处是它还可以动态工作。我相信Media也可以达到同样的效果 播放器