当前位置: 首页>>代码示例>>Java>>正文


Java VideoStream类代码示例

本文整理汇总了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();
    }
}
 
开发者ID:TeamNewPipe,项目名称:np-cli,代码行数:38,代码来源:GetStreamUrl.java

示例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);
    }
}
 
开发者ID:TeamNewPipe,项目名称:NewPipeExtractor,代码行数:16,代码来源:YoutubeStreamExtractorRestrictedTest.java


注:本文中的org.schabi.newpipe.extractor.stream.VideoStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。