- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚将 exoplayer 设置为播放 .m3u8 视频。但是有些视频正在播放,如果某些链接没有播放,则只有加载时间。
"http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8 "
这个链接播放...
"https://hl.bobtor.com/hl/Mortal.Engines.2018.HDCAM.x264.AC3-MP4KiNG.m3u8 "
此链接未播放,仅在加载时播放
这是我的代码
公共(public)类 MainActivity 扩展了 AppCompatActivity {
private final String STATE_RESUME_WINDOW = "resumeWindow";
private final String STATE_RESUME_POSITION = "resumePosition";
private final String STATE_PLAYER_FULLSCREEN = "playerFullscreen";
private SimpleExoPlayerView mExoPlayerView;
private MediaSource mVideoSource;
private boolean mExoPlayerFullscreen = false;
private FrameLayout mFullScreenButton;
private ImageView mFullScreenIcon;
private Dialog mFullScreenDialog;
private int mResumeWindow;
private long mResumePosition;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState != null) {
mResumeWindow = savedInstanceState.getInt(STATE_RESUME_WINDOW);
mResumePosition = savedInstanceState.getLong(STATE_RESUME_POSITION);
mExoPlayerFullscreen = savedInstanceState.getBoolean(STATE_PLAYER_FULLSCREEN);
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putInt(STATE_RESUME_WINDOW, mResumeWindow);
outState.putLong(STATE_RESUME_POSITION, mResumePosition);
outState.putBoolean(STATE_PLAYER_FULLSCREEN, mExoPlayerFullscreen);
super.onSaveInstanceState(outState);
}
private void initFullscreenDialog() {
mFullScreenDialog = new Dialog(this, android.R.style.Theme_Black_NoTitleBar_Fullscreen) {
public void onBackPressed() {
if (mExoPlayerFullscreen)
closeFullscreenDialog();
super.onBackPressed();
}
};
}
private void openFullscreenDialog() {
((ViewGroup) mExoPlayerView.getParent()).removeView(mExoPlayerView);
mFullScreenDialog.addContentView(mExoPlayerView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mFullScreenIcon.setImageDrawable(ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_fullscreen_skrink));
mExoPlayerFullscreen = true;
mFullScreenDialog.show();
}
private void closeFullscreenDialog() {
((ViewGroup) mExoPlayerView.getParent()).removeView(mExoPlayerView);
((FrameLayout) findViewById(R.id.main_media_frame)).addView(mExoPlayerView);
mExoPlayerFullscreen = false;
mFullScreenDialog.dismiss();
mFullScreenIcon.setImageDrawable(ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_fullscreen_expand));
}
private void initFullscreenButton() {
PlaybackControlView controlView = mExoPlayerView.findViewById(R.id.exo_controller);
mFullScreenIcon = controlView.findViewById(R.id.exo_fullscreen_icon);
mFullScreenButton = controlView.findViewById(R.id.exo_fullscreen_button);
mFullScreenButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!mExoPlayerFullscreen)
openFullscreenDialog();
else
closeFullscreenDialog();
}
});
}
private void initExoPlayer() {
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl();
SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(new DefaultRenderersFactory(this), trackSelector, loadControl);
mExoPlayerView.setPlayer(player);
boolean haveResumePosition = mResumeWindow != C.INDEX_UNSET;
if (haveResumePosition) {
mExoPlayerView.getPlayer().seekTo(mResumeWindow, mResumePosition);
}
mExoPlayerView.getPlayer().prepare(mVideoSource);
mExoPlayerView.getPlayer().setPlayWhenReady(true);
}
@Override
protected void onResume() {
super.onResume();
if (mExoPlayerView == null) {
mExoPlayerView = (SimpleExoPlayerView) findViewById(R.id.exoplayer);
initFullscreenDialog();
initFullscreenButton();
Intent in = getIntent();
// String streamUrl = in.getStringExtra("url");//in.getIntExtra("pos", 0);
String streamUrl = "https://hl.bobtor.com/hl/Mortal.Engines.2018.HDCAM.x264.AC3-MP4KiNG.m3u8";//"http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8";
String userAgent = Util.getUserAgent(MainActivity.this, getApplicationContext().getApplicationInfo().packageName);
DefaultHttpDataSourceFactory httpDataSourceFactory = new DefaultHttpDataSourceFactory(userAgent, null, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS, DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, true);
DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(MainActivity.this, null, httpDataSourceFactory);
Uri daUri = Uri.parse(streamUrl);
mVideoSource = new HlsMediaSource(daUri, dataSourceFactory, 1, null, null);
}
initExoPlayer();
if (mExoPlayerFullscreen) {
((ViewGroup) mExoPlayerView.getParent()).removeView(mExoPlayerView);
mFullScreenDialog.addContentView(mExoPlayerView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mFullScreenIcon.setImageDrawable(ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_fullscreen_skrink));
mFullScreenDialog.show();
}
}
@Override
protected void onPause() {
super.onPause();
if (mExoPlayerView != null && mExoPlayerView.getPlayer() != null) {
mResumeWindow = mExoPlayerView.getPlayer().getCurrentWindowIndex();
mResumePosition = Math.max(0, mExoPlayerView.getPlayer().getContentPosition());
mExoPlayerView.getPlayer().release();
}
if (mFullScreenDialog != null)
mFullScreenDialog.dismiss();
}
}
最佳答案
我无法打开您的网址,但从网址中我可以看到流正在使用 AC3 编解码器。 ExoPlayer 不支持 AC3 编解码器。您需要为 ExoPlayer 使用 FFmpeg 扩展。
关于android - Exoplayer 只播放一些 .m3u8 链接,其他的只是加载时间但不开始播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53996428/
我不确定我明白这里发生了什么。 请问有人可以解释一下吗? 我收到以下错误: Type of 'exoPlayer' doesn't match the type of the overridden v
我在尝试编译 exoplayer r1.5.2 存储库时遇到问题...。当我改用 com.google.android.exoplayer:exoplayer:r1.4.2 时没有问题。 编译代码如下
我有这个简单的 .m3u8 文件 #EXTM3U #EXT-X-VERSION:5 #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="English ste
为了避免应用程序中的任何 SCSS ,从后台线程使用 exoplayer 还是从主 ui 线程使用它更好? 注意:当我在主 ui 线程中创建一个 simpleExoPlayer 时: // 1. Cr
我有一个 exoplayer 我的第一个 Activity ,当我点击全屏按钮时,我打开一个新的 VideoActivity 全屏。我只发送我当前的位置并在该位置启动 VideoActivity。
我在 DemoPlayer 的基础上使用 Exoplayer。我想在 ExoPlayer.STATE_ENDED 被调度后在一些用户操作时从头开始重新启动/重播视频。 之后我尝试使用 seekTo(0
我在我的 android 应用程序中使用 exoplayer,在播放视频时我点击屏幕,带有 Controller 的显示不流畅,我想让它看起来流畅,就像淡入淡出..如何我可以这样做吗? 最佳答案 查看
我在 CardView 的 RecyclerView 中有一个 ex0player。 exoplayer 的高度需要根据包含的视频的高度以编程方式更改。此高度值以 像素 的形式从 API 调用返回。这
在 android 中有一个名为 的库。 Exoplayer 这与从给定 url 流式传输视频有关。 现在根据this firebase 不支持视频流,尽管您可以将 uri 从 url 传递到 vid
更新项目依赖项后,我在视频 android studio 应用程序中遇到这个 exoplayer not found 错误。 我不知道如何将旧的 Exoplayer 链接更新到 https://mvn
我在 android 中构建一个 expo 分离项目时遇到问题。当我构建项目时,控制台构建的输出显示:无法解析:com.google.android.exoplayer:exoplayer-smoot
情况:将我的 Android 项目从带有 VisualOn 的旧 Ooyala SDK 更新到带有 Exoplyer 的最新 Ooyala SDK。通过 Amazon Fire Stick 播放视频。
我制作了安卓音频应用程序。现在一些用户报告说,当他们在车内通过蓝牙连接设备时,应用程序没有响应媒体按钮(播放、暂停、下一步)。 同时,我用蓝牙扬声器测试了应用程序 - 播放/暂停按钮可按需工作。 车载
我希望在我的项目中实现 exoplayer。我已经成功实现了它,但是视频加载时间很慢。如何在 exoplayer 中实现或实现视频的快速加载?就像抖音一样——立即加载视频并开始播放 最佳答案 试试下面
遵循开发人员指南中给出的示例后,我得到以下信息: 05-23 16:25:22.002 11893-11942/com.app.videotest E/ExoPlayerImplInternal: S
我基于此 link 在我的应用程序中集成了 exoplayer . 我在 createCurrentContentIntent() 中添加了一个待处理的 Intent 。 return Pen
我正在阅读有关配置默认 exoplayer View 布局的教程: https://exoplayer.dev/ui-components.html 但是它不显示默认播放器布局的源代码 exo_pla
我想使用 PlayerView 在 exoplayer 中创建一个自定义时间栏: 不能被用户拖动,只能在视频中显示进度 更新:好的,所以我可以通过将 touch_target_height 设置为 0
07-03 18:51:01.600 16188-16266/? E/ExoPlayerImplInternal﹕ Internal runtime error. java.lang.Ill
使用 ExoPlayer我正在尝试同时播放两个音轨。 我的想法是创建两个 MediaSource , 并使用 MergingMediaSource 在它们之间“组合” . 这就是我所做的: U
我是一名优秀的程序员,十分优秀!