physia / kflutter Goto Github PK
View Code? Open in Web Editor NEWKimia flutter&dart packages
License: MIT License
Kimia flutter&dart packages
License: MIT License
Hello,
I'm relatively new to Flutter so not very familiar with extending classes and all. I tried your package to help me with a stack Z-index issue but couldn't make it work. I want to be able to move the box over the other one, so trying to change the index (to 100) when moving the box (you can see the index I'm trying to set while moving the box).
Any idea how can I solve this?
`import 'package:flutter/material.dart';
import 'package:indexed/indexed.dart';
class NewBoard extends StatefulWidget {
const NewBoard({Key? key}) : super(key: key);
@OverRide
_NewBoardState createState() => _NewBoardState();
}
class _NewBoardState extends State {
List index = [0, 1];
@OverRide
Widget build(BuildContext context) {
return SizedBox(
width: 300,
height: 300,
child: Indexer(
children: [
MoveableStackItem(
positionIndex: index[0], color: Colors.blue, index: 1),
MoveableStackItem(
positionIndex: index[1], color: Colors.orange, index: 0),
Positioned(
top: 160,
child: ElevatedButton(
onPressed: () {
setState(() {
index =
index[0] == 0 ? List.from([1, 0]) : List.from([0, 1]);
});
},
child: Text('swap')),
)
],
),
);
}
}
class MoveableStackItem extends StatefulWidget implements IndexedInterface {
int index;
final int positionIndex;
final Color color;
MoveableStackItem({
Key? key,
required this.positionIndex,
required this.color,
required this.index,
}) : super(key: key);
@OverRide
_MoveableStackItemState createState() => _MoveableStackItemState();
}
class _MoveableStackItemState extends State {
double xPosition = 0;
double yPosition = 0;
Color color = Colors.black;
@OverRide
void initState() {
xPosition = widget.positionIndex * 40 + 10;
yPosition = 10;
color = widget.color;
super.initState();
}
@OverRide
void didUpdateWidget(MoveableStackItem oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.positionIndex != oldWidget.positionIndex) {
xPosition = widget.positionIndex * 40 + 10;
yPosition = 10;
}
}
@OverRide
Widget build(BuildContext context) {
var index = widget.index;
print(index);
print(widget.positionIndex);
return Indexed(
index: index,
key: UniqueKey(),
child: AnimatedPositioned(
duration: const Duration(milliseconds: 250),
curve: Curves.easeOutCubic,
top: yPosition,
left: xPosition,
child: Listener(
onPointerUp: (e) {
setState(() {
xPosition = widget.positionIndex * 40.0 + 10;
yPosition = 10.0;
widget.index = 0;
});
},
child: GestureDetector(
onTap: () {
setState(() {
widget.index = 100;
});
},
onPanUpdate: (tapInfo) {
setState(() {
xPosition += tapInfo.delta.dx;
yPosition += tapInfo.delta.dy;
widget.index = 100;
});
},
child: Container(
width: 30,
height: 30,
color: color,
child: Text(widget.index.toString()),
),
),
),
),
);
}
}
`
I tried AnimatedPositioned but it doesn't work. Is it possible to change widgets animatedly?
In kplayer_with_audioplayers program, need to update version of audioplayers to v3.0.1, to solve Error: "@staticInterop" classes should not contain any generative constructors
Hello kplayer
Team,
First of all, thank you for your work on kplayer
; it's a great asset to the Flutter community.
I'm currently integrating kplayer
into my Flutter project to handle audio playback. Everything is functioning as expected, however, I've encountered an issue with excessive logging of player events during playback. While playing audio, the console is flooded with logs for every minor event (PlayerEvent.status
, PlayerEvent.play
, PlayerEvent.init
, PlayerEvent.position
, etc.), which makes it challenging to read other important logs for debugging purposes.
Here is an example of the logs I'm seeing:
flutter: PlayerEvent.status
flutter: PlayerEvent.play
flutter: PlayerEvent.init
flutter: PlayerEvent.position
... (many more lines of similar logs)
This occurs whenever I play an audio file using kplayer
. While I understand the importance of these events for internal state management and potentially for debugging, it would be immensely helpful to have a way to control the verbosity of these logs, either by:
I believe such a feature would be beneficial for many developers who use kplayer
in more complex applications where console output is already quite dense.
Thank you for considering this request. I look forward to any suggestions or updates you might have.
kplayer: ^0.4.2
[✓] Flutter (Channel stable, 3.19.4, on macOS 14.3.1 23D60 darwin-arm64, locale zh-Hans-CN)
• Flutter version 3.19.4 on channel stable at /Users/calcitem/development/flutter
• Upstream repository https://gitee.com/mirrors/Flutter.git
• FLUTTER_GIT_URL = https://gitee.com/mirrors/Flutter.git
• Framework revision 68bfaea224 (11 days ago), 2024-03-20 15:36:31 -0700
• Engine revision a5c24f538d
• Dart version 3.3.2
• DevTools version 2.31.1
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/calcitem/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15E204a
• CocoaPods version 1.14.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
[✓] VS Code (version 1.87.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.84.0
[✓] VS Code (version 1.81.1)
• VS Code at /Users/calcitem/Downloads/Visual Studio Code.app/Contents
• Flutter extension version 3.84.0
[✓] Connected device (4 available)
• 2206122SC (mobile) • 40a6e11a • android-arm64 • Android 13 (API 33)
• iPhone Xs (mobile) • 00008020-000A54E8363B002E • ios • iOS 17.4.1 21E236
• macOS (desktop) • macos • darwin-arm64 • macOS 14.3.1 23D60 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 123.0.6312.87
! Error: Browsing on the local area network for iPad Pro (2). Ensure the device is unlocked and attached with a
cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources
• All expected network resources are available.
• No issues found!
Originally posted by jeejeestudio May 29, 2022
Hi Mohamad,
I've updated to 0.2.4.
First I thought palyers was a typo but it seems not:
I'm using this for each player:
Container( //by using theme dark in Main, no color background is needed
width: 400.0,
height: 50,
child: PlayerBar(player: player1, options: [])),
How do I use PlayerController.palyers.forEach((_player)=>_player.pause());
or player.others.forEach((player) => player.pause());
in/with the above container?
I tried both before container and in child just before the playerbar, of course i've changed the ; for , else the rest is not working anymore. For some of course I needed to use the correct player name like player1
I'm getting this error:
This expression has a type of 'void' so its value can't be used.
You see i'm a novice, but learning. Also looking for possible solutions concerning error messages on Stack Overflow.
Thanks!
edit I changed it in an issue hoping you can help me, as I had no responses in the discussion section.
Regards,
Jerry
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: LateInitializationError: Field 'dynamicLibrary' has not been initialized.
#0 dynamicLibrary (package:dart_vlc_ffi/src/internal/dynamiclibrary.dart)
#1 PlayerFFI.create (package:dart_vlc_ffi/src/internal/ffi.dart:20:42)
#2 PlayerFFI.create (package:dart_vlc_ffi/src/internal/ffi.dart)
#3 new Player (package:dart_vlc_ffi/src/player.dart:108:15)
#4 new Player (package:dart_vlc/dart_vlc.dart:56:9)
#5 new Player (package:kplayer_with_dart_vlc/kplayer_with_dart_vlc.dart:18:27)
#6 Player.create (package:kplayer/kplayer.dart:50:23)
#7 Player.asset (package:kplayer/kplayer.dart:73:19)
Hi,
i've got a few questions, don't know where to ask them else than here as I can get it from the information available. (latest version)
-How can I change the buttons to white?
Now I have it in a container so I can change the back groundcolor else I don't see the buttons, but actually I want white user controls on black background. I'm not using a white or black modus, it's just black.
Container(color: Colors.blue[100],
child: PlayerBar(player: player1, options: []))
-I have it playing a mp3 from network, but I don't hear sound. (on Android, not tested with other platforms yet)
-What options are available (see the piece of code above) ?
-How do I prevent automatic playing, it must load the mp3 but not auto-play.
-If a second player starts, other players must stop how do I do that.
Thanks very much for your help.
Jerry
i have an problem looping the audio and it runs only one time and it gives this log:
(Reload already in progress, ignoring request
Restarted application in 5,946ms.
flutter: Kplayer: just_audio
flutter: PlayerEvent.init
flutter: PlayerEvent.loop
flutter: PlayerEvent.play
flutter: PlayerEvent.status
AudioPlayers: Could not query current duration.
flutter: PlayerEvent.duration
flutter: PlayerEvent.position
flutter: PlayerEvent.position
flutter: PlayerEvent.duration
flutter: PlayerEvent.position
AudioPlayers: Could not set playback to position 0 and rate 1.000000.)
and my sound dont loop
AudioSource.uri() of just_audio has headers param, need to wrap it too
Loop parameter not working in Player.create,
need to set loop = true after init()
not support macos
On new version 0.1.18, I can't build exemple on windows anymore:
Launching lib\main.dart on Windows in debug mode...
Nuget.exe not found, trying to download or use cached version.
C:\Users\poka\dev\kflutter\kplayer\kplayer\example\build\windows\packages\Microsoft.Windows.ImplementationLibrary\include\wil/cppwinrt.h(82,75): error C2338: Please include wil/cppwinrt.h before including any C++/WinRT headers [C:\Users\poka\dev\kflutter\kplayer\kplayer\example\build\windows\plugins\audioplayers_windows\audioplayers_windows_plugin.vcxproj]
C:\Users\poka\dev\kflutter\kplayer\kplayer\example\build\windows\packages\Microsoft.Windows.ImplementationLibrary\include\wil/cppwinrt.h(101,75): error C2338: C++/WinRT external catch clause already defined outside of WIL [C:\Users\poka\dev\kflutter\kplayer\kplayer\example\build\windows\plugins\audioplayers_windows\audioplayers_windows_plugin.vcxproj]
C:\Users\poka\dev\kflutter\kplayer\kplayer\example\build\windows\packages\Microsoft.Windows.ImplementationLibrary\include\wil/cppwinrt.h(82,75): error C2338: Please include wil/cppwinrt.h before including any C++/WinRT headers [C:\Users\poka\dev\kflutter\kplayer\kplayer\example\build\windows\plugins\audioplayers_windows\audioplayers_windows_plugin.vcxproj]
C:\Users\poka\dev\kflutter\kplayer\kplayer\example\build\windows\packages\Microsoft.Windows.ImplementationLibrary\include\wil/cppwinrt.h(101,75): error C2338: C++/WinRT external catch clause already defined outside of WIL [C:\Users\poka\dev\kflutter\kplayer\kplayer\example\build\windows\plugins\audioplayers_windows\audioplayers_windows_plugin.vcxproj]
2
C:\Users\poka\dev\kflutter\kplayer\kplayer\example\windows\flutter\ephemeral\.plugin_symlinks\dart_vlc\dartvlc\internal/events.h(68,11): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [C:\Users\poka\dev\kflutter\kplayer\kplayer\example\build\windows\dart_vlc_core\dart_vlc_core.vcxproj]
I worked with version 0.1.11, so probably due to your change from just_audio to audioplayers.
I fond there is no volume control plugins for windows in pub dev but you can create that one or you will send those source code to me at [email protected]
When i want to run local mp3 file it doesnt run/work. However player.network is working successfully. I am working on windows. There is no setup on windows for dart_vlc.
var player = Player.create(
media: PlayerMedia.file(mp3FilePath), autoPlay: false, once: true)
..init();
I create a stateful widget same as yours example. everything is working if i change the player part instead :
var player = Player.create(
media: PlayerMedia.network("https://archive.org/download/s0v5kiwcwp1zaps7pdwjtp5o8e6clmevdnewngnd/JSJ_385_Panel.mp3"), autoPlay: false, once: true)
..init();
my stateful widget:
class AudioPlayer extends StatefulWidget {
String path;
Color bgColor, textColor;
double width, height;
AudioPlayer(
{Key? key,
required this.path,
required this.bgColor,
required this.textColor,
required this.width,
required this.height})
: super(key: key);
@override
State<AudioPlayer> createState() =>
_AudioPlayerState(path, bgColor, textColor);
}
class _AudioPlayerState extends State<AudioPlayer> {
String path;
Color bgColor, textColor;
_AudioPlayerState(this.path, this.bgColor, this.textColor) {
player = Player.create(
media: PlayerMedia.file(path), autoPlay: false, once: true)
..init();
}
late PlayerController player;
bool _changingPosition = false;
bool loading = false;
Duration _position = Duration.zero;
double get position {
if (player.duration.inSeconds == 0) {
return 0;
}
if (_changingPosition) {
return _position.inSeconds * 100 / player.duration.inSeconds;
} else {
return player.position.inSeconds * 100 / player.duration.inSeconds;
}
}
@override
void dispose() {
player.stop();
player.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Container(
width: widget.width,
height: widget.height,
decoration: BoxDecoration(
color: bgColor, borderRadius: BorderRadius.circular(20)),
padding: EdgeInsets.symmetric(horizontal: widget.width * 0.05),
child: Row(children: [
SizedBox(
width: widget.height * 0.8,
height: widget.height * 0.8,
child: StreamBuilder(
stream: player.positionStream,
builder: (context, snapshot) {
return CircularProgressIndicator(
strokeWidth: 1,
color: Colors.teal,
value: loading
? null
: player.position.inSeconds /
max(player.duration.inSeconds, 0.01),
);
},
),
),
IconButton(
onPressed: () {
setState(() {
player.toggle();
});
},
icon: StreamBuilder(
stream: player.positionStream,
builder: (context, snapshot) {
return player.playing
? Icon(
Icons.pause,
color: textColor,
size: appFonts.icon_S(),
)
: Icon(
Icons.play_arrow,
color: textColor,
size: appFonts.icon_S(),
);
},
)),
Expanded(
child: StreamBuilder(
stream: player.positionStream,
builder: (context, AsyncSnapshot<Duration> snapshot) {
loading = false;
return CupertinoSlider(
value: position,
min: 0,
max: 100,
onChangeStart: (double value) {
_changingPosition = true;
},
onChangeEnd: (double value) {
_changingPosition = false;
},
onChanged: (double value) {
setState(() {
loading = true;
_position = Duration(
seconds: ((value / 100) * player.duration.inSeconds)
.toInt());
player.position = _position;
});
},
);
}),
),
IconButton(
onPressed: () {
setState(() {
if (player.volume > 0) {
player.volume = 0.0;
} else {
player.volume = 1.0;
}
});
},
icon: StreamBuilder(
stream: player.positionStream,
builder: (context, snapshot) {
return player.volume == 0
? Icon(
Icons.volume_mute,
color: textColor,
size: appFonts.icon_S(),
)
: Icon(
Icons.volume_up,
color: textColor,
size: appFonts.icon_S(),
);
},
))
]),
);
}
}
Hello,
I've encountered an issue with kplayer
version 0.4.2 on Android that doesn't seem to affect iOS/macOS environments. When attempting to play audio, the application throws a PlatformException
indicating that the player has not been created or has already been disposed of. Below are the details of the exception and the stack trace:
Exception Details:
exception = {PlatformException} PlatformException(Unexpected AndroidAudioError, Player has not yet been created or has already been disposed., java.lang.IllegalStateException: Player has not yet been created or has already been disposed.
errorCode = "Unexpected AndroidAudioError"
errorMessage = "Player has not yet been created or has already been disposed."
errorDetails = "java.lang.IllegalStateException: Player has not yet been created or has already been disposed."
Stack Trace:
StandardMethodCodec.decodeEnvelope (message_codecs.dart:651)
MethodChannel._invokeMethod (platform_channel.dart:334)
<AudioPlayer and Player related calls>
Relevant Console Output:
D/alcitem.sanmill(15598): MiuiProcessManagerServiceStub setSchedFifo
<...>
I/flutter (15598): PlayerEvent.init
I/flutter (15598): PlayerEvent.dispose
The issue arises when trying to play a sound after disposing of the current player instance and immediately creating a new one to play a different sound. This pattern works without issues on iOS/macOS but fails on Android with the mentioned error. I suspect there might be a race condition or a platform-specific behavior not accounted for in the Android implementation of kplayer
.
The relevant part of the code that leads to this exception is as follows:
// Simplified for clarity
try {
_currentTonePlayer?.dispose();
_currentTonePlayer = kplayer.Player.asset(fileName);
} catch (e) {
print("Error playing sound: $e");
}
I've ensured that the asset paths are correct and that the player is not being used after disposal outside of this flow. This issue has been reproducible consistently in the described scenario.
Any guidance on how to resolve this issue or if there's a workaround would be greatly appreciated. Thank you for your support and for the great work on kplayer
.
kplayer: 0.4.2
[✓] Flutter (Channel stable, 3.19.4, on macOS 14.3.1 23D60 darwin-arm64, locale zh-Hans-CN)
• Flutter version 3.19.4 on channel stable at /Users/calcitem/development/flutter
• Upstream repository https://gitee.com/mirrors/Flutter.git
• FLUTTER_GIT_URL = https://gitee.com/mirrors/Flutter.git
• Framework revision 68bfaea224 (11 days ago), 2024-03-20 15:36:31 -0700
• Engine revision a5c24f538d
• Dart version 3.3.2
• DevTools version 2.31.1
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/calcitem/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15E204a
• CocoaPods version 1.14.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
[✓] VS Code (version 1.87.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.84.0
[✓] VS Code (version 1.81.1)
• VS Code at /Users/calcitem/Downloads/Visual Studio Code.app/Contents
• Flutter extension version 3.84.0
[✓] Connected device (4 available)
• 2206122SC (mobile) • 40a6e11a • android-arm64 • Android 13 (API 33)
• iPhone Xs (mobile) • 00008020-000A54E8363B002E • ios • iOS 17.4.1 21E236
• macOS (desktop) • macos • darwin-arm64 • macOS 14.3.1 23D60 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 123.0.6312.87
! Error: Browsing on the local area network for iPad Pro (2). Ensure the device is unlocked and attached with a
cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources
• All expected network resources are available.
• No issues found!
I notice that reading from network works fine on Linux, but not on Windows, with the same code.
It is as if the request did not execute at all (nothing appears in the devtools), no error appears in the logs so it is very difficult to diagnose.
I would like to give more information but unfortunately I don't have it.
Other query types work fine in the app on Windows.
Has anyone else had success getting network play to work on a Windows build?
Message received in the terminal window when running the installation:
Because every version of flutter_map_cached_tile_provider depends on flutter_map ^6.1.0 and myApp depends
on flutter_map ^7.0.2, flutter_map_cached_tile_provider is forbidden.
Strange bug, but in network playing, with audioplayer version, when I set the position after 03:30 of a track, even this track is 5 minutes or more, it will send a end status and stop.
loop does not trigger replay function
When an audio asset is passed to Player, like -
player = Player.create(media: PlayerMedia.asset("assets/audio/ring.mp3"), loop: true)..init();
The audio loops for all platforms(Android, macOS) except windows.
Any plans to add a loop in windows?
Any workarounds to make the loop work in windows?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.