Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/web-cast-support
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
hawk23 committed Dec 2, 2024
2 parents e7b1e6a + b1a3326 commit c2a17b6
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 7 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/),
and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]
- Google Cast support for Web platform.
- Google Cast support for Web platform
- Support for `Player.isPaused` and `Player.isMuted`

## [0.13.0] - 2024-11-26
- Introduce platform support for web.
- Introduce platform support for web
- Supported API calls: `loadSource(source)`, `play`, `pause`, `mute`, `unmute`, `seek(time)`, `timeShift(timeShift)`, `getCurrentTime`, `getTimeShift`, `getDuration`, `getMaxTimeShift`, `isLive`, `isPlaying`, `isAirplayActive`, `isAirplayAvailable`, `castVideo`, `castStop`, `isCastAvailable`, `isCasting`, `showAirPlayTargetPicker`, `destroy`
- Supported events: `play`,`playing`,`paused`,`timeChanged`,`seek`,`seeked`,`timeShift`,`timeShifted`,`playbackFinished`,`error`,`muted`,`unmuted`,`warning`,`ready`,`sourceLoaded`,`sourceUnloaded`
- Update Bitmovin's native Android Player SDK version to `3.94.0`
Expand All @@ -20,7 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- Update Bitmovin's native iOS Player SDK version to `3.77.0`

### Removed
- Custom spec source `https://github.com/bitmovin/cocoapod-specs.git` from `example/ios/Podfile` as `BitmovinPlayer` is now published to the public CocoaPods registry.
- Custom spec source `https://github.com/bitmovin/cocoapod-specs.git` from `example/ios/Podfile` as `BitmovinPlayer` is now published to the public CocoaPods registry

## [0.11.0] - 2024-09-11
### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class FlutterPlayer(
Methods.MAX_TIME_SHIFT -> maxTimeShift
Methods.IS_LIVE -> isLive
Methods.IS_PLAYING -> isPlaying
Methods.IS_PAUSED -> isPaused
Methods.IS_MUTED -> isMuted
Methods.SEND_CUSTOM_DATA_EVENT ->
this.analytics?.sendCustomDataEvent(arg.asCustomData.toNative())
?: Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class Methods {
const val MAX_TIME_SHIFT = "maxTimeShift"
const val IS_LIVE = "isLive"
const val IS_PLAYING = "isPlaying"
const val IS_PAUSED = "isPaused"
const val IS_MUTED = "isMuted"
const val SEND_CUSTOM_DATA_EVENT = "sendCustomDataEvent"
const val AVAILABLE_SUBTITLES = "availableSubtitles"
const val SET_SUBTITLE = "setSubtitle"
Expand Down
17 changes: 13 additions & 4 deletions example/lib/player_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class PlayerInfo extends StatefulWidget {
}

class PlayerInfoState extends State<PlayerInfo> {
final Map<String, dynamic> _data = {};
final Map<String, String> _data = {};

Future<void> updatePlayerInfo(Player player, Event event) async {
if (event is ReadyEvent) {
Expand Down Expand Up @@ -41,6 +41,10 @@ class PlayerInfoState extends State<PlayerInfo> {
}
if (event is PlayingEvent || event is PausedEvent) {
_updatePlayerInfoForField('isPlaying', player.isPlaying);
_updatePlayerInfoForField('isPaused', player.isPaused);
}
if (event is MutedEvent || event is UnmutedEvent) {
_updatePlayerInfoForField('isMuted', player.isMuted);
}
if (event is TimeChangedEvent) {
_updatePlayerInfoForField('currentTime', player.currentTime);
Expand All @@ -63,8 +67,13 @@ class PlayerInfoState extends State<PlayerInfo> {

void _updatePlayerInfoForField(String field, Future<dynamic> value) {
value.then((dynamic value) {
var valueString = value.toString();
if (value is double) {
valueString = value.toStringAsFixed(2);
}

setState(() {
_data[field] = value.toString();
_data[field] = valueString;
});
});
}
Expand All @@ -75,7 +84,7 @@ class PlayerInfoState extends State<PlayerInfo> {
itemCount: _data.length,
itemBuilder: (context, index) {
final key = _data.keys.elementAt(index);
final value = _data[key];
final value = _data[key]!;

return Padding(
padding: const EdgeInsets.symmetric(vertical: 1, horizontal: 1),
Expand All @@ -87,7 +96,7 @@ class PlayerInfoState extends State<PlayerInfo> {
),
Expanded(
flex: 3,
child: Text(value.toString()),
child: Text(value),
),
],
),
Expand Down
4 changes: 4 additions & 0 deletions ios/Classes/FlutterPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ private extension FlutterPlayer {
return player.isLive
case (Methods.isPlaying, .empty):
return player.isPlaying
case (Methods.isPaused, .empty):
return player.isPaused
case (Methods.isMuted, .empty):
return player.isMuted
case (Methods.destroy, .empty):
destroyPlayer()
case (Methods.sendCustomDataEvent, .json(let customDataJson)):
Expand Down
2 changes: 2 additions & 0 deletions ios/Classes/Methods.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ internal enum Methods {
static let maxTimeShift = "maxTimeShift"
static let isLive = "isLive"
static let isPlaying = "isPlaying"
static let isPaused = "isPaused"
static let isMuted = "isMuted"
static let sendCustomDataEvent = "sendCustomDataEvent"
static let availableSubtitles = "availableSubtitles"
static let getSubtitle = "getSubtitle"
Expand Down
7 changes: 7 additions & 0 deletions lib/src/api/player/player_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ abstract class PlayerApi {
/// not paused.
Future<bool> get isPlaying;

/// Whether the player is currently paused, i.e. has started playback but is
/// currently paused.
Future<bool> get isPaused;

/// Whether the player is muted.
Future<bool> get isMuted;

/// A list of all available [SubtitleTrack]s of the active [Source],
/// including "off" subtitle track.
Future<List<SubtitleTrack>> get availableSubtitles;
Expand Down
2 changes: 2 additions & 0 deletions lib/src/methods.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Methods {
static const String maxTimeShift = 'maxTimeShift';
static const String isLive = 'isLive';
static const String isPlaying = 'isPlaying';
static const String isPaused = 'isPaused';
static const String isMuted = 'isMuted';
static const String sendCustomDataEvent = 'sendCustomDataEvent';
static const String availableSubtitles = 'availableSubtitles';
static const String setSubtitle = 'setSubtitle';
Expand Down
6 changes: 6 additions & 0 deletions lib/src/platform/player_platform_method_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ class PlayerPlatformMethodChannel extends PlayerPlatformInterface {
@override
Future<bool> get isPlaying async => _invokeMethod<bool>(Methods.isPlaying);

@override
Future<bool> get isPaused async => _invokeMethod<bool>(Methods.isPaused);

@override
Future<bool> get isMuted async => _invokeMethod<bool>(Methods.isMuted);

@override
Future<void> loadSource(Source source) async {
await super.loadSource(source);
Expand Down
2 changes: 2 additions & 0 deletions lib/src/platform/web/bitmovin_player_web_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class BitmovinPlayerJs {
external void castVideo();
external void castStop();
external bool isPlaying();
external bool isPaused();
external bool isMuted();
external bool isLive();
external bool isCasting();
external bool isCastAvailable();
Expand Down
6 changes: 6 additions & 0 deletions lib/src/platform/web/player_platform_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ class PlayerPlatformWeb extends PlayerPlatformInterface {
@override
Future<bool> get isPlaying async => _player.isPlaying();

@override
Future<bool> get isPaused async => _player.isPaused();

@override
Future<bool> get isMuted async => _player.isMuted();

@override
Future<void> loadSource(Source source) async {
await super.loadSource(source);
Expand Down
6 changes: 6 additions & 0 deletions lib/src/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ class Player with PlayerEventHandler implements PlayerApi {
@override
Future<bool> get isPlaying async => _playerPlatformInterface.isPlaying;

@override
Future<bool> get isPaused async => _playerPlatformInterface.isPaused;

@override
Future<bool> get isMuted async => _playerPlatformInterface.isMuted;

@override
Future<List<SubtitleTrack>> get availableSubtitles async =>
_playerPlatformInterface.availableSubtitles;
Expand Down

0 comments on commit c2a17b6

Please sign in to comment.