當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。