From a37672ff5580df8be9dc84e0dc84e7720f07d41b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20Gangs=C3=B8?= Open pigeons/playback_platform
Anything we add here will be callable from flutter and has to be implemented on the native side.
Let's add a setVolume() function somewhere, with a double
to represent the volume from 0.0 to 1.0.
You almost always need to include a playerId
, in order to know which player to work with (you'll see later).
We attribute the method with a @ObjCSelector with this syntax: functionName:secondParam:
. This isn't strictly necessary but it helps keep the iOS code a bit cleaner.
We attribute the method with a @ObjCSelector with this syntax: functionName:secondParam:
. This isn't strictly necessary but it helps keep the iOS code a bit cleaner.
+The @async makes the generated dart code return a Future, allowing us to await it if necessary.
So something like this:
@HostApi()
abstract class PlaybackPlatformPigeon {
// ... other methods
- @ObjCSelector("setVolume:volume:")
- void setVolume(String playerId, double volume);
-
- // ... other methods
-}
+ @async
+ @ObjCSelector("setVolume:volume:")
+ void setVolume(String playerId, double volume);
+
+ // ... other methods
+}
Tip: You can use advanced argument types (see MediaItem, etc), pigeon will generate iOS/Android code for those too. But everything needs to be defined inside this one .dart file, as 'import' is not supported.
After any edits to playback_platform_pigeon.dart we need to run pigeon to generate everything:
diff --git a/index.html b/index.html index ddbaff19..c5ea4607 100644 --- a/index.html +++ b/index.html @@ -201,5 +201,5 @@