Skip to content
Open
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
8 changes: 8 additions & 0 deletions windows/ReactNativeVideoCPP/ReactVideoView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ void ReactVideoView::Set_UriString(hstring const &value) {
}
}

void ReactVideoView::Clear_Source() {
m_uriString = L"";
if (m_player != nullptr) {
m_player.Pause();
m_player.Source(nullptr);
}
}

void ReactVideoView::Set_Paused(bool value) {
m_isPaused = value;
if (m_player != nullptr) {
Expand Down
1 change: 1 addition & 0 deletions windows/ReactNativeVideoCPP/ReactVideoView.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct ReactVideoView : ReactVideoViewT<ReactVideoView> {
public:
ReactVideoView(winrt::Microsoft::ReactNative::IReactContext const &reactContext);
void Set_UriString(hstring const &value);
void Clear_Source();
void Set_IsLoopingEnabled(bool value);
void Set_Paused(bool isPaused);
void Set_Muted(bool isMuted);
Expand Down
20 changes: 15 additions & 5 deletions windows/ReactNativeVideoCPP/ReactVideoViewManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,22 @@ void ReactVideoViewManager::UpdateProperties(
for (auto const &pair : propertyMap) {
auto const &propertyName = pair.first;
auto const &propertyValue = pair.second;
if (!propertyValue.IsNull()) {
if (propertyName == "src") {
if (propertyName == "src") {
if (propertyValue.IsNull()) {
reactVideoView.Clear_Source();
} else {
auto const &srcMap = propertyValue.AsObject();
auto const &uri = srcMap.at("uri");
reactVideoView.Set_UriString(to_hstring(uri.AsString()));
} else if (propertyName == "resizeMode") {
auto const uri = srcMap.find("uri");
if (uri == srcMap.end() || uri->second.IsNull() || uri->second.AsString().empty()) {
reactVideoView.Clear_Source();
} else {
reactVideoView.Set_UriString(to_hstring(uri->second.AsString()));
}
}
continue;
}
if (!propertyValue.IsNull()) {
if (propertyName == "resizeMode") {
auto resizeModeString = propertyValue.AsString();
Stretch resizeMode = Stretch::None;
if (resizeModeString == "contain") {
Expand Down