Skip to content

Commit

Permalink
Merge branch 'development' into add-thumbnail-API
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandkakonyi authored Sep 7, 2023
2 parents 629ac1f + 2b1f11b commit dd067e4
Show file tree
Hide file tree
Showing 9 changed files with 223 additions and 52 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,11 @@ jobs:
run: |
bundle exec pod repo remove trunk
bundle exec pod repo add bitmovin https://github.com/bitmovin/cocoapod-specs.git || bundle exec pod repo update bitmovin
NO_FLIPPER=1 bundle exec pod install --repo-update
bundle exec pod install --repo-update
working-directory: example/ios
env:
CP_HOME_DIR: ${{ github.workspace }}/.cocoapods-cache
NO_FLIPPER: 1

- name: Save Pods cache
if: steps.pods-cache-restore.outputs.cache-hit != 'true'
Expand Down
82 changes: 78 additions & 4 deletions .github/workflows/finish-release-train.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,89 @@
name: Finish Release Train
on:
workflow_dispatch:
pull_request:
types:
- closed
branches:
- main
env:
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
concurrency:
group: finish-release-train-${{ github.ref_name }}
cancel-in-progress: true
jobs:
placeholder:
create_pr:
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/v')
runs-on: ubuntu-latest
outputs:
version_number: ${{ steps.version_number.outputs.version_number }}
steps:
- name: Placeholder
run: echo "Placeholder"
- uses: actions/checkout@v4

- name: Detect version number
id: version_number
run: |
version_number="$(npm view bitmovin-player-react-native version)"
echo "Detected version number: $version_number"
echo "version_number=$version_number" >> $GITHUB_OUTPUT
- name: Create PR
run: |
gh pr create \
--base "development" \
--head "main" \
--title "Finish release ${{ steps.version_number.outputs.version_number }}" \
--body "Finish release ${{ steps.version_number.outputs.version_number }}"
env:
GH_TOKEN: ${{ github.token }}

publish_release:
needs: [create_pr]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Git User
run: |
# setup git
git config --global user.name "Bitmovin Release Automation"
git config --global user.email "[email protected]"
- name: Add tag
run: |
git tag v${{ needs.create_pr.outputs.version_number }}
- name: Git push
run: |
git push origin v${{ needs.create_pr.outputs.version_number }}
- name: Setup node and npm registry
uses: actions/setup-node@v3
with:
node-version: '16'
registry-url: 'https://registry.npmjs.org/'
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build TypeScript files
run: yarn build

- name: Publish npm package
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Extract changelog
id: changelog
uses: ffurrer2/extract-release-notes@v1

- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: ${{ steps.changelog.outputs.release_notes }}
41 changes: 0 additions & 41 deletions .github/workflows/publish.yml

This file was deleted.

66 changes: 61 additions & 5 deletions .github/workflows/start-release-train.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,66 @@ on:
env:
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
concurrency:
group: start-release-train-${{ inputs.version_number }}
cancel-in-progress: true
jobs:
placeholder:
name: Placeholder job
runs-on: ubuntu-latest
create_release_pr:
name: Create release branch and bump version
runs-on: macos-latest
outputs:
branch_name: ${{ steps.branching.outputs.branch_name }}
steps:
- name: Placeholder step
run: echo "Placeholder step"
- uses: actions/checkout@v4

- name: Setup Git User
run: |
# setup git
git config --global user.name "Bitmovin Release Automation"
git config --global user.email "[email protected]"
- name: Setup node and npm registry
uses: actions/setup-node@v3
with:
node-version: '16'
registry-url: 'https://registry.npmjs.org/'
cache: 'yarn'

- name: Set Release Branch name
id: branching
run: |
branch_name="release/v${{ inputs.version_number }}"
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT
- name: Create Release Branch
run: |
# Delete the release branch if already exists, useful in case we need to re-run this workflow
git push origin --delete ${{ steps.branching.outputs.branch_name }} || true
git checkout -b ${{ steps.branching.outputs.branch_name }}
- name: Bump changelog version
run: |
sed -i'.bak' "s/\[Unreleased\]/\[${{ inputs.version_number }}\] \(${{ inputs.release_date }}\)/g" CHANGELOG.md
- name: Bump package.json version
run: |
npm version ${{ inputs.version_number }} --no-git-tag-version
- name: Update Podfile.lock
run: |
yarn bootstrap
- name: Commit changelog version bump
run: |
git add CHANGELOG.md package.json example/ios/Podfile.lock
git commit -m "chore: prepare release ${{ inputs.version_number }}"
git push origin ${{ steps.branching.outputs.branch_name }}
- name: Create PR
run: |
gh pr create \
--base "main" \
--title "Release ${{ inputs.version_number }}" \
--body "Release ${{ inputs.version_number }}"
env:
GH_TOKEN: ${{ github.token }}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Added

- `Player.getAudioTrack` and `Player.getSubtitleTrack` APIs to get currently selected audio and subtitle tracks
- `Player.getThumbnail` and `Source.getThumbnail` APIs to get thumbnail images

## [0.10.0] (2023-09-04)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,18 @@ class PlayerModule(private val context: ReactApplicationContext) : ReactContextB
}
}

/**
* Resolve `nativeId`'s currently selected audio track.
* @param nativeId Target player Id.
* @param promise JS promise object.
*/
@ReactMethod
fun getAudioTrack(nativeId: NativeId, promise: Promise) {
uiManager()?.addUIBlock {
promise.resolve(JsonConverter.fromAudioTrack(players[nativeId]?.source?.selectedAudioTrack))
}
}

/**
* Resolve `nativeId`'s player available audio tracks.
* @param nativeId Target player Id.
Expand Down Expand Up @@ -323,6 +335,18 @@ class PlayerModule(private val context: ReactApplicationContext) : ReactContextB
}
}

/**
* Resolve `nativeId`'s currently selected subtitle track.
* @param nativeId Target player Id.
* @param promise JS promise object.
*/
@ReactMethod
fun getSubtitleTrack(nativeId: NativeId, promise: Promise) {
uiManager()?.addUIBlock {
promise.resolve(JsonConverter.fromSubtitleTrack(players[nativeId]?.source?.selectedSubtitleTrack))
}
}

/**
* Resolve `nativeId`'s player available subtitle tracks.
* @param nativeId Target player Id.
Expand Down
8 changes: 8 additions & 0 deletions ios/PlayerModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ @interface RCT_EXTERN_REMAP_MODULE(PlayerModule, PlayerModule, NSObject)
isAirPlayAvailable:(NSString *)nativeId
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(
getAudioTrack:(NSString *)nativeId
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(
getAvailableAudioTracks:(NSString *)nativeId
resolver:(RCTPromiseResolveBlock)resolve
Expand All @@ -60,6 +64,10 @@ @interface RCT_EXTERN_REMAP_MODULE(PlayerModule, PlayerModule, NSObject)
trackIdentifier:(NSString *)trackIdentifier
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(
getSubtitleTrack:(NSString *)nativeId
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(
getAvailableSubtitles:(NSString *)nativeId
resolver:(RCTPromiseResolveBlock)resolve
Expand Down
34 changes: 34 additions & 0 deletions ios/PlayerModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,23 @@ class PlayerModule: NSObject, RCTBridgeModule {
}
}

/**
Resolve `nativeId`'s currently selected audio track.
- Parameter nativeId: Target player Id.
- Parameter resolver: JS promise resolver.
- Parameter rejecter: JS promise rejecter.
*/
@objc(getAudioTrack:resolver:rejecter:)
func getAudioTrack(
_ nativeId: NativeId,
resolver resolve: @escaping RCTPromiseResolveBlock,
rejecter reject: @escaping RCTPromiseRejectBlock
) {
bridge.uiManager.addUIBlock { [weak self] _, _ in
resolve(RCTConvert.audioTrackJson(self?.players[nativeId]?.audio))
}
}

/**
Resolve `nativeId`'s player available audio tracks.
- Parameter nativeId: Target player Id.
Expand Down Expand Up @@ -399,6 +416,23 @@ class PlayerModule: NSObject, RCTBridgeModule {
}
}

/**
Resolve `nativeId`'s currently selected subtitle track.
- Parameter nativeId: Target player Id.
- Parameter resolver: JS promise resolver.
- Parameter rejecter: JS promise rejecter.
*/
@objc(getSubtitleTrack:resolver:rejecter:)
func getSubtitleTrack(
_ nativeId: NativeId,
resolver resolve: @escaping RCTPromiseResolveBlock,
rejecter reject: @escaping RCTPromiseRejectBlock
) {
bridge.uiManager.addUIBlock { [weak self] _, _ in
resolve(RCTConvert.subtitleTrackJson(self?.players[nativeId]?.subtitle))
}
}

/**
Resolve `nativeId`'s player available subtitle tracks.
- Parameter nativeId: Target player Id.
Expand Down
16 changes: 15 additions & 1 deletion src/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,13 @@ export class Player extends NativeInstance<PlayerConfig> {
return PlayerModule.isAirPlayAvailable(this.nativeId);
};

/**
* @returns The currently selected audio track or `null`.
*/
getAudioTrack = async (): Promise<AudioTrack | null> => {
return PlayerModule.getAudioTrack(this.nativeId);
};

/**
* @returns An array containing AudioTrack objects for all available audio tracks.
*/
Expand All @@ -390,6 +397,13 @@ export class Player extends NativeInstance<PlayerConfig> {
return PlayerModule.setAudioTrack(this.nativeId, trackIdentifier);
};

/**
* @returns The currently selected subtitle track or `null`.
*/
getSubtitleTrack = async (): Promise<SubtitleTrack | null> => {
return PlayerModule.getSubtitleTrack(this.nativeId);
};

/**
* @returns An array containing SubtitleTrack objects for all available subtitle tracks.
*/
Expand Down Expand Up @@ -454,7 +468,7 @@ export class Player extends NativeInstance<PlayerConfig> {
* Sets the upper bitrate boundary for video qualities. All qualities with a bitrate
* that is higher than this threshold will not be eligible for automatic quality selection.
*
* Can be set to `undefined` for no limitation.
* Can be set to `null` for no limitation.
*/
setMaxSelectableBitrate = (bitrate: number | null) => {
PlayerModule.setMaxSelectableBitrate(this.nativeId, bitrate || -1);
Expand Down

0 comments on commit dd067e4

Please sign in to comment.