Git Product home page Git Product logo

Comments (8)

tcking avatar tcking commented on July 19, 2024

支持fragment,你需要在onViewCreated中初始化GiraffePlayer

from giraffeplayer.

sendtion avatar sendtion commented on July 19, 2024

@tcking 我就是在onViewCreated中初始化的,GiraffePlayer初始化需要传入Activity,我使用getActivity传入不可行,或者有什么别的方法传入activity?

from giraffeplayer.

tcking avatar tcking commented on July 19, 2024

fragment加载的布局需要include giraffe_player.xml,在onViewCreated初始化传入getActivity ()就行

from giraffeplayer.

sendtion avatar sendtion commented on July 19, 2024

@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" />
` **TabLearningFargment.java** `@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_tab_learning, null); //iv_learning_banner = (ImageView) view.findViewById(R.id.iv_learning_banner); rv_list_learning = (XRecyclerView) view.findViewById(R.id.rv_list_learning); player = new GiraffePlayer(getActivity()); }`

但是仍然报错。
videoView = (IjkVideoView) activity.findViewById(R.id.video_view);
videoView.setAspectRatio(IRenderView.AR_MATCH_PARENT);
在上面一句,videoview报空指针异常。应该是不能通过传过来的activity获得videoview。

from giraffeplayer.

tcking avatar tcking commented on July 19, 2024

注意,是在onViewCreated,不是onCreatView

from giraffeplayer.

sendtion avatar sendtion commented on July 19, 2024

@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.

hisonedumobile avatar hisonedumobile commented on July 19, 2024

@tcking @sendtion "fragment加载的布局需要include giraffe_player.xml ,在 onViewCreated 初始化传入 getActivity () 就行",我的项目中这样做以后,确实可以

from giraffeplayer.

hisonedumobile avatar hisonedumobile commented on July 19, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.