Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Swift Conversion #2527

Merged
merged 22 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
45efd1b
Initial iOS Swift Conversion
nickfujita Nov 4, 2021
364a7f8
Apply changes from: Resolved ignored silent switch in iOS when player…
nickfujita Nov 4, 2021
9149bc9
update changelog and version
nickfujita Nov 4, 2021
8823b0c
Merge remote-tracking branch 'upstream/master' into ios-swift-conversion
nickfujita Jan 31, 2022
41be780
update example app, ios working
nickfujita Feb 2, 2022
4f3c2c6
update android test harness
nickfujita Feb 3, 2022
83fd4bd
update windows test app
nickfujita Feb 3, 2022
9a80c06
enable exoplayer for test app, clean up install process, add shortcut…
nickfujita Feb 3, 2022
ee369ea
update readme
nickfujita Feb 3, 2022
163442b
'update changelog and version'
nickfujita Feb 3, 2022
5fa1af7
'fix circle dep
nickfujita May 13, 2022
68f6a81
'fix circle dep'
nickfujita May 13, 2022
05b7805
Merge remote-tracking branch 'upstream/master' into ios-swift-conversion
nickfujita May 13, 2022
805d143
'migrate latest updates to basic example'
nickfujita May 13, 2022
020b159
'fix test harnesses'
nickfujita May 17, 2022
d4292a2
'fix install for windows'
nickfujita May 17, 2022
e955d9c
'update readme'
nickfujita May 17, 2022
bd7044a
'cleanup'
nickfujita May 17, 2022
034a771
fix windows example app, needed to repoint app to new index location
nickfujita May 17, 2022
c4c4d4a
'add back configs not in new template app'
nickfujita May 18, 2022
4e53bbc
Merge branch 'ios-swift-conversion' of github.com:crunchyroll/react-n…
nickfujita May 18, 2022
bc21324
'update readme'
nickfujita May 19, 2022
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ DerivedData
*.ipa
*.xcuserstate
project.xcworkspace
Pods

# Android/IJ
#
Expand All @@ -29,6 +30,9 @@ project.xcworkspace
.gradle
local.properties
*.hprof
.project
.settings
.classpath

# node.js
#
Expand All @@ -46,3 +50,7 @@ buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore

# windows
Deploy.binlog
msbuild.binlog
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
- (Breaking) Bump shaka-player to 3.3.2 [#2587](https://github.com/react-native-video/react-native-video/pull/2587)
- Improve basic player example on android [#2662](https://github.com/react-native-video/react-native-video/pull/2662)
- Ensure we always use `hideShutterView` before showing the `shutterView` on Android [#2609](https://github.com/react-native-video/react-native-video/pull/2609)
- Convert iOS implementation to Swift [#2527](https://github.com/react-native-video/react-native-video/pull/2527)
- Add iOS support for decoding offline sources [#2527](https://github.com/react-native-video/react-native-video/pull/2527)
- Update basic example applications (React Native 0.63.4) [#2527](https://github.com/react-native-video/react-native-video/pull/2527)

### Version 5.2.0

Expand Down Expand Up @@ -223,4 +226,4 @@
- Add cookie support for ExoPlayer [#922](https://github.com/react-native-community/react-native-video/pull/922)
- Remove ExoPlayer onMetadata that wasn't being used [#1040](https://github.com/react-native-community/react-native-video/pull/1040)
- Fix bug where setting the progress interval on iOS didn't work [#800](https://github.com/react-native-community/react-native-video/pull/800)
- Support setting the poster resize mode [#595](https://github.com/react-native-community/react-native-video/pull/595)
- Support setting the poster resize mode [#595](https://github.com/react-native-community/react-native-video/pull/595)
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ Version 3.0 features a number of changes to existing behavior. See [Updating](#u
* [Android](#android-installation)
* [Windows](#windows-installation)
* [react-native-dom](#react-native-dom-installation)
* [Examples](#examples)
* [iOS](#ios-example)
* [Android](#android-example)
* [Windows](#windows-example)
* [Usage](#usage)
* [iOS App Transport Security](#ios-app-transport-security)
* [Audio Mixing](#audio-mixing)
Expand Down Expand Up @@ -69,6 +73,12 @@ Run `npx pod-install`. Linking is not required in React Native 0.60 and above.

Run `react-native link react-native-video` to link the react-native-video library.

#### Enable Static Linking for dependencies in your ios project Podfile

Add `use_frameworks! :linkage => :static` just under `platform :ios` in your ios project Podfile.

[See the example ios project for reference](examples/basic/ios/Podfile#L5)

#### Using CocoaPods (required to enable caching)

Setup your Podfile like it is described in the [react-native documentation](https://facebook.github.io/react-native/docs/integration-with-existing-apps#configuring-cocoapods-dependencies).
Expand Down Expand Up @@ -166,6 +176,11 @@ android.enableJetifier=true

#### **MainApplication.java**

If using com.facebook.react.PackageList to auto import native dependencies, there are no updates required here. Please see the android example project for more details.
/examples/basic/android/app/src/main/java/com/videoplayer/MainApplication.java

##### For manual linking

On top, where imports are:

```java
Expand Down Expand Up @@ -257,6 +272,25 @@ const ReactNativeDomOptions = {
```
</details>

## Examples

Run `yarn xbasic install` before running any of the examples.

### iOS Example
```
yarn xbasic ios
```

### Android Example
```
yarn xbasic android
```

### Windows Example
```
yarn xbasic windows
```

## Usage

```javascript
Expand Down Expand Up @@ -926,6 +960,18 @@ Adjust the volume.

Platforms: all

#### localSourceEncryptionKeyScheme
Set the url scheme for stream encryption key for local assets

Type: String

Example:
```
localSourceEncryptionKeyScheme="my-offline-key"
```

Platforms: iOS


### Event props

Expand Down Expand Up @@ -1404,6 +1450,16 @@ To enable audio to play in background on iOS the audio session needs to be set t

## Updating

### Version 6.0.0

#### iOS

In your project Podfile add support for static dependency linking. This is required to support the new Promises subdependency in the iOS swift conversion.

Add `use_frameworks! :linkage => :static` just under `platform :ios` in your ios project Podfile.

[See the example ios project for reference](examples/basic/ios/Podfile#L5)

### Version 5.0.0

Probably you want to update your gradle version:
Expand Down
1 change: 1 addition & 0 deletions Video.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ Video.propTypes = {
certificateUrl: PropTypes.string,
getLicense: PropTypes.func,
}),
localSourceEncryptionKeyScheme: PropTypes.string,
minLoadRetryCount: PropTypes.number,
maxBitRate: PropTypes.number,
resizeMode: PropTypes.string,
Expand Down
6 changes: 0 additions & 6 deletions examples/basic/.buckconfig

This file was deleted.

58 changes: 0 additions & 58 deletions examples/basic/.flowconfig

This file was deleted.

1 change: 0 additions & 1 deletion examples/basic/.gitattributes

This file was deleted.

55 changes: 0 additions & 55 deletions examples/basic/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion examples/basic/.watchmanconfig

This file was deleted.

14 changes: 14 additions & 0 deletions examples/basic/__tests__/App-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @format
*/

import 'react-native';
import React from 'react';
import VideoPlayer from '../src/VideoPlayer';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

it('renders correctly', () => {
renderer.create(<VideoPlayer />);
});
67 changes: 28 additions & 39 deletions examples/basic/android/app/BUCK
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import re

# To learn about Buck see [Docs](https://buckbuild.com/).
# To run your application with Buck:
# - install Buck
Expand All @@ -10,57 +8,48 @@ import re
# - `buck install -r android/app` - compile, install and run application
#

load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")

lib_deps = []
for jarfile in glob(['libs/*.jar']):
name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile)
lib_deps.append(':' + name)
prebuilt_jar(
name = name,
binary_jar = jarfile,
)

for aarfile in glob(['libs/*.aar']):
name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile)
lib_deps.append(':' + name)
android_prebuilt_aar(
name = name,
aar = aarfile,
)
create_aar_targets(glob(["libs/*.aar"]))

create_jar_targets(glob(["libs/*.jar"]))

android_library(
name = 'all-libs',
exported_deps = lib_deps
name = "all-libs",
exported_deps = lib_deps,
)

android_library(
name = 'app-code',
srcs = glob([
'src/main/java/**/*.java',
]),
deps = [
':all-libs',
':build_config',
':res',
],
name = "app-code",
srcs = glob([
"src/main/java/**/*.java",
]),
deps = [
":all-libs",
":build_config",
":res",
],
)

android_build_config(
name = 'build_config',
package = 'com.videoplayer',
name = "build_config",
package = "com.videoplayer",
)

android_resource(
name = 'res',
res = 'src/main/res',
package = 'com.videoplayer',
name = "res",
package = "com.videoplayer",
res = "src/main/res",
)

android_binary(
name = 'app',
package_type = 'debug',
manifest = 'src/main/AndroidManifest.xml',
keystore = '//android/keystores:debug',
deps = [
':app-code',
],
name = "app",
keystore = "//android/keystores:debug",
manifest = "src/main/AndroidManifest.xml",
package_type = "debug",
deps = [
":app-code",
],
)
Loading