Comments (8)
支持fragment,你需要在onViewCreated
中初始化GiraffePlayer
from giraffeplayer.
@tcking 我就是在onViewCreated中初始化的,GiraffePlayer初始化需要传入Activity,我使用getActivity传入不可行,或者有什么别的方法传入activity?
from giraffeplayer.
fragment加载的布局需要include giraffe_player.xml
,在onViewCreated
初始化传入getActivity ()
就行
from giraffeplayer.
@tcking 没错啊,我就是这样做的。
fragment_tab_learning.xml
`
<include
android:id="@+id/player_learning"
layout="@layout/giraffe_player"
android:layout_width="match_parent"
android:layout_height="200dp" />
<com.jcodecraeer.xrecyclerview.XRecyclerView
android:id="@+id/rv_list_learning"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/player_learning" />
但是仍然报错。
videoView = (IjkVideoView) activity.findViewById(R.id.video_view);
videoView.setAspectRatio(IRenderView.AR_MATCH_PARENT);
在上面一句,videoview报空指针异常。应该是不能通过传过来的activity获得videoview。
from giraffeplayer.
注意,是在onViewCreated,不是onCreatView
from giraffeplayer.
@tcking 仍然不行。
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); player = new GiraffePlayer(getActivity()); }
View liveBox = activity.findViewById(R.id.app_video_box); liveBox.setClickable(true);
这里报错,错误如下。
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setClickable(boolean)' on a null object reference at tcking.github.com.giraffeplayer.GiraffePlayer.<init>(GiraffePlayer.java:332) at com.bri.cdstm.ui.fragment.TabLearningFragment.onViewCreated(TabLearningFragment.java:134)
from giraffeplayer.
@tcking @sendtion "fragment加载的布局需要include giraffe_player.xml ,在 onViewCreated 初始化传入 getActivity () 就行",我的项目中这样做以后,确实可以
from giraffeplayer.
@sendtion
我的xml文件:
我的fragment文件中:
@OverRide
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mVedioPlayer = new GiraffePlayer(this.getActivity());
if (mVideoPath == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(
getActivity(),
"No Video Found! Press Back Button To Exit",
Toast.LENGTH_LONG).show();
} else {
mVedioPlayer.play(mVideoPath);
}
}
from giraffeplayer.
Related Issues (20)
- 播放器如何去掉循环播放, HOT 1
- Right to left support ? HOT 1
- How to get current duration and total duration ? HOT 1
- IJKMEDIA: Immediate exit requested
- Video not playing for some specific format.
- high quality 1080 video playback problem lag
- Frist time configuration
- can not play https url
- No audio in player HOT 1
- How do call onError method more than one time HOT 1
- Lazy casting on hd channels
- @Override public void onCompletion(final GiraffePlayer giraffePlayer)
- onCompletion function is not working and offline video is not playing
- listener not working
- 播放 报 video play error
- 支持播放直接推过来的byte[] 流吗?
- subtitel
- MOV 格式的视频播放失败
- how to change player user agent?
- How to add subtitle?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from giraffeplayer.