Giter Site home page Giter Site logo

emostar / audioplayer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rxlabz/audioplayer

11.0 11.0 3.0 11.58 MB

A flutter plugin to play audio files ( ObjC/Java )

Home Page: https://pub.dartlang.org/packages/audioplayer

License: BSD 3-Clause "New" or "Revised" License

Java 21.15% Objective-C 28.71% Swift 1.56% Dart 46.02% Ruby 2.56%

audioplayer's People

Contributors

alanrussian avatar emostar avatar gdcolella avatar jonasbark avatar mehmetf avatar mindon avatar mit-mit avatar oakes avatar rxlabz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

audioplayer's Issues

Error on Compilation after adding audioplayer2 as a dependency

Launching lib/main.dart on iPhone 6 in debug mode...
Running pod install...
CocoaPods' output:

Preparing

Analyzing dependencies

Inspecting targets to integrate
  Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)

Fetching external sources
-> Fetching podspec for `Flutter` from `.symlinks/flutter/ios`
-> Fetching podspec for `audioplayer2` from `.symlinks/plugins/audioplayer2/ios`
[!] No podspec found for `audioplayer2` in `.symlinks/plugins/audioplayer2/ios`

/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/external_sources/path_source.rb:14:in `block in fetch'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:85:in `titled_section'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/external_sources/path_source.rb:11:in `fetch'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:697:in `fetch_external_source'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:673:in `block (2 levels) in fetch_external_sources'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:672:in `each'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:672:in `block in fetch_external_sources'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:64:in `section'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:671:in `fetch_external_sources'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer/analyzer.rb:85:in `analyze'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:243:in `analyze'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:154:in `block in resolve_dependencies'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/user_interface.rb:64:in `section'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:153:in `resolve_dependencies'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/installer.rb:116:in `install!'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/command/install.rb:41:in `run'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/lib/cocoapods/command.rb:52:in `run'
/usr/local/Cellar/cocoapods/1.5.3/libexec/gems/cocoapods-1.5.3/bin/pod:55:in `<top (required)>'
/usr/local/Cellar/cocoapods/1.5.3/libexec/bin/pod:22:in `load'
/usr/local/Cellar/cocoapods/1.5.3/libexec/bin/pod:22:in `<main>'

Error output from CocoaPods:

[!] `<PBXGroup UUID=`97C146E51CF9000F007C117D`>` attempted to initialize an object with an unknown UUID. `CF3B75C9A7D2FA2A4C99F110` for attribute: `children`. This can be the result of a merge and  the unknown UUID is being discarded.

[!] Automatically assigning platform `ios` with version `8.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

Error running pod install
Error launching application on iPhone 6.

Multi audioplayer instance in one widget

I want to put 2 widgets into one parent widget, both 2 widgets include audioplayer instance. Then I got something wrong, the indicator of playing status can't get right status.

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

class PhMp3 extends StatefulWidget {
  final src;
  final text;
  final color;
  final autoplay;
  PhMp3({this.src,this.text,this.color,this.autoplay});
  @override
  PhMp3State createState() => new PhMp3State();
}

class PhMp3State extends State<PhMp3>{
  bool playing = false;
  AudioPlayer audioPlayer;
  StreamSubscription _audioPlayerStateSubscription;

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

  @override
  void dispose(){
    stop();
    _audioPlayerStateSubscription.cancel();
    super.dispose();
  }

  Future play(url) async {
    try{
      await audioPlayer.play(url);
      if(mounted){
        setState(() => playing = true);
      }
    }catch(e){
      stop();
    }
  }

  Future stop() async {
    try{
      await audioPlayer.stop();
      if(mounted){
        setState(() => playing = false);
      }
    }catch(e){
      if(mounted){
        setState(() => playing = false);
      }
    }
  }

  void audioController(url){
    if(playing){
      stop();
    }else{
      play(url);
    }
  }

  void initAudio(){
    audioPlayer = new AudioPlayer();
    _audioPlayerStateSubscription = audioPlayer.onPlayerStateChanged.listen((s){
      if(s == AudioPlayerState.STOPPED){
        stop();
      }
    }, onError: (msg){
      stop();
    });
    if(widget.autoplay){
      play(widget.src);
    }
  }

  @override
  Widget build(BuildContext context) {
    if(widget.color==null && !widget.autoplay){  
      return new GestureDetector(   // widget1
        onTap:() {
          audioController(widget.src);
        },
        child: new Text(widget.text,
          style: new TextStyle(color: Colors.blue,fontSize: 16.0),
        ),
      );
    }
    return new GestureDetector(   // widget2
      child: new Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          new Icon(
            // When parent widget includes both widget1 and widget2, `playing` will not change state
            // waht's the problem?
            playing ? Icons.pause_circle_outline : Icons.play_circle_outline,
            color: widget.color,
            size: 19.0,
          ),
          new Text(' /'+widget.text+'/',style: new TextStyle(fontSize: 18.0,color: widget.color),),
        ],
      ),
      onTap: (){
        if(widget.src.isNotEmpty){
          audioController(widget.src);
        }
      },
    );
  }
}

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.