mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-23 12:53:08 +00:00
delete PlayableItem to simplify and add a Method to get the best quality recording
This commit is contained in:
parent
14cfeafa22
commit
29c4283b2a
5 changed files with 28 additions and 45 deletions
|
@ -1,8 +1,6 @@
|
|||
package de.nicidienase.chaosflix.touch.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
|
@ -10,26 +8,18 @@ import android.support.v4.app.FragmentTransaction;
|
|||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.transition.Slide;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionInflater;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.nicidienase.chaosflix.R;
|
||||
import de.nicidienase.chaosflix.common.entities.PlayableItem;
|
||||
import de.nicidienase.chaosflix.common.entities.recording.Conference;
|
||||
import de.nicidienase.chaosflix.common.entities.recording.Event;
|
||||
import de.nicidienase.chaosflix.common.entities.recording.Metadata;
|
||||
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;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
@ -168,10 +158,10 @@ public class BrowseActivity extends TouchBaseActivity implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void playItem(PlayableItem item) {
|
||||
public void playItem(String title, String subtitle, String url) {
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
|
||||
MediaPlayerFragment playerFragment = MediaPlayerFragment.newInstance(item, -1);
|
||||
MediaPlayerFragment playerFragment = MediaPlayerFragment.newInstance(title,subtitle,url);
|
||||
ft.replace(R.id.fragment_container,playerFragment,TAG_RETAINED_FRAGMENT);
|
||||
ft.addToBackStack(null);
|
||||
ft.commit();
|
||||
|
|
|
@ -7,9 +7,12 @@ import android.content.ServiceConnection;
|
|||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.PersistableBundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.devbrackets.android.exomedia.ExoMedia;
|
||||
|
||||
import de.nicidienase.chaosflix.common.network.MediaApiService;
|
||||
import io.reactivex.Single;
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.squareup.picasso.Callback;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
@ -27,7 +26,6 @@ import com.squareup.picasso.Picasso;
|
|||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import de.nicidienase.chaosflix.R;
|
||||
import de.nicidienase.chaosflix.common.entities.PlayableItem;
|
||||
import de.nicidienase.chaosflix.common.entities.recording.Event;
|
||||
|
||||
public class EventDetailsFragment extends Fragment {
|
||||
|
@ -154,7 +152,7 @@ public class EventDetailsFragment extends Fragment {
|
|||
|
||||
private void play() {
|
||||
if(mListener != null){
|
||||
mListener.playItem(mEvent);
|
||||
mListener.playItem(mEvent.getTitle(),mEvent.getSubtitle(),mEvent.getOptimalStream());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,6 +199,6 @@ public class EventDetailsFragment extends Fragment {
|
|||
public interface OnEventDetailsFragmentInteractionListener {
|
||||
void onToolbarStateChange();
|
||||
void setActionbar(Toolbar toolbar);
|
||||
void playItem(PlayableItem item);
|
||||
void playItem(String title, String subtitle, String url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package de.nicidienase.chaosflix.touch.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
@ -12,36 +10,37 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.devbrackets.android.exomedia.ui.widget.VideoControls;
|
||||
import com.devbrackets.android.exomedia.ui.widget.VideoView;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Optional;
|
||||
import de.nicidienase.chaosflix.R;
|
||||
import de.nicidienase.chaosflix.common.entities.PlayableItem;
|
||||
|
||||
public class MediaPlayerFragment extends Fragment {
|
||||
private static final String ARG_ITEM = "title";
|
||||
private static final String ARG_INDEX = "index";
|
||||
private static final String ARG_TITEL = "title";
|
||||
private static final String ARG_SUBTITLE = "subtitle";
|
||||
private static final String ARG_URL = "url";
|
||||
|
||||
private OnMediaPlayerInteractionListener mListener;
|
||||
|
||||
@BindView(R.id.video_view)
|
||||
VideoView videoView;
|
||||
private PlayableItem mItem;
|
||||
private int mIndex = -1;
|
||||
private String mTitle;
|
||||
private String mSubtitle;
|
||||
private String mUrl;
|
||||
|
||||
public MediaPlayerFragment() {
|
||||
}
|
||||
|
||||
public static MediaPlayerFragment newInstance(PlayableItem item, int index) {
|
||||
public static MediaPlayerFragment newInstance(String title, String subtitle, String url) {
|
||||
MediaPlayerFragment fragment = new MediaPlayerFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelable(ARG_ITEM, item);
|
||||
args.putInt(ARG_INDEX,index);
|
||||
args.putString(ARG_TITEL, title);
|
||||
args.putString(ARG_SUBTITLE, subtitle);
|
||||
args.putString(ARG_URL, url);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
@ -51,8 +50,9 @@ public class MediaPlayerFragment extends Fragment {
|
|||
super.onCreate(savedInstanceState);
|
||||
setRetainInstance(true);
|
||||
if (getArguments() != null) {
|
||||
mItem = getArguments().getParcelable(ARG_ITEM);
|
||||
mIndex = getArguments().getInt(ARG_INDEX);
|
||||
mTitle = getArguments().getString(ARG_TITEL);
|
||||
mSubtitle = getArguments().getString(ARG_SUBTITLE);
|
||||
mUrl = getArguments().getString(ARG_URL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,23 +69,13 @@ public class MediaPlayerFragment extends Fragment {
|
|||
ButterKnife.bind(this,view);
|
||||
|
||||
videoView.setOnPreparedListener(() -> videoView.start());
|
||||
if(mIndex >= 0){
|
||||
setVideoByIndex(mIndex);
|
||||
} else {
|
||||
List<String> strings = mItem.getPlaybackOptions();
|
||||
CharSequence[] options = strings.toArray(new CharSequence[strings.size()]);
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.select_option)
|
||||
.setItems(options,(dialog, which) -> setVideoByIndex(which))
|
||||
.create().show();
|
||||
}
|
||||
}
|
||||
VideoControls controls = videoView.getVideoControls();
|
||||
controls.setTitle(mTitle);
|
||||
controls.setSubTitle(mSubtitle);
|
||||
|
||||
private void setVideoByIndex(int index) {
|
||||
videoView.setVideoURI(Uri.parse(mItem.getUrlForOption(index)));
|
||||
videoView.setVideoURI(Uri.parse(mUrl));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
|
|
|
@ -3,12 +3,14 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@color/black"
|
||||
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"/>
|
||||
app:useDefaultControls="true"
|
||||
/>
|
||||
|
||||
</FrameLayout>
|
||||
|
|
Loading…
Reference in a new issue