Giter Club home page Giter Club logo

Comments (6)

narumi147 avatar narumi147 commented on June 11, 2024 1

Here is example code under my assumption:

  • call await ensurePlayer() before any method like play, open, stop, pause....
  • _Player is deprecated and use a factory to reuse instance. Another side, it improves the null-safety check.
import 'dart:async';

import 'package:flutter/services.dart';

late MethodChannel channel;

class Player {
  int id;
  static Map<int, Player> _players = {};

  Completer<void>? _completer;

  factory Player({required int id}) {
    if (_players.containsKey(id)) return _players[id]!;
    final Player _player = Player._(id);
    _players[id] = _player;
    return _player;
  }

  Player._(this.id) {
    ensurePlayer();
  }

  Future<void> ensurePlayer() async {
    if (_completer != null) return _completer!.future;
    _completer = Completer();
    await channel.invokeMethod(
      'create',
      {
        'id': id,
      },
    );
    _completer!.complete();
  }

  Future<void> play() async {
    await ensurePlayer();
    await channel.invokeMethod(
      'play',
      {
        'id': this.id,
      },
    );
  }
}

from dart_vlc.

alexmercerind avatar alexmercerind commented on June 11, 2024

Hi there @narumishi !

Umm I was using a synchronous constructor in the previous project, as you might recall. But that used to cause bit of problems, as people used to call any method directly after creating of object in the same method & then used to report me bugs, so I made it completely safe this time 😟.

I feel this project would be much stable for you compared to older one.

I'll look forward to get what you said.

Thanks.

from dart_vlc.

alexmercerind avatar alexmercerind commented on June 11, 2024

Thanks.
Seeing this code reminds me that I haven't even migrated to null safety yet.

from dart_vlc.

narumi147 avatar narumi147 commented on June 11, 2024

Just compiled the windows version... I have never thought libvlc will generate 120MB files in plugins folder which is still 60MB large after zipped.

Is there any options to decrease plugins folder size while most of them of useless if I just want to play mp3/wav audios?

from dart_vlc.

alexmercerind avatar alexmercerind commented on June 11, 2024

Just compiled the windows version... I have never thought libvlc will generate 120MB files in plugins folder which is still 60MB large after zipped.
This project does not compile libVLC itself, but fetches shared libraries & headers etc. directly from VideoLAN severs, if I could compile libVLC myself, then it could be possible to select the plugin that one wants.

Is there any options to decrease plugins folder size while most of them of useless if I just want to play mp3/wav audios

All I can say right now, is "trial and error", as far as I'm aware there are many many plugins for video decompression, even Qt window etc. that you might won't need. So, you can just try and delete the folders/DLLs that you find unnecessary. (I can guarantee not much of the DLLs depend on each other inside the plugins folder)

This is where miniaudio version was lightweight (a lot) than this.

from dart_vlc.

alexmercerind avatar alexmercerind commented on June 11, 2024

Okay finally.

from dart_vlc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.