Add video player (#2)
https://github.com/sony/flutter-embedded-linux/issues/124
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
// 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.
|
||||
|
||||
#ifndef PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_CREATE_MESSAGE_H_
|
||||
#define PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_CREATE_MESSAGE_H_
|
||||
|
||||
#include <flutter/binary_messenger.h>
|
||||
#include <flutter/encodable_value.h>
|
||||
|
||||
class CreateMessage {
|
||||
public:
|
||||
CreateMessage() = default;
|
||||
~CreateMessage() = default;
|
||||
|
||||
// Prevent copying.
|
||||
CreateMessage(CreateMessage const&) = default;
|
||||
CreateMessage& operator=(CreateMessage const&) = default;
|
||||
|
||||
void SetAsset(const std::string& asset) { asset_ = asset; }
|
||||
|
||||
std::string GetAsset() const { return asset_; }
|
||||
|
||||
void SetUri(const std::string& uri) { uri_ = uri; }
|
||||
|
||||
std::string GetUri() const { return uri_; }
|
||||
|
||||
void SetPackageName(const std::string& packageName) {
|
||||
package_name_ = packageName;
|
||||
}
|
||||
|
||||
std::string GetPackageName() const { return package_name_; }
|
||||
|
||||
void SetFormatHint(const std::string& formatHint) {
|
||||
format_hint_ = formatHint;
|
||||
}
|
||||
|
||||
std::string GetFormatHint() const { return format_hint_; }
|
||||
|
||||
flutter::EncodableValue ToMap() {
|
||||
// todo: Add httpHeaders.
|
||||
flutter::EncodableMap map = {
|
||||
{flutter::EncodableValue("asset"), flutter::EncodableValue(asset_)},
|
||||
{flutter::EncodableValue("uri"), flutter::EncodableValue(uri_)},
|
||||
{flutter::EncodableValue("packageName"),
|
||||
flutter::EncodableValue(package_name_)},
|
||||
{flutter::EncodableValue("formatHint"),
|
||||
flutter::EncodableValue(format_hint_)}};
|
||||
return flutter::EncodableValue(map);
|
||||
}
|
||||
|
||||
static CreateMessage FromMap(const flutter::EncodableValue& value) {
|
||||
CreateMessage message;
|
||||
if (std::holds_alternative<flutter::EncodableMap>(value)) {
|
||||
auto map = std::get<flutter::EncodableMap>(value);
|
||||
|
||||
flutter::EncodableValue& asset = map[flutter::EncodableValue("asset")];
|
||||
if (std::holds_alternative<std::string>(asset)) {
|
||||
message.SetAsset(std::get<std::string>(asset));
|
||||
}
|
||||
|
||||
flutter::EncodableValue& uri = map[flutter::EncodableValue("uri")];
|
||||
if (std::holds_alternative<std::string>(uri)) {
|
||||
message.SetUri(std::get<std::string>(uri));
|
||||
}
|
||||
|
||||
flutter::EncodableValue& packageName =
|
||||
map[flutter::EncodableValue("packageName")];
|
||||
if (std::holds_alternative<std::string>(packageName)) {
|
||||
message.SetPackageName(std::get<std::string>(uri));
|
||||
}
|
||||
|
||||
flutter::EncodableValue& formatHint =
|
||||
map[flutter::EncodableValue("formatHint")];
|
||||
if (std::holds_alternative<std::string>(formatHint)) {
|
||||
message.SetFormatHint(std::get<std::string>(formatHint));
|
||||
}
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string asset_;
|
||||
std::string uri_;
|
||||
std::string package_name_;
|
||||
std::string format_hint_;
|
||||
};
|
||||
|
||||
#endif // PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_CREATE_MESSAGE_H_
|
||||
@@ -0,0 +1,63 @@
|
||||
// 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.
|
||||
|
||||
#ifndef PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_LOOPING_MESSAGE_H_
|
||||
#define PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_LOOPING_MESSAGE_H_
|
||||
|
||||
#include <flutter/binary_messenger.h>
|
||||
#include <flutter/encodable_value.h>
|
||||
|
||||
class LoopingMessage {
|
||||
public:
|
||||
LoopingMessage() = default;
|
||||
~LoopingMessage() = default;
|
||||
|
||||
// Prevent copying.
|
||||
LoopingMessage(LoopingMessage const&) = default;
|
||||
LoopingMessage& operator=(LoopingMessage const&) = default;
|
||||
|
||||
void SetTextureId(int64_t texture_id) { texture_id_ = texture_id; }
|
||||
|
||||
int64_t GetTextureId() const { return texture_id_; }
|
||||
|
||||
void SetIsLooping(bool is_looping) { is_looping_ = is_looping; }
|
||||
|
||||
bool GetIsLooping() const { return is_looping_; }
|
||||
|
||||
flutter::EncodableValue ToMap() {
|
||||
flutter::EncodableMap map = {{flutter::EncodableValue("textureId"),
|
||||
flutter::EncodableValue(texture_id_)},
|
||||
{flutter::EncodableValue("isLooping"),
|
||||
flutter::EncodableValue(is_looping_)}};
|
||||
return flutter::EncodableValue(map);
|
||||
}
|
||||
|
||||
static LoopingMessage FromMap(const flutter::EncodableValue& value) {
|
||||
LoopingMessage message;
|
||||
if (std::holds_alternative<flutter::EncodableMap>(value)) {
|
||||
auto map = std::get<flutter::EncodableMap>(value);
|
||||
|
||||
flutter::EncodableValue& texture_id =
|
||||
map[flutter::EncodableValue("textureId")];
|
||||
if (std::holds_alternative<int32_t>(texture_id) ||
|
||||
std::holds_alternative<int64_t>(texture_id)) {
|
||||
message.SetTextureId(texture_id.LongValue());
|
||||
}
|
||||
|
||||
flutter::EncodableValue& is_looping =
|
||||
map[flutter::EncodableValue("isLooping")];
|
||||
if (std::holds_alternative<bool>(is_looping)) {
|
||||
message.SetIsLooping(std::get<bool>(is_looping));
|
||||
}
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
private:
|
||||
int64_t texture_id_ = 0;
|
||||
bool is_looping_ = false;
|
||||
};
|
||||
|
||||
#endif // PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_LOOPING_MESSAGE_H_
|
||||
@@ -0,0 +1,16 @@
|
||||
// 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.
|
||||
|
||||
#ifndef PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_MESSAGES_H_
|
||||
#define PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_MESSAGES_H_
|
||||
|
||||
#include "create_message.h"
|
||||
#include "looping_message.h"
|
||||
#include "mix_with_others_message.h"
|
||||
#include "playback_speed_message.h"
|
||||
#include "position_message.h"
|
||||
#include "texture_message.h"
|
||||
#include "volume_message.h"
|
||||
|
||||
#endif // PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_MESSAGES_H_
|
||||
@@ -0,0 +1,52 @@
|
||||
// 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.
|
||||
|
||||
#ifndef PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_MIX_WITH_OTHERS_MESSAGE_H_
|
||||
#define PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_MIX_WITH_OTHERS_MESSAGE_H_
|
||||
|
||||
#include <flutter/binary_messenger.h>
|
||||
#include <flutter/encodable_value.h>
|
||||
|
||||
class MixWithOthersMessage {
|
||||
public:
|
||||
MixWithOthersMessage() = default;
|
||||
~MixWithOthersMessage() = default;
|
||||
|
||||
// Prevent copying.
|
||||
MixWithOthersMessage(MixWithOthersMessage const&) = default;
|
||||
MixWithOthersMessage& operator=(MixWithOthersMessage const&) = default;
|
||||
|
||||
void SetMixWithOthers(bool mixWithOthers) {
|
||||
mix_with_others_ = mixWithOthers;
|
||||
}
|
||||
|
||||
bool GetMixWithOthers() const { return mix_with_others_; }
|
||||
|
||||
flutter::EncodableValue ToMap() {
|
||||
flutter::EncodableMap map = {{flutter::EncodableValue("mixWithOthers"),
|
||||
flutter::EncodableValue(mix_with_others_)}};
|
||||
|
||||
return flutter::EncodableValue(map);
|
||||
}
|
||||
|
||||
static MixWithOthersMessage FromMap(const flutter::EncodableValue& value) {
|
||||
MixWithOthersMessage message;
|
||||
if (std::holds_alternative<flutter::EncodableMap>(value)) {
|
||||
auto map = std::get<flutter::EncodableMap>(value);
|
||||
|
||||
flutter::EncodableValue& mixWithOthers =
|
||||
map[flutter::EncodableValue("mixWithOthers")];
|
||||
if (std::holds_alternative<bool>(mixWithOthers)) {
|
||||
message.SetMixWithOthers(std::get<bool>(mixWithOthers));
|
||||
}
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
private:
|
||||
bool mix_with_others_ = false;
|
||||
};
|
||||
|
||||
#endif // PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_MIX_WITH_OTHERS_MESSAGE_H_
|
||||
@@ -0,0 +1,62 @@
|
||||
// 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.
|
||||
|
||||
#ifndef PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_PLAYBACK_SPEED_MESSAGE_H_
|
||||
#define PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_PLAYBACK_SPEED_MESSAGE_H_
|
||||
|
||||
#include <flutter/binary_messenger.h>
|
||||
#include <flutter/encodable_value.h>
|
||||
|
||||
class PlaybackSpeedMessage {
|
||||
public:
|
||||
PlaybackSpeedMessage() = default;
|
||||
~PlaybackSpeedMessage() = default;
|
||||
|
||||
// Prevent copying.
|
||||
PlaybackSpeedMessage(PlaybackSpeedMessage const&) = default;
|
||||
PlaybackSpeedMessage& operator=(PlaybackSpeedMessage const&) = default;
|
||||
|
||||
void SetTextureId(int64_t texture_id) { texture_id_ = texture_id; }
|
||||
|
||||
int64_t GetTextureId() const { return texture_id_; }
|
||||
|
||||
void SetSpeed(double speed) { speed_ = speed; }
|
||||
|
||||
double GetSpeed() const { return speed_; }
|
||||
|
||||
flutter::EncodableValue ToMap() {
|
||||
flutter::EncodableMap map = {
|
||||
{flutter::EncodableValue("textureId"),
|
||||
flutter::EncodableValue(texture_id_)},
|
||||
{flutter::EncodableValue("speed"), flutter::EncodableValue(speed_)}};
|
||||
return flutter::EncodableValue(map);
|
||||
}
|
||||
|
||||
static PlaybackSpeedMessage FromMap(const flutter::EncodableValue& value) {
|
||||
PlaybackSpeedMessage message;
|
||||
if (std::holds_alternative<flutter::EncodableMap>(value)) {
|
||||
auto map = std::get<flutter::EncodableMap>(value);
|
||||
|
||||
flutter::EncodableValue& texture_id =
|
||||
map[flutter::EncodableValue("textureId")];
|
||||
if (std::holds_alternative<int32_t>(texture_id) ||
|
||||
std::holds_alternative<int64_t>(texture_id)) {
|
||||
message.SetTextureId(texture_id.LongValue());
|
||||
}
|
||||
|
||||
flutter::EncodableValue& speed = map[flutter::EncodableValue("speed")];
|
||||
if (std::holds_alternative<double>(speed)) {
|
||||
message.SetSpeed(std::get<double>(speed));
|
||||
}
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
private:
|
||||
int64_t texture_id_ = 0;
|
||||
double speed_ = 1.0;
|
||||
};
|
||||
|
||||
#endif // PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_PLAYBACK_SPEED_MESSAGE_H_
|
||||
@@ -0,0 +1,65 @@
|
||||
// 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.
|
||||
|
||||
#ifndef PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_POSITION_MESSAGE_H_
|
||||
#define PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_POSITION_MESSAGE_H_
|
||||
|
||||
#include <flutter/binary_messenger.h>
|
||||
#include <flutter/encodable_value.h>
|
||||
|
||||
class PositionMessage {
|
||||
public:
|
||||
PositionMessage() = default;
|
||||
~PositionMessage() = default;
|
||||
|
||||
// Prevent copying.
|
||||
PositionMessage(PositionMessage const&) = default;
|
||||
PositionMessage& operator=(PositionMessage const&) = default;
|
||||
|
||||
void SetTextureId(int64_t texture_id) { texture_id_ = texture_id; }
|
||||
|
||||
int64_t GetTextureId() const { return texture_id_; }
|
||||
|
||||
void SetPosition(int64_t position) { position_ = position; }
|
||||
|
||||
int64_t GetPosition() const { return position_; }
|
||||
|
||||
flutter::EncodableValue ToMap() {
|
||||
flutter::EncodableMap toMapResult = {{flutter::EncodableValue("textureId"),
|
||||
flutter::EncodableValue(texture_id_)},
|
||||
{flutter::EncodableValue("position"),
|
||||
flutter::EncodableValue(position_)}};
|
||||
|
||||
return flutter::EncodableValue(toMapResult);
|
||||
}
|
||||
|
||||
static PositionMessage FromMap(const flutter::EncodableValue& value) {
|
||||
PositionMessage message;
|
||||
if (std::holds_alternative<flutter::EncodableMap>(value)) {
|
||||
auto map = std::get<flutter::EncodableMap>(value);
|
||||
|
||||
flutter::EncodableValue& texture_id =
|
||||
map[flutter::EncodableValue("textureId")];
|
||||
if (std::holds_alternative<int32_t>(texture_id) ||
|
||||
std::holds_alternative<int64_t>(texture_id)) {
|
||||
message.SetTextureId(texture_id.LongValue());
|
||||
}
|
||||
|
||||
flutter::EncodableValue& position =
|
||||
map[flutter::EncodableValue("position")];
|
||||
if (std::holds_alternative<int32_t>(position) ||
|
||||
std::holds_alternative<int64_t>(position)) {
|
||||
message.SetPosition(position.LongValue());
|
||||
}
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
private:
|
||||
int64_t texture_id_ = 0;
|
||||
int64_t position_ = 0;
|
||||
};
|
||||
|
||||
#endif // PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_POSITION_MESSAGE_H_
|
||||
@@ -0,0 +1,49 @@
|
||||
// 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.
|
||||
|
||||
#ifndef PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_TEXTURE_MESSAGE_H_
|
||||
#define PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_TEXTURE_MESSAGE_H_
|
||||
|
||||
#include <flutter/binary_messenger.h>
|
||||
#include <flutter/encodable_value.h>
|
||||
|
||||
class TextureMessage {
|
||||
public:
|
||||
TextureMessage() = default;
|
||||
~TextureMessage() = default;
|
||||
|
||||
// Prevent copying.
|
||||
TextureMessage(TextureMessage const&) = default;
|
||||
TextureMessage& operator=(TextureMessage const&) = default;
|
||||
|
||||
void SetTextureId(int64_t texture_id) { texture_id_ = texture_id; }
|
||||
|
||||
int64_t GetTextureId() const { return texture_id_; }
|
||||
|
||||
flutter::EncodableValue ToMap() {
|
||||
flutter::EncodableMap map = {{flutter::EncodableValue("textureId"),
|
||||
flutter::EncodableValue(texture_id_)}};
|
||||
return flutter::EncodableValue(map);
|
||||
}
|
||||
|
||||
static TextureMessage FromMap(const flutter::EncodableValue& value) {
|
||||
TextureMessage message;
|
||||
if (std::holds_alternative<flutter::EncodableMap>(value)) {
|
||||
auto map = std::get<flutter::EncodableMap>(value);
|
||||
|
||||
flutter::EncodableValue& texture_id =
|
||||
map[flutter::EncodableValue("textureId")];
|
||||
if (std::holds_alternative<int32_t>(texture_id) ||
|
||||
std::holds_alternative<int64_t>(texture_id)) {
|
||||
message.SetTextureId(texture_id.LongValue());
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
private:
|
||||
int64_t texture_id_ = 0;
|
||||
};
|
||||
|
||||
#endif // PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_TEXTURE_MESSAGE_H_
|
||||
@@ -0,0 +1,62 @@
|
||||
// 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.
|
||||
|
||||
#ifndef PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_VOLUME_MESSAGE_H_
|
||||
#define PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_VOLUME_MESSAGE_H_
|
||||
|
||||
#include <flutter/binary_messenger.h>
|
||||
#include <flutter/encodable_value.h>
|
||||
|
||||
class VolumeMessage {
|
||||
public:
|
||||
VolumeMessage() = default;
|
||||
~VolumeMessage() = default;
|
||||
|
||||
// Prevent copying.
|
||||
VolumeMessage(VolumeMessage const&) = default;
|
||||
VolumeMessage& operator=(VolumeMessage const&) = default;
|
||||
|
||||
void SetTextureId(int64_t texture_id) { texture_id_ = texture_id; }
|
||||
|
||||
int64_t GetTextureId() const { return texture_id_; }
|
||||
|
||||
void SetVolume(double volume) { volume_ = volume; }
|
||||
|
||||
double GetVolume() const { return volume_; }
|
||||
|
||||
flutter::EncodableValue ToMap() {
|
||||
flutter::EncodableMap map = {
|
||||
{flutter::EncodableValue("textureId"),
|
||||
flutter::EncodableValue(texture_id_)},
|
||||
{flutter::EncodableValue("volume"), flutter::EncodableValue(volume_)}};
|
||||
return flutter::EncodableValue(map);
|
||||
}
|
||||
|
||||
static VolumeMessage FromMap(const flutter::EncodableValue& value) {
|
||||
VolumeMessage message;
|
||||
if (std::holds_alternative<flutter::EncodableMap>(value)) {
|
||||
auto map = std::get<flutter::EncodableMap>(value);
|
||||
|
||||
flutter::EncodableValue& texture_id =
|
||||
map[flutter::EncodableValue("textureId")];
|
||||
if (std::holds_alternative<int32_t>(texture_id) ||
|
||||
std::holds_alternative<int64_t>(texture_id)) {
|
||||
message.SetTextureId(texture_id.LongValue());
|
||||
}
|
||||
|
||||
flutter::EncodableValue& volume = map[flutter::EncodableValue("volume")];
|
||||
if (std::holds_alternative<double>(volume)) {
|
||||
message.SetVolume(std::get<double>(volume));
|
||||
}
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
private:
|
||||
int64_t texture_id_ = 0;
|
||||
double volume_ = 0;
|
||||
};
|
||||
|
||||
#endif // PACKAGES_VIDEO_PLAYER_VIDEO_PLAYER_ELINUX_MESSAGES_VOLUME_MESSAGE_H_
|
||||
Reference in New Issue
Block a user