Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.4

* Android: add support for hls, dash and ss video formats.

## 0.6.3

* iOS: Allow audio playback in silent mode.
Expand Down
3 changes: 3 additions & 0 deletions packages/video_player/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@ android {

dependencies {
implementation 'com.google.android.exoplayer:exoplayer-core:2.8.0'
implementation 'com.google.android.exoplayer:exoplayer-hls:2.8.0'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.8.0'
implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.8.0'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@
import com.google.android.exoplayer2.Player.DefaultEventListener;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.audio.AudioAttributes;
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.dash.DashMediaSource;
import com.google.android.exoplayer2.source.dash.DefaultDashChunkSource;
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
import com.google.android.exoplayer2.source.smoothstreaming.DefaultSsChunkSource;
import com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.TrackSelector;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
import com.google.android.exoplayer2.util.Util;
import io.flutter.plugin.common.EventChannel;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
Expand Down Expand Up @@ -83,13 +90,33 @@ private static class VideoPlayer {
true);
}

MediaSource mediaSource =
new ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(uri);
MediaSource mediaSource = buildMediaSource(uri, dataSourceFactory);
exoPlayer.prepare(mediaSource);

setupVideoPlayer(eventChannel, textureEntry, result);
}

private MediaSource buildMediaSource(Uri uri, DataSource.Factory mediaDataSourceFactory) {
int type = Util.inferContentType(uri.getLastPathSegment());
switch (type) {
case C.TYPE_SS:
return new SsMediaSource(
uri, null, new DefaultSsChunkSource.Factory(mediaDataSourceFactory), null, null);
case C.TYPE_DASH:
return new DashMediaSource(
uri, null, new DefaultDashChunkSource.Factory(mediaDataSourceFactory), null, null);
case C.TYPE_HLS:
return new HlsMediaSource(uri, mediaDataSourceFactory, null, null);
case C.TYPE_OTHER:
return new ExtractorMediaSource(
uri, mediaDataSourceFactory, new DefaultExtractorsFactory(), null, null);
default:
{
throw new IllegalStateException("Unsupported type: " + type);
}
}
}

private void setupVideoPlayer(
EventChannel eventChannel,
TextureRegistry.SurfaceTextureEntry textureEntry,
Expand Down
25 changes: 23 additions & 2 deletions packages/video_player/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,15 @@ Widget buildCard(String title) {
children: <Widget>[
new FlatButton(
child: const Text('BUY TICKETS'),
onPressed: () {/* ... */},
onPressed: () {
/* ... */
},
),
new FlatButton(
child: const Text('SELL TICKETS'),
onPressed: () {/* ... */},
onPressed: () {
/* ... */
},
),
],
),
Expand Down Expand Up @@ -373,6 +377,23 @@ void main() {
),
body: new TabBarView(
children: <Widget>[
new Column(
children: <Widget>[
new NetworkPlayerLifeCycle(
'http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_20mb.mp4',
(BuildContext context, VideoPlayerController controller) =>
new AspectRatioVideo(controller),
),
new Container(
padding: const EdgeInsets.only(top: 20.0),
),
new NetworkPlayerLifeCycle(
'http://184.72.239.149/vod/smil:BigBuckBunny.smil/playlist.m3u8',
(BuildContext context, VideoPlayerController controller) =>
new AspectRatioVideo(controller),
),
],
),
new NetworkPlayerLifeCycle(
'http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_20mb.mp4',
(BuildContext context, VideoPlayerController controller) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: video_player
description: Flutter plugin for displaying inline video with other Flutter
widgets on Android and iOS.
author: Flutter Team <flutter-dev@googlegroups.com>
version: 0.6.3
version: 0.6.4
homepage: https://github.com/flutter/plugins/tree/master/packages/video_player

flutter:
Expand Down