-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[video_player] Adds audio track metadata fetching and audio track selection feature #9925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 15 commits
c8b0071
4e4dc8c
25de26c
31f9030
8f711b5
e0f6d65
fc30013
8a68e76
894f516
644e08e
fdde6f8
4291609
8dfd8e3
a892a5e
1537778
c222584
f087fe1
2e4c9ac
652dd48
80bda36
1495a95
ad558a7
6c7fd2b
85a8f54
ac54143
1775e23
6dafd5f
9440d1b
a65ebaf
7798aaa
e912f6d
3ae0519
99cdbd6
e7895ef
4e9b50b
5c32bf3
5101efc
f0bdabd
e7b3da0
6b0de5f
12fd73f
680c5e6
c06a83d
466946a
9f391de
f85c2bf
5aca457
56191a0
27336d4
f202438
3341e2d
bba24d3
f89e93b
d69fb63
48f7159
1862a7d
8046d22
e2b9a1b
00b55ed
3c82ead
5916b33
5b1e5c7
1161332
2811ea2
77a28bb
08e20d3
c63b050
e3df547
8d25e52
9f00bf2
a7118ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,326 @@ | ||||||||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||||||||
| // Use of this source code is governed by a BSD-style license that can be | ||||||||
| // found in the LICENSE file. | ||||||||
|
|
||||||||
| import 'package:flutter/material.dart'; | ||||||||
| import 'package:video_player/video_player.dart'; | ||||||||
|
|
||||||||
| /// A demo page that showcases audio track functionality. | ||||||||
| class AudioTracksDemo extends StatefulWidget { | ||||||||
| /// Creates an AudioTracksDemo widget. | ||||||||
| const AudioTracksDemo({super.key}); | ||||||||
|
|
||||||||
| @override | ||||||||
| State<AudioTracksDemo> createState() => _AudioTracksDemoState(); | ||||||||
| } | ||||||||
|
|
||||||||
| class _AudioTracksDemoState extends State<AudioTracksDemo> { | ||||||||
| VideoPlayerController? _controller; | ||||||||
| List<VideoAudioTrack> _audioTracks = <VideoAudioTrack>[]; | ||||||||
| bool _isLoading = false; | ||||||||
| String? _error; | ||||||||
|
|
||||||||
| // Sample video URLs with multiple audio tracks | ||||||||
| final List<String> _sampleVideos = <String>[ | ||||||||
| 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4', | ||||||||
|
||||||||
| _controller = MiniController.network( | |
| 'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4', | |
| viewType: widget.viewType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you can upload one with a proper license to https://github.com/flutter/assets-for-api-docs/tree/main/assets/videos
nateshmbhat marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm this could be a major source of flakiness. Shouldn't selectAudioTrack completes the future only after the new tracks becomes ready?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, a major source of user errors if this isn't documented (still I would prefer that we hide the ugliness within our implementation so the user doesn't have to worry about that).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will move the delay inside the selectAudioTrack dart method itself. that should take care of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is also needed whenever you want to call setState I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will add it after async calls whereever it's needed
nateshmbhat marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
nateshmbhat marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read the material DropdownMenu documentation and it doesn't really tell me when the callback would give me a null value. Does it mean no selection was made?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: final error case _error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't understand this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (_error != null) { | |
| if (_error case final String error?) { |
so you don't need to use !.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can we use the theme based colors throughout this example? Including where we use Colors.white etc?
Uh oh!
There was an error while loading. Please reload this page.