搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目

暂无相关数据。