add mediaplayer fragment

This commit is contained in:
Felix 2017-09-22 00:39:02 +02:00
parent c376f14c22
commit 60e274b959
4 changed files with 105 additions and 3 deletions

View file

@ -48,9 +48,10 @@ dependencies {
implementation 'com.android.support:support-v4:25.4.0'
implementation 'com.android.support:recyclerview-v7:25.4.0'
implementation 'com.android.support:cardview-v7:25.4.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:design:25.4.0'
compile 'com.google.android.exoplayer:exoplayer:r2.5.2'
compile 'com.devbrackets.android:exomedia:4.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton:butterknife:8.5.1'
@ -74,9 +75,9 @@ dependencies {
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
}
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}

View file

@ -27,6 +27,7 @@ import de.nicidienase.chaosflix.common.network.MediaApiService;
import de.nicidienase.chaosflix.touch.fragments.ConferencesTabBrowseFragment;
import de.nicidienase.chaosflix.touch.fragments.EventDetailsFragment;
import de.nicidienase.chaosflix.touch.fragments.EventsFragment;
import de.nicidienase.chaosflix.touch.fragments.MediaPlayerFragment;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
@ -39,7 +40,8 @@ import io.reactivex.disposables.Disposable;
public class BrowseActivity extends TouchBaseActivity implements
ConferencesTabBrowseFragment.OnConferenceListFragmentInteractionListener,
EventsFragment.OnEventsListFragmentInteractionListener,
EventDetailsFragment.OnEventDetailsFragmentInteractionListener{
EventDetailsFragment.OnEventDetailsFragmentInteractionListener,
MediaPlayerFragment.OnMediaPlayerInteractionListener {
private static final String TAG = BrowseActivity.class.getSimpleName();
private static final String TAG_RETAINED_FRAGMENT = "retained_fragment";

View file

@ -0,0 +1,85 @@
package de.nicidienase.chaosflix.touch.fragments;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.devbrackets.android.exomedia.ui.widget.VideoView;
import butterknife.BindView;
import butterknife.ButterKnife;
import de.nicidienase.chaosflix.R;
public class MediaPlayerFragment extends Fragment {
private static final String ARG_TITLE = "title";
private static final String ARG_URL = "url";
private String mTitle;
private String mVideoURL;
private OnMediaPlayerInteractionListener mListener;
@BindView(R.id.video_view)
VideoView videoView;
public MediaPlayerFragment() {
}
public static MediaPlayerFragment newInstance(String title, String videoURL) {
MediaPlayerFragment fragment = new MediaPlayerFragment();
Bundle args = new Bundle();
args.putString(ARG_TITLE, title);
args.putString(ARG_URL,videoURL);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mTitle = getArguments().getString(ARG_TITLE);
mVideoURL = getArguments().getString(ARG_URL);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_media_player, container, false);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this,view);
videoView.setOnPreparedListener(() -> videoView.start());
videoView.setVideoURI(Uri.parse(mVideoURL));
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnMediaPlayerInteractionListener) {
mListener = (OnMediaPlayerInteractionListener) context;
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
mListener = null;
}
public interface OnMediaPlayerInteractionListener {
}
}

View file

@ -0,0 +1,14 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="de.nicidienase.chaosflix.touch.fragments.MediaPlayerFragment">
<com.devbrackets.android.exomedia.ui.widget.VideoView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:useDefaultControls="true"/>
</FrameLayout>