本文整理汇总了Java中org.schabi.newpipe.extractor.stream.VideoStream类的典型用法代码示例。如果您正苦于以下问题:Java VideoStream类的具体用法?Java VideoStream怎么用?Java VideoStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VideoStream类属于org.schabi.newpipe.extractor.stream包,在下文中一共展示了VideoStream类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.schabi.newpipe.extractor.stream.VideoStream; //导入依赖的package包/类
public static void main(String argv[]) {
if(argv.length == 0) {
System.err.println("please provide a youtube url as first parameter.");
return;
}
String url = argv[0];
//first we need to set the Downloader, so NewPipe knows how to get the files
NewPipe.init(initDownloader());
try {
StreamingService youtube = NewPipe.getService("Youtube");
StreamExtractor extractor = youtube.getStreamExtractorInstance(url);
// actual extraction
StreamInfo streamInfo = StreamInfo.getVideoInfo(extractor);
// if non critical exceptions happened during extraction they will be printed now
for(Throwable error : streamInfo.errors) {
System.err.println("----------------");
error.printStackTrace();
}
// now print the stream url and we are done
for(VideoStream stream : streamInfo.video_streams) {
if(stream.resolution.contains("320p") ||
stream.resolution.contains("720p") ||
stream.resolution.contains("360p")) {
System.out.print(stream.url);
return;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: testGetVideoStreams
import org.schabi.newpipe.extractor.stream.VideoStream; //导入依赖的package包/类
@Test
public void testGetVideoStreams() throws IOException, ExtractionException {
List<VideoStream> streams = new ArrayList<>();
streams.addAll(extractor.getVideoStreams());
streams.addAll(extractor.getVideoOnlyStreams());
assertTrue(streams.size() > 0);
for (VideoStream s : streams) {
assertTrue(s.getUrl(),
s.getUrl().contains(HTTPS));
assertTrue(s.resolution.length() > 0);
assertTrue(Integer.toString(s.getFormatId()),
0 <= s.getFormatId() && s.getFormatId() <= 4);
}
}