gpt4 book ai didi

android - ExoPlayer 在某些设备上不播放声音

转载 作者:行者123 更新时间:2023-12-04 14:23:33 32 4
gpt4 key购买 nike

我正在尝试在 Android 上使用 ExoPlayer 创建一个流媒体应用程序。大多数流都工作正常,只有部分流在某些设备上不播放声音。

这是使用此命令提取的流信息:

ffprobe -v error -show_format -show_streams http://nasaiptv.com:8000/live/qSplUhwfcy/bE43JqZPSt/477.ts

[STREAM]
index=0
codec_name=mpeg2video
codec_long_name=MPEG-2 video
profile=Main
codec_type=video
codec_time_base=1/25
codec_tag_string=[2][0][0][0]
codec_tag=0x0002
width=720
height=576
coded_width=0
coded_height=0
has_b_frames=1
sample_aspect_ratio=16:15
display_aspect_ratio=4:3
pix_fmt=yuv420p
level=8
color_range=tv
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
field_order=progressive
timecode=N/A
refs=1
id=0x100
r_frame_rate=25/1
avg_frame_rate=25/1
time_base=1/90000
start_pts=3471311880
start_time=38570.132000
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]
[STREAM]
index=1
codec_name=mp2
codec_long_name=MP2 (MPEG audio layer 2)
profile=unknown
codec_type=audio
codec_time_base=1/48000
codec_tag_string=[3][0][0][0]
codec_tag=0x0003
sample_fmt=fltp
sample_rate=48000
channels=2
channel_layout=stereo
bits_per_sample=0
id=0x101
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/90000
start_pts=3471301664
start_time=38570.018489
duration_ts=N/A
duration=N/A
bit_rate=112000
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]
[FORMAT]
filename=http://nasaiptv.com:8000/live/qSplUhwfcy/AVbqREBSOh/477.ts
nb_streams=2
nb_programs=1
format_name=mpegts
format_long_name=MPEG-TS (MPEG-2 Transport Stream)
start_time=38570.018489
duration=N/A
size=N/A
bit_rate=N/A
probe_score=50
[/FORMAT]

这就是我开始播放流的方式:

   private SimpleExoPlayer player;
private PlayerView exoPlayer;

private void initializePlayer() {
exoPlayer = findViewById(R.id.exo_player);
player = ExoPlayerFactory.newSimpleInstance(
new DefaultRenderersFactory(this, EXTENSION_RENDERER_MODE_ON),
new DefaultTrackSelector(),
new DefaultLoadControl());

player.addListener(listener);

exoPlayer.setPlayer(player);

player.setPlayWhenReady(true);

Uri uri = Uri.parse(stream.getStreamUriString());

MediaSource mediaSource = new ExtractorMediaSource.Factory(
new DefaultHttpDataSourceFactory("exoplayer-codelab")).createMediaSource(uri);
player.prepare(mediaSource, true, false);
}

我还尝试了 EXTENSION_RENDERER_MODE_OFFEXTENSION_RENDERER_MODE_PREFER,但没有成功。

这是在 the sample project 中导入扩展后的结果进入我的项目。

这是 ffmpeg 问题吗?如果我必须从头开始构建扩展,是否可以在 Windows 中进行?在我的 PC 上安装 Linux 有点问题。根据我的流信息,是否有任何教程可以正确执行此操作?

ExoPlayer 是一个很棒的媒体播放器,但它确实缺乏文档(或者很难找到)。

最佳答案

您可以尝试通过将 ExoPlayer.EventListner 附加到您的 SimpleExoPlayer 实例并覆盖 onPlayerError 来获取一些详细的错误信息。

@Override
public void onPlayerError(ExoPlaybackException error) {
switch (error.type) {
case ExoPlaybackException.TYPE_SOURCE:
Log.e(TAG, "TYPE_SOURCE: " + error.getSourceException().getMessage());
break;

case ExoPlaybackException.TYPE_RENDERER:
Log.e(TAG, "TYPE_RENDERER: " + error.getRendererException().getMessage());
break;

case ExoPlaybackException.TYPE_UNEXPECTED:
Log.e(TAG, "TYPE_UNEXPECTED: " + error.getUnexpectedException().getMessage());
break;
}
}

收到错误消息后,请更新您的问题

关于android - ExoPlayer 在某些设备上不播放声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50801894/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com