iOS Swift Conversion (#2527)
Converts iOS implementation from Objective-c to Swift # During the conversion process some updates to the code structure were also made - Modularize codebase from single file to smaller focused files - Untangled large nested IF statements - Added more null checks, since Swift is more strict with null pointers - Added property to allow for decoding of local video sources with self contained key for offline playback - Updates example apps to test react-native 0.63.4 and uses auto native dependency imports for android and ios
This commit is contained in:
@@ -1,50 +1,79 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include "App.h"
|
||||
#include "ReactPackageProvider.h"
|
||||
|
||||
#include "winrt/ReactNativeVideoCPP.h"
|
||||
|
||||
using namespace winrt::VideoPlayer;
|
||||
using namespace winrt::VideoPlayer::implementation;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the singleton application object. This is the first line of
|
||||
/// authored code executed, and as such is the logical equivalent of main() or
|
||||
/// WinMain().
|
||||
/// </summary>
|
||||
App::App() noexcept
|
||||
{
|
||||
MainComponentName(L"VideoPlayer");
|
||||
|
||||
#if BUNDLE
|
||||
JavaScriptBundleFile(L"index");
|
||||
InstanceSettings().UseWebDebugger(false);
|
||||
InstanceSettings().UseFastRefresh(false);
|
||||
#else
|
||||
JavaScriptMainModuleName(L"index");
|
||||
InstanceSettings().UseWebDebugger(true);
|
||||
InstanceSettings().UseFastRefresh(true);
|
||||
#endif
|
||||
|
||||
#if _DEBUG
|
||||
InstanceSettings().EnableDeveloperMenu(true);
|
||||
#else
|
||||
InstanceSettings().EnableDeveloperMenu(false);
|
||||
#endif
|
||||
|
||||
PackageProviders().Append(make<ReactPackageProvider>()); // Includes all modules in this project
|
||||
|
||||
PackageProviders().Append(winrt::ReactNativeVideoCPP::ReactPackageProvider());
|
||||
|
||||
REACT_REGISTER_NATIVE_MODULE_PACKAGES(); //code-gen macro from autolink
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
// This works around a cpp/winrt bug with composable/aggregable types tracked
|
||||
// by 22116519
|
||||
AddRef();
|
||||
m_inner.as<::IUnknown>()->Release();
|
||||
}
|
||||
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
#include "App.h"
|
||||
|
||||
#include "AutolinkedNativeModules.g.h"
|
||||
#include "ReactPackageProvider.h"
|
||||
|
||||
using namespace winrt::videoplayer;
|
||||
using namespace winrt::videoplayer::implementation;
|
||||
using namespace winrt;
|
||||
using namespace Windows::UI::Xaml;
|
||||
using namespace Windows::UI::Xaml::Controls;
|
||||
using namespace Windows::UI::Xaml::Navigation;
|
||||
using namespace Windows::ApplicationModel;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the singleton application object. This is the first line of
|
||||
/// authored code executed, and as such is the logical equivalent of main() or
|
||||
/// WinMain().
|
||||
/// </summary>
|
||||
App::App() noexcept
|
||||
{
|
||||
#if BUNDLE
|
||||
JavaScriptBundleFile(L"src/index.windows");
|
||||
InstanceSettings().UseWebDebugger(false);
|
||||
InstanceSettings().UseFastRefresh(false);
|
||||
#else
|
||||
JavaScriptMainModuleName(L"src/index");
|
||||
InstanceSettings().UseWebDebugger(true);
|
||||
InstanceSettings().UseFastRefresh(true);
|
||||
#endif
|
||||
|
||||
#if _DEBUG
|
||||
InstanceSettings().UseDeveloperSupport(true);
|
||||
#else
|
||||
InstanceSettings().UseDeveloperSupport(false);
|
||||
#endif
|
||||
|
||||
RegisterAutolinkedNativeModulePackages(PackageProviders()); // Includes any autolinked modules
|
||||
|
||||
PackageProviders().Append(make<ReactPackageProvider>()); // Includes all modules in this project
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the application is launched normally by the end user. Other entry points
|
||||
/// will be used such as when the application is launched to open a specific file.
|
||||
/// </summary>
|
||||
/// <param name="e">Details about the launch request and process.</param>
|
||||
void App::OnLaunched(activation::LaunchActivatedEventArgs const& e)
|
||||
{
|
||||
super::OnLaunched(e);
|
||||
|
||||
Frame rootFrame = Window::Current().Content().as<Frame>();
|
||||
rootFrame.Navigate(xaml_typename<videoplayer::MainPage>(), box_value(e.Arguments()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when application execution is being suspended. Application state is saved
|
||||
/// without knowing whether the application will be terminated or resumed with the contents
|
||||
/// of memory still intact.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the suspend request.</param>
|
||||
/// <param name="e">Details about the suspend request.</param>
|
||||
void App::OnSuspending([[maybe_unused]] IInspectable const& sender, [[maybe_unused]] SuspendingEventArgs const& e)
|
||||
{
|
||||
// Save application state and stop any background activity
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when Navigation to a certain page fails
|
||||
/// </summary>
|
||||
/// <param name="sender">The Frame which failed navigation</param>
|
||||
/// <param name="e">Details about the navigation failure</param>
|
||||
void App::OnNavigationFailed(IInspectable const&, NavigationFailedEventArgs const& e)
|
||||
{
|
||||
throw hresult_error(E_FAIL, hstring(L"Failed to load Page ") + e.SourcePageType().Name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user