搜尋套件、儲存庫與 APP 分類

套件詳情v0.0.5

flutter_youtube_downloader

一個用於提取和下載 YouTube 影片 URL 的 Flutter 插件

AndroidiOS
近 30 天下載
261
喜歡數
71
Pub 分數
130

安裝套件

flutter pub add flutter_youtube_downloader

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 插件,可實現從 YouTube 提取和下載影片 URL,支援 Android 和 iOS 平台。它允許開發者取得影片資訊和下載連結,以供離線存取。該套件可無縫整合至 Flutter 應用程式中,提供直覺的 API 來處理 YouTube 內容。對於需要從 YouTube 取得影片但不依賴官方 YouTube API 的媒體應用非常實用。原始碼公開於 GitHub,確保透明度並可客製化。

適用情境

  • 離線影片播放
  • 影片內容聚合
  • 教育類應用程式媒體下載
  • 自定義影片播放器整合
  • 用於個人用途的內容抓取

主要特色

  • 提取YouTube影片連結
  • 支援 Android 和 iOS
  • 提供影片元資料
  • 開源並有公開倉庫
  • 與 Flutter 的簡單整合

適合對象

  • 開發媒體應用的開發者
  • 需要離線影片存取的應用
  • 教育或教程平台
  • 需要YouTube內容檢索的項目

使用建議

  • 需要遵守YouTube的服務條款
  • 可能受到YouTube反爬取措施的影響
  • 無官方 YouTube API 使用
  • YouTube 更新可能導致變更
  • 僅限影片URL提取,不支援完整影片下載

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

flutter_youtube_downloader

A flutter plugin for extracting and downloading youtube video url

Usage

[Example] (https://github.com/Destiny-Ed/flutter_youtube_downloader/blob/main/example/lib/main.dart)

To use this plugin : *add the dependency to your [pubspec.yaml] file

    dependencies:
        flutter:
            sdk : flutter
        flutter_youtube_downloader:

Add to your app manifest.xml file

  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">  <!-- Add This line -->
    
    ...........
  
    <application
        ..............
        <!-- Add This line -->

        tools:replace="android:label" 
        android:requestLegacyExternalStorage="true"> <!-- Add This line if you are targeting android API 29+-->

        <activity>
            ...............
        </activity>
     
    </application>
</manifest>

Warning

Make sure you don't add ...(dots) after the video title name

[Example] Bad final result = await FlutterYoutubeDownloader.downloadVideo( youTube_link, "Video Title goes Here...", 18);

[Example] Good final result = await FlutterYoutubeDownloader.downloadVideo( youTube_link, "Video Title goes Here", 18);

How To Use

    import 'package:flutter/material.dart';
    import 'dart:async';

    import 'package:flutter/services.dart';
    import 'package:flutter_youtube_downloader/flutter_youtube_downloader.dart';

    void main() {
      runApp(MyApp());
    }

    class MyApp extends StatefulWidget {
      @override
      _MyAppState createState() => _MyAppState();
    }

    class _MyAppState extends State<MyApp> {
      String _extractedLink = 'Loading...';

      String youTube_link = "https://www.youtube.com/watch?v=nRhYQlg8fVw";

      @override
      void initState() {
        super.initState();
        extractYoutubeLink();
      }

      // Platform messages are asynchronous, so we initialize in an async method.
      Future<void> extractYoutubeLink() async {
        String link;
        // Platform messages may fail, so we use a try/catch PlatformException.
        try {
          link = await FlutterYoutubeDownloader.extractYoutubeLink(youTube_link, 18);
        } on PlatformException {
          link = 'Failed to Extract YouTube Video Link.';
        }

        // If the widget was removed from the tree while the asynchronous platform
        // message was in flight, we want to discard the reply rather than calling
        // setState to update our non-existent appearance.
        if (!mounted) return;

        setState(() {
          _extractedLink = link;
        });
      }

      Future<void> downloadVideo() async {
        final result = await FlutterYoutubeDownloader.downloadVideo(
            youTube_link, "Video Title goes Here", 18);
        print(result);
      }

      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: Scaffold(
            appBar: AppBar(
              title: const Text('Flutter Youtube Link Downloader example app'),
            ),
            body: Center(
              child: Text('Extracted Link : $_extractedLink\n'),
            ),
            floatingActionButton: FloatingActionButton(
              onPressed: downloadVideo,
              child: const Icon(Icons.download_rounded),
            ),
          ),
        );
      }
    }

Getting Started

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。