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

套件詳情v0.0.2

flutter_torrent_streamer

一個 Flutter 插件,可直接從 torrent/magnet 鏈接串流影片。

近 30 天下載
36
喜歡數
29
Pub 分數
30

安裝套件

flutter pub add flutter_torrent_streamer

套件介紹

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

一個Flutter外掛,可直接從torrent和磁力連結串流影片。它利用點對點技術取得並播放內容,無需完整下載,非常適合輕量級媒體消費。此外掛可順暢整合至Flutter應用程式中,提供簡單的API來從有效的torrent或磁力URL啟動串流。設計上設定簡單,支援邊下載邊即時播放,適用於按需影片應用。

適用情境

  • 從種子連結串流影片
  • 透過磁力連結播放媒體
  • 建構輕量級影片播放器
  • 啟用離線就緒串流
  • 整合P2P影片播放

主要特色

  • 直接流式傳輸 torrent/magnet
  • 下載時即時播放
  • 最小整合工作量
  • 跨平台相容性
  • 同時支援 torrent 檔案和磁力連結

適合對象

  • 媒體應用開發者
  • P2P串流應用
  • 按需影片平台
  • 需要低儲存媒體存取權限的應用程式
  • 尋求簡單種子整合的開發者

使用建議

  • 需要穩定的互聯網連接
  • 取決於追蹤器的可用性
  • 某些地區可能面臨法律限制
  • 性能因網路狀況而異
  • 無內建的種子傳播功能

原始 README

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

Flutter Torrent Streamer

pub

A flutter plugin to stream videos directly from torrent/magnet links.

This plugin is still under development and pull requests to make it better are heavily appreciated

Few Important points to note before using this plugin

  • Has only android support for now. (Help to implement iOS support is highly appreciated)
  • Is still under development and APIs may go through breaking changes.
  • Supports streaming and seeking videos while still being downloaded but is still experimental and has been tested to work on MX Player but does not work with video_player plugin.

Installation

Add below line to your pubspec.yaml and run flutter packages get

flutter_torrent_streamer: ^0.0.2

Example

import 'package:flutter_torrent_streamer/flutter_torrent_streamer.dart';  
  
class TorrentStreamerView extends StatefulWidget {
  @override _TorrentStreamerViewState createState() => _TorrentStreamerViewState();
}  
  
class _TorrentStreamerViewState extends State<TorrentStreamerView> {
  bool isStreamReady = false;
  int progress = 0;
  
  @override  
  void initState() {
    super.initState();
    _addTorrentListeners();
  }
  
  void _addTorrentListeners() {
    TorrentStreamer.addEventListener('progress', (data) {
      setState(() => progress = data['progress']);
    });
    
    TorrentStreamer.addEventListener('ready', (_) {
      setState(() => isStreamReady = true);
    });
  }
    
  Future<void> _startDownload() async {
    await TorrentStreamer.start('torrent-link-here');
  }
  
  Future<void> _openVideo(BuildContext context) async {
    if (progress == 100) {
      await TorrentStreamer.launchVideo();
    } else {
      showDialog(
        builder: (BuildContext context) {
          return AlertDialog(
            title: new Text('Are You Sure?'),
            content: new Text('Playing video while it is still downloading is experimental and only works on limited set of apps.'),
            actions: <Widget>[
              FlatButton(
               child: new Text("Cancel"),
                onPressed: () {
                  Navigator.of(context).pop();
                }
              ),
              FlatButton(
                child: new Text("Yes, Proceed"),
                onPressed: () async {
                  await TorrentStreamer.launchVideo();
                  Navigator.of(context).pop();
                }
              )
            ]
          );
        },
        context: context
      );
    }
  }
 
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: <Widget>[
          RaisedButton(
            child: Text('Start Download'),
            onPress: _startDownload
          ),
          Container(height: 8),
          RaisedButton(
	        child: Text('Play Video'),
	        onPress: () => _openVideo(context)
	      )
	    ],
	    crossAxisAlignment: CrossAxisAlignment.center,
	    mainAxisAlignment: MainAxisAlignment.start,
	    mainAxisSize: MainAxisSize.max
	  ),
	  padding: EdgeInsets.all(16)
    );
  }
}  

See example app for more detailed usage.

Using in release builds

If you are using proguard in your app then add the below 2 lines to your proguard rules:

-keep class com.frostwire.jlibtorrent.swig.libtorrent_jni {*;}
-keep class com.frostwire.jlibtorrent.swig.** { *; }

TODO

  • Add support for video_player flutter plugin.
  • Make streaming and seeking more robust for while download still in progress.
  • Run torrent streamer server on local network instead of localhost.
  • Add support for iOS.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。