renamed video classes to stream classes
This commit is contained in:
parent
b1fe197c11
commit
045ca40a77
20 changed files with 190 additions and 189 deletions
|
|
@ -50,9 +50,9 @@ import org.schabi.newpipe.extractor.MediaFormat;
|
|||
import org.schabi.newpipe.extractor.ParsingException;
|
||||
import org.schabi.newpipe.extractor.ServiceList;
|
||||
import org.schabi.newpipe.extractor.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.VideoPreviewInfo;
|
||||
import org.schabi.newpipe.extractor.StreamInfo;
|
||||
import org.schabi.newpipe.extractor.StreamPreviewInfo;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.VideoInfo;
|
||||
import org.schabi.newpipe.extractor.services.youtube.YoutubeStreamExtractor;
|
||||
|
||||
|
||||
|
|
@ -127,12 +127,12 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
VideoInfo videoInfo = null;
|
||||
StreamInfo streamInfo = null;
|
||||
try {
|
||||
streamExtractor = service.getExtractorInstance(videoUrl, new Downloader());
|
||||
videoInfo = VideoInfo.getVideoInfo(streamExtractor, new Downloader());
|
||||
streamInfo = StreamInfo.getVideoInfo(streamExtractor, new Downloader());
|
||||
|
||||
h.post(new VideoResultReturnedRunnable(videoInfo));
|
||||
h.post(new VideoResultReturnedRunnable(streamInfo));
|
||||
} catch (IOException e) {
|
||||
postNewErrorToast(h, R.string.network_error);
|
||||
e.printStackTrace();
|
||||
|
|
@ -165,14 +165,14 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
e.printStackTrace();
|
||||
} catch(VideoInfo.StreamExctractException e) {
|
||||
if(!videoInfo.errors.isEmpty()) {
|
||||
} catch(StreamInfo.StreamExctractException e) {
|
||||
if(!streamInfo.errors.isEmpty()) {
|
||||
// !!! if this case ever kicks in someone gets kicked out !!!
|
||||
ErrorActivity.reportError(h, getActivity(), e, VideoItemListActivity.class, null,
|
||||
ErrorActivity.ErrorInfo.make(ErrorActivity.REQUESTED_STREAM,
|
||||
service.getServiceInfo().name, videoUrl, R.string.could_not_get_stream));
|
||||
} else {
|
||||
ErrorActivity.reportError(h, getActivity(), videoInfo.errors, VideoItemListActivity.class, null,
|
||||
ErrorActivity.reportError(h, getActivity(), streamInfo.errors, VideoItemListActivity.class, null,
|
||||
ErrorActivity.ErrorInfo.make(ErrorActivity.REQUESTED_STREAM,
|
||||
service.getServiceInfo().name, videoUrl, R.string.could_not_get_stream));
|
||||
}
|
||||
|
|
@ -206,17 +206,17 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
});
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(videoInfo != null &&
|
||||
!videoInfo.errors.isEmpty()) {
|
||||
if(streamInfo != null &&
|
||||
!streamInfo.errors.isEmpty()) {
|
||||
Log.e(TAG, "OCCURRED ERRORS DURING EXTRACTION:");
|
||||
for(Exception e : videoInfo.errors) {
|
||||
for(Exception e : streamInfo.errors) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Activity a = getActivity();
|
||||
View rootView = a != null ? a.findViewById(R.id.videoitem_detail) : null;
|
||||
ErrorActivity.reportError(h, getActivity(),
|
||||
videoInfo.errors, null, rootView,
|
||||
streamInfo.errors, null, rootView,
|
||||
ErrorActivity.ErrorInfo.make(ErrorActivity.REQUESTED_STREAM,
|
||||
service.getServiceInfo().name, videoUrl, 0 /* no message for the user */));
|
||||
}
|
||||
|
|
@ -225,16 +225,16 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
}
|
||||
|
||||
private class VideoResultReturnedRunnable implements Runnable {
|
||||
private final VideoInfo videoInfo;
|
||||
public VideoResultReturnedRunnable(VideoInfo videoInfo) {
|
||||
this.videoInfo = videoInfo;
|
||||
private final StreamInfo streamInfo;
|
||||
public VideoResultReturnedRunnable(StreamInfo streamInfo) {
|
||||
this.streamInfo = streamInfo;
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
boolean show_age_restricted_content = PreferenceManager.getDefaultSharedPreferences(getActivity())
|
||||
.getBoolean(activity.getString(R.string.show_age_restricted_content), false);
|
||||
if(videoInfo.age_limit == 0 || show_age_restricted_content) {
|
||||
updateInfo(videoInfo);
|
||||
if(streamInfo.age_limit == 0 || show_age_restricted_content) {
|
||||
updateInfo(streamInfo);
|
||||
} else {
|
||||
onNotSpecifiedContentErrorWithMessage(R.string.video_is_age_restricted);
|
||||
}
|
||||
|
|
@ -261,7 +261,7 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
public void onLoadingCancelled(String imageUri, View view) {}
|
||||
}
|
||||
|
||||
private void updateInfo(final VideoInfo info) {
|
||||
private void updateInfo(final StreamInfo info) {
|
||||
try {
|
||||
Context c = getContext();
|
||||
VideoInfoItemViewCreator videoItemViewCreator =
|
||||
|
|
@ -378,8 +378,8 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
descriptionView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
// parse streams
|
||||
Vector<VideoInfo.VideoStream> streamsToUse = new Vector<>();
|
||||
for (VideoInfo.VideoStream i : info.video_streams) {
|
||||
Vector<StreamInfo.VideoStream> streamsToUse = new Vector<>();
|
||||
for (StreamInfo.VideoStream i : info.video_streams) {
|
||||
if (useStream(i, streamsToUse)) {
|
||||
streamsToUse.add(i);
|
||||
}
|
||||
|
|
@ -435,7 +435,7 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
private void initThumbnailViews(VideoInfo info, View nextVideoFrame) {
|
||||
private void initThumbnailViews(StreamInfo info, View nextVideoFrame) {
|
||||
ImageView videoThumbnailView = (ImageView) activity.findViewById(R.id.detailThumbnailView);
|
||||
ImageView uploaderThumb
|
||||
= (ImageView) activity.findViewById(R.id.detailUploaderThumbnailView);
|
||||
|
|
@ -478,7 +478,7 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
private void setupActionBarHandler(final VideoInfo info) {
|
||||
private void setupActionBarHandler(final StreamInfo info) {
|
||||
actionBarHandler.setupStreamList(info.video_streams);
|
||||
|
||||
actionBarHandler.setOnShareListener(new ActionBarHandler.OnActionListener() {
|
||||
|
|
@ -545,7 +545,7 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
// website which was crawled. Then the ui has to understand this and act right.
|
||||
|
||||
if (info.audio_streams != null) {
|
||||
VideoInfo.AudioStream audioStream =
|
||||
StreamInfo.AudioStream audioStream =
|
||||
info.audio_streams.get(getPreferredAudioStreamId(info));
|
||||
|
||||
String audioSuffix = "." + MediaFormat.getSuffixById(audioStream.format);
|
||||
|
|
@ -554,7 +554,7 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
}
|
||||
|
||||
if (info.video_streams != null) {
|
||||
VideoInfo.VideoStream selectedStreamItem = info.video_streams.get(selectedStreamId);
|
||||
StreamInfo.VideoStream selectedStreamItem = info.video_streams.get(selectedStreamId);
|
||||
String videoSuffix = "." + MediaFormat.getSuffixById(selectedStreamItem.format);
|
||||
args.putString(DownloadDialog.FILE_SUFFIX_VIDEO, videoSuffix);
|
||||
args.putString(DownloadDialog.VIDEO_URL, selectedStreamItem.url);
|
||||
|
|
@ -581,7 +581,7 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
boolean useExternalAudioPlayer = PreferenceManager.getDefaultSharedPreferences(activity)
|
||||
.getBoolean(activity.getString(R.string.use_external_audio_player_key), false);
|
||||
Intent intent;
|
||||
VideoInfo.AudioStream audioStream =
|
||||
StreamInfo.AudioStream audioStream =
|
||||
info.audio_streams.get(getPreferredAudioStreamId(info));
|
||||
if (!useExternalAudioPlayer && android.os.Build.VERSION.SDK_INT >= 18) {
|
||||
//internal music player: explicit intent
|
||||
|
|
@ -640,7 +640,7 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
private int getPreferredAudioStreamId(final VideoInfo info) {
|
||||
private int getPreferredAudioStreamId(final StreamInfo info) {
|
||||
String preferredFormatString = PreferenceManager.getDefaultSharedPreferences(getActivity())
|
||||
.getString(activity.getString(R.string.default_audio_format_key), "webm");
|
||||
|
||||
|
|
@ -667,10 +667,10 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
return 0;
|
||||
}
|
||||
|
||||
private void initSimilarVideos(final VideoInfo info, VideoInfoItemViewCreator videoItemViewCreator) {
|
||||
private void initSimilarVideos(final StreamInfo info, VideoInfoItemViewCreator videoItemViewCreator) {
|
||||
LinearLayout similarLayout = (LinearLayout) activity.findViewById(R.id.similarVideosView);
|
||||
ArrayList<VideoPreviewInfo> similar = new ArrayList<>(info.related_videos);
|
||||
for (final VideoPreviewInfo item : similar) {
|
||||
ArrayList<StreamPreviewInfo> similar = new ArrayList<>(info.related_videos);
|
||||
for (final StreamPreviewInfo item : similar) {
|
||||
View similarView = videoItemViewCreator
|
||||
.getViewFromVideoInfoItem(null, similarLayout, item, getContext());
|
||||
|
||||
|
|
@ -744,8 +744,8 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
.show();
|
||||
}
|
||||
|
||||
private boolean useStream(VideoInfo.VideoStream stream, Vector<VideoInfo.VideoStream> streams) {
|
||||
for(VideoInfo.VideoStream i : streams) {
|
||||
private boolean useStream(StreamInfo.VideoStream stream, Vector<StreamInfo.VideoStream> streams) {
|
||||
for(StreamInfo.VideoStream i : streams) {
|
||||
if(i.resolution.equals(stream.resolution)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -835,9 +835,9 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
public void playVideo(final VideoInfo info) {
|
||||
public void playVideo(final StreamInfo info) {
|
||||
// ----------- THE MAGIC MOMENT ---------------
|
||||
VideoInfo.VideoStream selectedVideoStream =
|
||||
StreamInfo.VideoStream selectedVideoStream =
|
||||
info.video_streams.get(actionBarHandler.getSelectedVideoStream());
|
||||
|
||||
if (PreferenceManager.getDefaultSharedPreferences(activity)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue