Skip to content

Conversation

@vasu-nageshri
Copy link
Contributor

Description

This PR introduces comprehensive web platform support to the audio_waveforms Flutter plugin, enabling audio playback in web applications. The implementation leverages the Web Audio API and HTML5 audio elements to provide feature parity with native platforms.

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs: etc).
  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive web platform support for the audio_waveforms Flutter plugin, enabling audio playback functionality in web browsers using HTML5 Audio API. The implementation provides feature parity with native platforms for audio playback, while explicitly excluding recording functionality which is not supported on the web platform.

Changes:

  • Added web platform implementation for audio player with HTML5 audio elements
  • Implemented platform-specific method channel handlers for web
  • Added web configuration files and assets for the example app
  • Updated dependencies to support web platform (flutter_web_plugins, web package)

Reviewed changes

Copilot reviewed 12 out of 17 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
pubspec.yaml Added flutter_web_plugins and web dependencies, registered web plugin
lib/audio_waveforms_web.dart Entry point that delegates to web plugin implementation
lib/web/audio_waveforms_plugin_web.dart Main web plugin class handling method channel calls
lib/web/audio_player_web.dart Core audio player implementation using HTMLAudioElement
lib/web/waveform_extractor_web.dart Placeholder waveform extraction with dummy data
lib/web/base/constants_web.dart Web-specific constants
lib/web/base/utils_web.dart Web console logging utilities
example/lib/main.dart Added web platform checks and recording restrictions
example/pubspec.yaml Updated file_picker dependency version
example/web/* Standard Flutter web assets (manifest, index.html, icons, favicon)
CHANGELOG.md Added entry for web platform support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 17 changed files in this pull request and generated 13 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vasu-nageshri vasu-nageshri force-pushed the feat/add_web_support_player_feature branch from 8915752 to 14f26d7 Compare January 12, 2026 09:10
@vasu-nageshri vasu-nageshri force-pushed the feat/add_web_support_player_feature branch from 14f26d7 to 57e662e Compare January 12, 2026 09:13
}

/// Prepares the audio player with the given path
Future<bool> preparePlayer(Map<dynamic, dynamic> arguments) async {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cant we pass <String, dynamic>?

final String path = rawPath;
final int frequency = arguments[Constants.updateFrequency] ??
WebConstants.defaultUpdateFrequency;
final double? volume = arguments[Constants.volume];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check type here as well

final completer = Completer<bool>();
bool isCompleted = false;

audioElement.addEventListener(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to remove listeners?

Comment on lines +103 to +106
return await completer.future
.timeout(
const Duration(seconds: WebConstants.defaultLoadTimeout),
onTimeout: () => false,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we must not use these type of static timeouts


// Stop the player if it's currently playing
if (isPlaying) {
await stopPlayer();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method does same thing as below

Comment on lines +313 to +315
void _sendDurationUpdate(int currentTime) {
onDurationUpdate(currentTime);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can directly use the callback

Comment on lines +337 to +339
void _sendCompletionEvent() {
onCompletion();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^


/// Handles method calls from the platform interface
Future<dynamic> handleMethodCall(MethodCall call) async {
final args = call.arguments as Map<dynamic, dynamic>?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use <string, dynamic>

{
Constants.playerKey: playerKey,
Constants.finishType:
2, // 2 = stopped (default finish mode on web)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add todo


import 'package:web/web.dart';

extension WebConsoleLogger on String {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add top level documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants