diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 24a2055d3c..0000000000 --- a/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "@react-native-community", -} \ No newline at end of file diff --git a/.github/DISCUSSION_TEMPLATE/ideas.yml b/.github/DISCUSSION_TEMPLATE/ideas.yml new file mode 100644 index 0000000000..d398543f77 --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/ideas.yml @@ -0,0 +1,80 @@ +labels: ["feature"] +body: + - type: markdown + attributes: + value: | + Thanks for sharing an idea for react-native-video! + + **Before you post:** + - Search [existing ideas](https://github.com/TheWidlarzGroup/react-native-video/discussions/categories/ideas) - if it's already there, add a 👍 instead of a duplicate + - This is for **feature ideas**, not bugs. Found a bug? [Open a bug report](https://github.com/TheWidlarzGroup/react-native-video/issues/new?template=bug-report.yml) + + - type: textarea + id: problem + attributes: + label: What problem are you trying to solve? + description: The use case or pain point behind this idea. What are you building, and what gets in the way today? + placeholder: "In a TikTok-style feed I want the next video ready instantly, but there's no way to warm up a player before its view is shown." + validations: + required: true + + - type: textarea + id: solution + attributes: + label: Proposed solution + description: What would you like to happen? A rough API shape, prop, or behavior is enough + placeholder: "A preload() method on the player, or a prefetch prop that starts buffering before the view mounts." + validations: + required: true + + - type: textarea + id: alternatives + attributes: + label: Alternatives considered + description: Any workarounds you use today, or other approaches you've thought about + validations: + required: false + + - type: dropdown + id: platforms + attributes: + label: Platforms + description: Which platforms is this idea relevant to? + multiple: true + options: + - iOS + - Android + - Web + - visionOS + - Apple tvOS + - Android TV + - Windows + validations: + required: false + + - type: dropdown + id: version-line + attributes: + label: Version line + description: Which version of react-native-video is this for? + options: + - v7 + - v6 + - Both + - Not sure + validations: + required: false + + - type: textarea + id: context + attributes: + label: Additional context + description: Mockups, links, references, or anything else that helps explain the idea + validations: + required: false + + - type: markdown + attributes: + value: | + --- + **Want this built, or need it sooner?** TheWidlarzGroup - the maintainers of react-native-video - offer [commercial support and custom development](https://sdk.thewidlarzgroup.com/issue-booster?contact=true&utm_source=rnv&utm_medium=discussion&utm_campaign=idea&utm_id=build-it). diff --git a/.github/DISCUSSION_TEMPLATE/q-a.yml b/.github/DISCUSSION_TEMPLATE/q-a.yml new file mode 100644 index 0000000000..259e1ad8f4 --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/q-a.yml @@ -0,0 +1,71 @@ +labels: ["question"] +body: + - type: markdown + attributes: + value: | + Thanks for reaching out! A few details help us answer faster. + + **Before you post:** + - Search [existing Q&A](https://github.com/TheWidlarzGroup/react-native-video/discussions/categories/q-a) and the [docs](https://sdk.thewidlarzgroup.com/) - your question may already be answered + - Hitting a bug or crash? [Open a bug report](https://github.com/TheWidlarzGroup/react-native-video/issues/new?template=bug-report.yml) instead + + - type: textarea + id: goal + attributes: + label: What are you trying to do? + description: Describe your question or the goal you want to achieve with react-native-video + placeholder: "Play an HLS stream and switch audio tracks from a custom button." + validations: + required: true + + - type: textarea + id: tried + attributes: + label: What have you tried? + description: What you've attempted so far, and what actually happens (optional) + validations: + required: false + + - type: textarea + id: code + attributes: + label: Relevant code + description: A minimal snippet of how you set up the player / Video component (optional) + render: tsx + validations: + required: false + + - type: dropdown + id: version-line + attributes: + label: Version + description: Which version of react-native-video is your question about? + options: + - Not version-specific / not sure + - v7 + - v6 + validations: + required: false + + - type: dropdown + id: platforms + attributes: + label: Platforms + description: Which platforms does your question concern? (optional) + multiple: true + options: + - iOS + - Android + - Web + - visionOS + - Apple tvOS + - Android TV + - Windows + validations: + required: false + + - type: markdown + attributes: + value: | + --- + **Need a faster answer or hands-on help?** TheWidlarzGroup - the maintainers of react-native-video - offer [commercial support](https://sdk.thewidlarzgroup.com/issue-booster?contact=true&utm_source=rnv&utm_medium=discussion&utm_campaign=question&utm_id=get-help). diff --git a/.github/DISCUSSION_TEMPLATE/show-and-tell.yml b/.github/DISCUSSION_TEMPLATE/show-and-tell.yml new file mode 100644 index 0000000000..8b9ff2f5f4 --- /dev/null +++ b/.github/DISCUSSION_TEMPLATE/show-and-tell.yml @@ -0,0 +1,39 @@ +body: + - type: markdown + attributes: + value: | + Built something with react-native-video? We'd love to see it! 🎬 + + - type: textarea + id: what + attributes: + label: What did you build? + description: Tell us about your app, feature, or experiment + validations: + required: true + + - type: input + id: link + attributes: + label: Link / demo + description: App Store / Play Store / website / video / screenshots + placeholder: https://... + validations: + required: false + + - type: input + id: version + attributes: + label: react-native-video version used + description: Which version powered it + placeholder: 7.0.0 + validations: + required: false + + - type: textarea + id: notable + attributes: + label: Anything notable? + description: Tricky problems you solved, tips, or feedback for the maintainers + validations: + required: false diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000000..ad70076892 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,6 @@ +# Supported funding model platforms +# https://docs.github.com/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/displaying-a-sponsor-button-in-your-repository + +github: TheWidlarzGroup +custom: + - https://sdk.thewidlarzgroup.com/?utm_source=rnv&utm_medium=github-funding&utm_campaign=sponsor-button diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index b0312b3044..0000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,19 +0,0 @@ -### Current behavior -Describe what happens when you encounter this issue. - -### Reproduction steps -A 1, 2, 3, etc. list of what's needed to see the issue happen. - -### Expected behavior -Describe what you wanted to happen - -### Platform -Which player are you experiencing the problem on: -* iOS -* Android ExoPlayer -* Android MediaPlayer -* Windows UWP -* Windows WPF - -### Video sample -If possible, include a link to the video that has the problem that can be streamed or downloaded from. diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 0000000000..9d16372438 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,185 @@ +name: 🐛 Bug report +description: Report a bug or unexpected behavior in react-native-video +title: "[Bug]: " +labels: ["bug"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to report a bug! + + **Before you continue:** + - Search [existing issues](https://github.com/TheWidlarzGroup/react-native-video/issues) - your problem may already be reported + - Reproduce on the **latest** release. Fixes land on `v7` (and `v6` maintenance) + - **v5 and older are no longer maintained.** Please upgrade to **v6/v7** (where we fix issues), or use [commercial support](https://sdk.thewidlarzgroup.com/issue-booster?contact=true&utm_source=rnv&utm_medium=issue&utm_campaign=v5-support&utm_id=v5-support) if you must stay on v5. These reports will be closed automatically + - Feature idea or usage question? This is **not** the place - use the links on the "New issue" screen (Discussions) + + - type: checkboxes + id: prerequisites + attributes: + label: Prerequisites + description: Please confirm the following before submitting + options: + - label: I searched existing issues and didn't find a duplicate + required: true + - label: I reproduced this on the latest release of react-native-video + required: true + + - type: textarea + id: what-happened + attributes: + label: What happened? + description: A clear description of the bug and what you expected instead. Screenshots or a screen recording help a lot + placeholder: "Playing an HLS stream on Android, the video freezes after ~3s while audio keeps playing. I expected smooth playback" + validations: + required: true + + - type: textarea + id: steps-to-reproduce + attributes: + label: Steps to reproduce + description: Exact steps for us to reproduce the bug + placeholder: | + 1. Render the Video component + 2. Start playback + 3. Observe the freeze after a few seconds + validations: + required: true + + - type: input + id: reproduction-repo + attributes: + label: Reproduction repository + description: A link to a minimal repo (or the example app modified) that reproduces the bug. Reports without a reproduction are much harder to fix + placeholder: https://github.com/your-username/rnv-bug-repro + validations: + required: false + + - type: markdown + attributes: + value: | + ## Required information + + - type: input + id: rnv-version + attributes: + label: react-native-video version + description: The exact version from your package.json + placeholder: 7.0.0 + validations: + required: true + + - type: input + id: react-native-version + attributes: + label: react-native version + description: The exact version from your package.json + placeholder: 0.86.0 + validations: + required: true + + - type: input + id: nitro-modules-version + attributes: + label: react-native-nitro-modules version + description: The react-native-nitro-modules version from your package.json (v7 only, skip if not applicable) + placeholder: 0.35.9 + validations: + required: false + + - type: dropdown + id: platforms + attributes: + label: Platforms + description: Which platforms does the bug occur on? + multiple: true + options: + - iOS + - Android + - Web + - visionOS + - Apple tvOS + - Android TV + - Windows + validations: + required: true + + - type: input + id: system-version + attributes: + label: OS version + description: The OS version of the device/simulator where you see the bug + placeholder: iOS 18.2 / Android 15 + validations: + required: true + + - type: dropdown + id: device + attributes: + label: Device + description: Where are you running the app? + multiple: true + options: + - Real device + - Simulator / Emulator + validations: + required: true + + - type: dropdown + id: architecture + attributes: + label: Architecture + description: Which React Native architecture are you using? + options: + - New Architecture + - Old Architecture + validations: + required: true + + - type: dropdown + id: expo + attributes: + label: Expo + description: "Are you using Expo? (Note: react-native-video doesn't work in Expo Go - you need a Dev Client)" + options: + - Yes (Expo Dev Client) + - No (bare / React Native CLI) + validations: + required: true + + - type: markdown + attributes: + value: | + ## Additional information (optional) + + The more you provide, the faster we can help + + - type: input + id: last-working-version + attributes: + label: Last working version + description: Did this work on a previous version? If so, which react-native-video version was the last that worked? + placeholder: 6.15.0 + validations: + required: false + + - type: dropdown + id: source-type + attributes: + label: Media / source type + description: What kind of media are you playing? + multiple: true + options: + - HLS (.m3u8) + - DASH (.mpd) + - MP4 / progressive + - Local file + - Other + validations: + required: false + + - type: markdown + attributes: + value: | + --- + **Need this fixed fast, or want dedicated support?** TheWidlarzGroup - the maintainers of react-native-video - offer [commercial support](https://sdk.thewidlarzgroup.com/issue-booster?contact=true&utm_source=rnv&utm_medium=issue&utm_campaign=bug-report&utm_id=fix-it-fast) and custom development diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index ac2d1e3e29..0000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -# Bug - - - -## Platform - -Which player are you experiencing the problem on: -* iOS -* Android ExoPlayer -* Android MediaPlayer -* Windows UWP -* Windows WPF - -## Environment info - - - -React native info output: - -```bash - // paste it here -``` - -Library version: x.x.x - -## Steps To Reproduce - - - -1. -2. -... - -## Expected behaviour - -1. -2. - -## Reproducible sample code - - - -## Video sample -If possible, include a link to the video that has the problem that can be streamed or downloaded from. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000000..01523e91eb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,17 @@ +blank_issues_enabled: false +contact_links: + - name: 💼 Priority / commercial support + url: https://sdk.thewidlarzgroup.com/issue-booster?contact=true&utm_source=rnv&utm_medium=issue&utm_campaign=issue-chooser&utm_id=commercial-support + about: Need it fixed fast or want dedicated help? TheWidlarzGroup (the maintainers) offer priority support and custom development. + - name: 💡 Feature request + url: https://github.com/TheWidlarzGroup/react-native-video/discussions/categories/ideas + about: Have an idea? Propose and discuss new features in Discussions -> Ideas. + - name: ❓ Question / Help + url: https://github.com/TheWidlarzGroup/react-native-video/discussions/categories/q-a + about: Usage questions and how-to help - ask the community in Discussions -> Q&A. + - name: 💬 Discord (TheWidlarzGroup) + url: https://discord.gg/uxyf9s7TR8 + about: Chat with the community and maintainers on Discord. + - name: "💬 VideoDev Slack (#react-native-video)" + url: https://join.slack.com/t/video-dev/shared_invite/zt-24kgmctuv-2z0O9J_v6q_rg~x1RujdOA + about: "Find us in the #react-native-video channel on the VideoDev Slack." diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index cc62df4e1d..0000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - ---- - -# Feature Request - - - -## Why it is needed - - - -## Possible implementation - - - -### Code sample - - diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 5ee6f693c9..885ffa77b8 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,20 +1,53 @@ -Thanks for opening a PR! -Since this is a volunteer project and is very active, anything you can do to reduce the amount of time needed to review and merge your PR is appreciated. -The following steps will help get your PR merged quickly: + -#### Update the changelog -After you open the PR, update the CHANGELOG.md file with an entry pointing to your PR. +## Summary -#### Provide an example of how to test the change -If the PR requires special testing setup provide all the relevant instructions and files. This may include a sample video file or URL, configuration, or setup steps. + -#### Focus the PR on only one area -Testing multiple features takes longer than isolated changes and if there is a bug in one feature, prevents the other parts of your PR from getting merged until it gets fixed. -If you're touching multiple different areas that aren't related, break the changes up into multiple PRs. +## Motivation -#### Describe the changes -Add a note describing what your PR does. If there is a change to the behavior of the code, explain why it needs to be updated. + + +## Changes + + + +- + +## Platforms affected + + + +- [ ] Android +- [ ] iOS +- [ ] visionOS +- [ ] tvOS / Android TV +- [ ] Windows +- [ ] Web + +## Type of change + +- [ ] Bug fix (non-breaking change that fixes an issue) +- [ ] New feature (non-breaking change that adds functionality) +- [ ] Breaking change (fix or feature that changes existing behavior) +- [ ] Documentation only + +## Test plan + + + +## Checklist + +- [ ] I read the [contributing guidelines](https://github.com/TheWidlarzGroup/react-native-video/blob/master/CONTRIBUTING.md). +- [ ] I updated the documentation / README where relevant. +- [ ] If this changes how the library is used (API, props, events, behavior), I updated the AI agent skill (`skills/react-native-video/`) to match. +- [ ] This PR is focused on a single concern. +- [ ] I tested my changes on at least one platform. diff --git a/.github/actions/setup-bun/action.yml b/.github/actions/setup-bun/action.yml new file mode 100644 index 0000000000..a9bc03fff6 --- /dev/null +++ b/.github/actions/setup-bun/action.yml @@ -0,0 +1,33 @@ +name: setup bun +description: Setup bun and install dependencies + +inputs: + working-directory: + description: 'working directory for bun install' + default: ./ + required: false + +runs: + using: composite + steps: + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: 1.3.1 + + - name: Cache dependencies + id: bun-cache + uses: actions/cache@v4 + with: + path: | + **/node_modules + key: ${{ runner.os }}-v7-bun-${{ hashFiles('**/bun.lock') }}-${{ hashFiles('**/package.json') }} + restore-keys: | + ${{ runner.os }}-v7-bun-${{ hashFiles('**/bun.lock') }} + ${{ runner.os }}-v7-bun- + + - name: Install dependencies + working-directory: ${{ inputs.working-directory }} + run: bun install + shell: bash + diff --git a/.github/scripts/triage-discussion.js b/.github/scripts/triage-discussion.js new file mode 100644 index 0000000000..9d93460ed7 --- /dev/null +++ b/.github/scripts/triage-discussion.js @@ -0,0 +1,48 @@ +// @ts-check +// Welcome bot for react-native-video discussions. On a newly created discussion +// it posts a short welcome comment (labels are handled by the category forms). +// handleDiscussion() is the entry point and does the GitHub IO. + +// Per-category welcome comment, keyed by the discussion category slug. +// Categories not listed here (Announcements, General) are left untouched. +/** @type {Record} */ +const COMMENT = { + ideas: 'Thanks for sharing this idea! 🙏 We will take a look, and others can chime in with 👍 and comments.', + 'q-a': 'Thanks for the question! 🙏 The community and maintainers will help when they can. Once something solves it, please mark it as the answer so others can find it.', + 'show-and-tell': 'Thanks for sharing what you built! 🎬 We love seeing react-native-video out in the wild.', + polls: 'Thanks for starting this poll! 🗳️ Cast your vote and let the community weigh in.', +}; + +/** @typedef {import('@octokit/rest').Octokit} Octokit */ +/** + * @typedef {Object} Discussion + * @property {string} node_id + * @property {number} number + * @property {{ slug?: string, name?: string }} [category] + */ +/** + * @typedef {Object} Context + * @property {{ owner: string, repo: string }} repo + * @property {{ discussion?: Discussion, action?: string }} payload + */ + +const ADD_COMMENT = `mutation($id:ID!,$body:String!){ + addDiscussionComment(input:{ discussionId:$id, body:$body }){ comment{ id } } +}`; + +/** @param {{ github: Octokit, context: Context }} args */ +async function handleDiscussion({ github, context }) { + const discussion = context.payload.discussion; + if (!discussion) return; + + const slug = discussion.category && discussion.category.slug; + const comment = slug ? COMMENT[slug] : undefined; + if (!comment) { + console.log(`No welcome comment for category "${slug}" -> skipping`); + return; + } + + await github.graphql(ADD_COMMENT, { id: discussion.node_id, body: comment }); +} + +module.exports = handleDiscussion; diff --git a/.github/scripts/validate-issue.js b/.github/scripts/validate-issue.js new file mode 100644 index 0000000000..dd90e9e8e3 --- /dev/null +++ b/.github/scripts/validate-issue.js @@ -0,0 +1,366 @@ +// @ts-check +// Deterministic issue validator + labeler for react-native-video bug reports. +// handleIssue() is the entry point and does the GitHub IO. + +/** @type {Record} */ +const PLATFORM = { + 'iOS': 'Platform: iOS', + 'Android': 'Platform: Android', + 'Web': 'Platform: Web', + 'visionOS': 'Platform: visionOS', + 'Apple tvOS': 'Platform: tvOS', + 'Android TV': 'Platform: Android TV', + 'Windows': 'Platform: Windows', +}; + +// Issue-form section headers we read. +const SECTION = { + platforms: 'Platforms', + repro: 'Reproduction repository', + version: 'react-native-video version', + prerequisites: 'Prerequisites', +}; + +const REPRO_PROVIDED = 'Repro Provided'; +const MISSING_REPRO = 'Missing Repro'; +const OUTDATED = 'Newer Version Available'; +const VERSION_MAJORS = [5, 6, 7]; +/** @param {number} major */ +const versionLabel = (major) => `V${major}`; + +// Bot-owned labels. EXCLUSIVE groups: at most one member per issue (setting one +// drops the others). ADDITIVE: any number may apply. Non-bot labels are never touched. +const EXCLUSIVE_GROUPS = [ + VERSION_MAJORS.map(versionLabel), // V5 / V6 / V7 + [REPRO_PROVIDED, MISSING_REPRO], // repro state +]; +const ADDITIVE_LABELS = [...Object.values(PLATFORM), OUTDATED]; + +const SKIP_LABEL = 'No Validation'; +const BOT_MARK = ''; + +// `context` is typed locally below - github-script's payload type is too loose. +/** @typedef {import('@octokit/rest').Octokit} Octokit */ +/** + * @typedef {Object} IssueLabel + * @property {string} name + */ +/** + * @typedef {Object} Issue + * @property {number} number + * @property {string} [body] + * @property {string} state + * @property {Array} [labels] + */ +/** + * @typedef {Object} Context + * @property {{ owner: string, repo: string }} repo + * @property {{ issue: Issue, action?: string }} payload + */ + +/** @param {string} v */ +const isEmpty = (v) => !v || v === '_No response_'; + +/** + * Parse the "### Header\n value" sections produced by GitHub issue forms. + * @param {string} body + * @returns {Record} + */ +function parseSections(body) { + /** @type {Record} */ + const sections = {}; + /** @type {string | null} */ + let header = null; + for (const line of String(body || '').split(/\r?\n/)) { + const m = line.match(/^###\s+(.+?)\s*$/); + if (m) { header = m[1].trim(); sections[header] = ''; continue; } + if (header != null) sections[header] += line + '\n'; + } + for (const k of Object.keys(sections)) sections[k] = sections[k].trim(); + return sections; +} + +/** + * A reproduction is "provided" only when the field contains a real http(s) URL. + * @param {string} v + * @returns {boolean} + */ +function isReproUrl(v) { + if (isEmpty(v)) return false; + return /\bhttps?:\/\/[^\s)]+/i.test(v); +} + +/** + * Extract the first x.y.z from a version string (ignores a leading v and any + * prerelease suffix). + * @param {string} v + * @returns {number[] | null} [major, minor, patch] or null + */ +function parseVersionTuple(v) { + const s = parseSemver(v); + return s ? s.main : null; +} + +/** + * Full semver parse incl. prerelease identifiers. Generic for -alpha/-beta/-rc/etc. + * @param {string} v + * @returns {{ main: number[], pre: string[] } | null} + */ +function parseSemver(v) { + const m = String(v || '').match(/v?(\d+)\.(\d+)\.(\d+)(?:[-.]([0-9A-Za-z.-]+))?/); + if (!m) return null; + // Split prerelease ids on "." or "-" so malformed inputs like "7.0.0.beta-9" + // still compare correctly (real-world reporters fumble the separators). + return { main: [Number(m[1]), Number(m[2]), Number(m[3])], pre: m[4] ? m[4].split(/[-.]/) : [] }; +} + +/** + * Compare two prerelease identifier arrays per semver precedence. + * [] (stable) ranks higher than any prerelease. + * @param {string[]} a + * @param {string[]} b + * @returns {number} + */ +function comparePre(a, b) { + if (a.length === 0 && b.length === 0) return 0; + if (a.length === 0) return 1; + if (b.length === 0) return -1; + const n = Math.max(a.length, b.length); + for (let i = 0; i < n; i++) { + if (i >= a.length) return -1; + if (i >= b.length) return 1; + const x = a[i], y = b[i]; + const xn = /^\d+$/.test(x), yn = /^\d+$/.test(y); + if (xn && yn) { if (Number(x) !== Number(y)) return Number(x) < Number(y) ? -1 : 1; } + else if (xn) return -1; + else if (yn) return 1; + else if (x !== y) return x < y ? -1 : 1; + } + return 0; +} + +/** + * Full semver comparison: -1 if a < b, 0 if equal, 1 if a > b. + * @param {string} a + * @param {string} b + * @returns {number} + */ +function compareSemver(a, b) { + const pa = parseSemver(a), pb = parseSemver(b); + if (!pa || !pb) return 0; + for (let i = 0; i < 3; i++) if (pa.main[i] !== pb.main[i]) return pa.main[i] < pb.main[i] ? -1 : 1; + return comparePre(pa.pre, pb.pre); +} + +/** + * Highest version among `versions` that shares the given major (the newest the + * reporter could upgrade to within their own version line). + * @param {string[]} versions + * @param {number} major + * @returns {string | null} + */ +function highestForMajor(versions, major) { + const same = (versions || []).filter((v) => { const t = parseVersionTuple(v); return t && t[0] === major; }); + if (!same.length) return null; + return same.reduce((hi, v) => (compareSemver(v, hi) > 0 ? v : hi), same[0]); +} + +/** + * Compute the desired bot labels + actions from parsed sections. + * @param {Record} sections + * @param {string[]} versions array of candidate "newest" version strings (npm dist-tags) + * @returns {{ labels: Set, isV5: boolean, outdated: { from: string, to: string } | null }} + */ +function computeTriage(sections, versions) { + /** @param {string} h */ + const get = (h) => (sections[h] || '').trim(); + /** @type {Set} */ + const labels = new Set(); + let isV5 = false; + /** @type {{ from: string, to: string } | null} */ + let outdated = null; + + const plat = get(SECTION.platforms); + if (!isEmpty(plat)) { + for (const p of plat.split(/[,\n]/).map((s) => s.trim()).filter(Boolean)) { + if (PLATFORM[p]) labels.add(PLATFORM[p]); + } + } + + labels.add(isReproUrl(get(SECTION.repro)) ? REPRO_PROVIDED : MISSING_REPRO); + + const verRaw = get(SECTION.version); + const tuple = parseVersionTuple(verRaw); + if (tuple) { + const maj = tuple[0]; + // rnv majors are 1..7; major 0 here means a confused reporter pasted their + // React Native version (0.x) into this field, so do not treat it as unsupported. + if (maj >= 1 && maj <= 5) { + // v5 and older are unsupported; bucket them all under the V5 label so the + // close stays idempotent (the close guard keys off this label). + isV5 = true; + labels.add(versionLabel(5)); + } else { + if (VERSION_MAJORS.includes(maj)) labels.add(versionLabel(maj)); + // newest in the reporter's major line, so e.g. an alpha is nudged to the latest beta + const newest = highestForMajor(versions, maj); + if (newest && compareSemver(verRaw, newest) < 0) { + labels.add(OUTDATED); + outdated = { from: verRaw, to: newest }; + } + } + } + + return { labels, isV5, outdated }; +} + +/** + * Remove the Prerequisites checkboxes section from the rendered issue body. + * @param {string} body + * @returns {string | null} the new body, or null if there was nothing to strip + */ +function tidyBody(body) { + const lines = String(body || '').split(/\r?\n/); + /** @type {string[]} */ + const out = []; + let inPrereq = false; + let removed = false; + // Drop ONLY the Prerequisites section; keep everything else verbatim + // (preamble before the first header, other sections, text between them). + for (const line of lines) { + if (/^###\s+/.test(line)) { + inPrereq = line.replace(/^###\s+/, '').trim().toLowerCase() === SECTION.prerequisites.toLowerCase(); + if (inPrereq) { removed = true; continue; } + } + if (inPrereq) continue; + out.push(line); + } + if (!removed) return null; + return out.join('\n').replace(/\s+$/, '') + '\n'; +} + +/** @returns {Promise} */ +async function fetchLatestVersions() { + try { + const res = await fetch('https://registry.npmjs.org/-/package/react-native-video/dist-tags'); + if (!res.ok) return []; + const tags = /** @type {Record} */ (await res.json()); + return Object.values(tags).filter(Boolean); + } catch (e) { + console.error('npm dist-tags fetch failed:', e instanceof Error ? e.message : e); + return []; + } +} + +/** @param {{ github: Octokit, context: Context }} args */ +async function hidePreviousBotComments({ github, context }) { + const { owner, repo } = context.repo; + const number = context.payload.issue.number; + const comments = await github.rest.issues.listComments({ owner, repo, issue_number: number }); + const ours = comments.data.filter((c) => c.body && c.body.includes(BOT_MARK) && !c.body.includes('Previous bot comment')); + for (const c of ours) { + const hidden = `
\nPrevious bot comment (click to expand)\n\n${c.body}\n\n
`; + await github.rest.issues.updateComment({ owner, repo, comment_id: c.id, body: hidden }); + } +} + +/** @param {{ github: Octokit, context: Context, body: string }} args */ +async function comment({ github, context, body }) { + const { owner, repo } = context.repo; + await hidePreviousBotComments({ github, context }); + await github.rest.issues.createComment({ + owner, + repo, + issue_number: context.payload.issue.number, + body: `${body}\n\n${BOT_MARK}`, + }); +} + +/** @param {{ github: Octokit, context: Context }} args */ +async function handleIssue({ github, context }) { + const { owner, repo } = context.repo; + const issue = context.payload.issue; + if (!issue) return; + const number = issue.number; + const body = issue.body || ''; + + const sections = parseSections(body); + // Only act on our bug-report form. + if (!(SECTION.platforms in sections) && !(SECTION.version in sections)) return; + + const existing = (issue.labels || []).map((l) => (typeof l === 'string' ? l : l.name)); + if (existing.includes(SKIP_LABEL)) { + console.log('No Validation label present -> skipping'); + return; + } + + const versions = await fetchLatestVersions(); + const { labels: desired, isV5, outdated } = computeTriage(sections, versions); + + // Reconcile only the bot's own labels (never touch others -> no clobber/race). + const have = new Set(existing); + const toAdd = [...desired].filter((l) => !have.has(l)); + /** @type {string[]} */ + const toRemove = []; + // Exclusive groups: setting one member drops the others that are present. + for (const group of EXCLUSIVE_GROUPS) { + if (group.some((l) => desired.has(l))) { + for (const l of group) if (have.has(l) && !desired.has(l)) toRemove.push(l); + } + } + // Additive bot labels no longer applicable. + for (const l of ADDITIVE_LABELS) { + if (have.has(l) && !desired.has(l)) toRemove.push(l); + } + if (toAdd.length) { + await github.rest.issues.addLabels({ owner, repo, issue_number: number, labels: toAdd }); + } + for (const l of toRemove) { + try { + await github.rest.issues.removeLabel({ owner, repo, issue_number: number, name: l }); + } catch (e) { /* label already absent - ignore */ } + } + + const tidied = tidyBody(body); + if (tidied && tidied !== body) { + await github.rest.issues.update({ owner, repo, issue_number: number, body: tidied }); + } + + // On a freshly opened issue, post one welcome comment: a thanks intro plus any + // nudges that apply (outdated version, missing reproduction) as a bullet list. + // v5 has its own message below, so it is excluded here. + if (context.payload.action === 'opened' && !isV5) { + /** @type {string[]} */ + const nudges = []; + if (outdated) { + nudges.push( + `You reported **${outdated.from}**, but a newer version (**${outdated.to}**) is available - ` + + `please retest on it and update the report if it still happens; many problems are already fixed there.`, + ); + } + if (desired.has(MISSING_REPRO)) { + nudges.push('We could not find a reproduction link - a minimal repro helps us fix it much faster, so please add one if you can.'); + } + const intro = 'Thanks for creating the issue! It will be triaged soon.'; + const text = nudges.length ? `${intro}\n\n${nudges.map((n) => `- ${n}`).join('\n')}` : intro; + await comment({ github, context, body: text }); + } + + // v5 is unsupported: comment + close as not planned (only once). + if (isV5 && issue.state === 'open' && !existing.includes(versionLabel(5))) { + await comment({ + github, + context, + body: [ + 'Thanks for the report - but **react-native-video v5 and older are no longer maintained**.', + '', + `Please upgrade to **v6 or v7**, where we actively fix issues. If you must stay on v5, [TheWidlarzGroup offers commercial support](https://sdk.thewidlarzgroup.com/issue-booster?contact=true&utm_source=rnv&utm_medium=issue&utm_campaign=v5-support&utm_id=${number}).`, + '', + 'Closing as not planned - if it still happens on a supported version, please open a new issue.', + ].join('\n'), + }); + await github.rest.issues.update({ owner, repo, issue_number: number, state: 'closed', state_reason: 'not_planned' }); + } +} + +module.exports = handleIssue; diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 0000000000..f5a6a16d8c --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,51 @@ +name: Deploy Documentation + +on: + workflow_dispatch: + push: + branches: + - master + paths: + # Update on workflow change + - ".github/workflows/deploy-docs.yml" + # Update on docs change + - "docs/**" + # Update on code change (Api Reference) + - "packages/react-native-video/src/**" + +jobs: + build: + name: Build Documentation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: ./.github/actions/setup-bun + + - name: Build Documentation + run: bun run --cwd docs build + + - name: Upload Build Artifact + uses: actions/upload-pages-artifact@v3 + with: + path: docs/build + + deploy: + name: Deploy Documentation to GitHub Pages + needs: build + + permissions: + pages: write + id-token: write + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000000..01ca4fd46e --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,27 @@ +name: Close inactive issues + +on: + schedule: + - cron: "30 1 * * *" + workflow_dispatch: + +permissions: + issues: write + pull-requests: write + +jobs: + stale: + if: ${{ github.repository == 'TheWidlarzGroup/react-native-video' }} + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v9 + with: + days-before-issue-stale: 30 + days-before-issue-close: 14 + stale-issue-label: "stale" + stale-issue-message: "This issue is stale because it has been open for 30 days with no activity. It will be closed in 14 days if there is no further activity." + close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale." + exempt-issue-labels: "good first issue,No Stale,Accepted" + days-before-pr-stale: -1 + days-before-pr-close: -1 + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-docs-build.yml b/.github/workflows/test-docs-build.yml new file mode 100644 index 0000000000..eb1fce59c4 --- /dev/null +++ b/.github/workflows/test-docs-build.yml @@ -0,0 +1,27 @@ +name: Test Documentation Build + +on: + pull_request: + branches: + - master + paths: + # Update on workflow change + - ".github/workflows/test-docs-build.yml" + # Update on docs change + - "docs/**" + # Update on code change (Api Reference) + - "packages/react-native-video/src/**" + +jobs: + test-docs-deploy: + name: Test Documentation Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: ./.github/actions/setup-bun + + - name: Test build website + run: bun run --cwd docs build diff --git a/.github/workflows/triage-discussion.yml b/.github/workflows/triage-discussion.yml new file mode 100644 index 0000000000..a29f22f99a --- /dev/null +++ b/.github/workflows/triage-discussion.yml @@ -0,0 +1,25 @@ +name: Triage discussion + +on: + discussion: + types: [created] + +permissions: + contents: read + discussions: write + +jobs: + triage: + if: ${{ github.repository == 'TheWidlarzGroup/react-native-video' }} + runs-on: ubuntu-latest + concurrency: + group: triage-discussion-${{ github.event.discussion.number }} + cancel-in-progress: false + steps: + - uses: actions/checkout@v4 + - uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const handleDiscussion = require('./.github/scripts/triage-discussion.js') + await handleDiscussion({ github, context }) diff --git a/.github/workflows/validate-issue.yml b/.github/workflows/validate-issue.yml new file mode 100644 index 0000000000..afc685dd25 --- /dev/null +++ b/.github/workflows/validate-issue.yml @@ -0,0 +1,25 @@ +name: Validate issue + +on: + issues: + types: [opened, edited] + +permissions: + contents: read + issues: write + +jobs: + validate: + if: ${{ github.repository == 'TheWidlarzGroup/react-native-video' }} + runs-on: ubuntu-latest + concurrency: + group: validate-issue-${{ github.event.issue.number }} + cancel-in-progress: false + steps: + - uses: actions/checkout@v4 + - uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const handleIssue = require('./.github/scripts/validate-issue.js') + await handleIssue({ github, context }) diff --git a/.gitignore b/.gitignore index d477ec0518..be0757aef5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,15 @@ # .DS_Store +**/.xcode.env.local + +# XDE +.expo/ + +# VSCode +.vscode/ +jsconfig.json + # Xcode # build/ @@ -24,25 +33,55 @@ project.xcworkspace # Android/IJ # -*.iml -.idea +.classpath +.cxx .gradle +.idea +.project +.settings local.properties -*.hprof +android.iml + +# Cocoapods +# +example/ios/Pods + +# Ruby +example/vendor/ # node.js # node_modules/ -*.log - -# yarn -yarn.lock +npm-debug.log +yarn-debug.log +yarn-error.log -# editor workspace settings -.vscode +# Bun +package-lock.json +**/*.bun # BUCK buck-out/ \.buckd/ android/app/libs android/keystores/debug.keystore + +# Yarn +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions + +# Expo +.expo/ + +# Turborepo +.turbo/ + +# generated by bob +lib/ + +# TypeScript +*.tsbuildinfo \ No newline at end of file diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 1d4c3eff7a..0000000000 --- a/.prettierrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "requirePragma": true, - "singleQuote": true, - "trailingComma": "all", - "bracketSpacing": false, - "jsxBracketSameLine": true, - "parser": "flow" -} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 53e2518cf7..0000000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,201 +0,0 @@ -## Changelog - -### Version 5.1.0-alpha9 - -- Add ARM64 support for windows [#2137](https://github.com/react-native-community/react-native-video/pull/2137) - -### Version 5.1.0-alpha8 - -- Fixing ID3 Frame Error When Receiving EventMessage in TimedMetadata [#2116](https://github.com/react-native-community/react-native-video/pull/2116) - -### Version 5.1.0-alpha7 - -- Basic support for DRM on iOS and Android [#1445](https://github.com/react-native-community/react-native-video/pull/1445) - -### Version 5.1.0-alpha6 - -- Fix iOS bug which would break size of views when video is displayed with controls on a non full-screen React view. [#1931](https://github.com/react-native-community/react-native-video/pull/1931) -- Fix video dimensions being undefined when playing HLS in ios. [#1992](https://github.com/react-native-community/react-native-video/pull/1992) -- Add support for audio mix with other apps for iOS. [#1978](https://github.com/react-native-community/react-native-video/pull/1978) -- Properly implement pending seek for iOS. [#1994](https://github.com/react-native-community/react-native-video/pull/1994) -- Added `preferredForwardBufferDuration` (iOS) - the duration the player should buffer media from the network ahead of the playhead to guard against playback disruption. (#1944) -- Added `currentPlaybackTime` (Android ExoPlayer, iOS) - when playing an HLS live stream with a `EXT-X-PROGRAM-DATE-TIME` tag configured, then this property will contain the epoch value in msec. (#1944) -- Added `trackId` (Android ExoPlayer) - Configure an identifier for the video stream to link the playback context to the events emitted. (#1944) -- Added preventsDisplaySleepDuringVideoPlayback (#2019) -- Reverted the JS fullscreening for Android. [#2013](https://github.com/react-native-community/react-native-video/pull/2013) -- Set iOS request headers without needing to edit RCTVideo.m. [#2014](https://github.com/react-native-community/react-native-video/pull/2014) -- Fix exoplayer aspect ratio update on source changes [#2053](https://github.com/react-native-community/react-native-video/pull/2053) - -### Version 5.1.0-alpha5 - -- Add support for react-native Windows Cpp/WinRT [#1893]((https://github.com/react-native-community/react-native-video/pull/1893)) - -### Version 5.1.0-alpha4 - -- Fix android play/pause bug related to full-screen mode [#1916](https://github.com/react-native-community/react-native-video/pull/1916) - -### Version 5.1.0-alpha3 - -- Improve Android Audio Focus [#1897](https://github.com/react-native-community/react-native-video/pull/1897) - -### Version 5.1.0-alpha2 - -- Added support for full-screen functionality in Android Exoplayer [#1730](https://github.com/react-native-community/react-native-video/pull/1730) - -### Version 5.1.0-alpha1 - -- Fixed Exoplayer doesn't work with mute=true (Android). [#1696](https://github.com/react-native-community/react-native-video/pull/1696) -- Added support for automaticallyWaitsToMinimizeStalling property (iOS) [#1723](https://github.com/react-native-community/react-native-video/pull/1723) -- Bump Exoplayer to 2.10.4, remove deprecated usages of Exoplayer methods (Android). [#1753](https://github.com/react-native-community/react-native-video/pull/1753) -- Preserve Exoplayer BandwidthMeter instance across video plays, this should noticeably improve streaming bandwidth detection (Android). - -### Version 5.0.2 - -- Fix crash when RCTVideo's superclass doesn't observe the keyPath 'frame' (iOS) [#1720](https://github.com/react-native-community/react-native-video/pull/1720) - -### Version 5.0.1 - -- Fix AndroidX Support bad merge - -### Version 5.0.0 [Deprecated] - -- AndroidX Support - -### Version 4.4.4 - -- Handle racing conditions when props are settled on Exoplayer - -### Version 4.4.3 - -- Fix mute/unmute when controls are present (iOS) [#1654](https://github.com/react-native-community/react-native-video/pull/1654) -- Fix Android videos being able to play with background music/audio from other apps. -- Fixed memory leak on iOS when using `controls` [#1647](https://github.com/react-native-community/react-native-video/pull/1647) -- (Android) Update gradle and target SDK [#1629](https://github.com/react-native-community/react-native-video/pull/1629) -- Fix iOS stressed mount/unmount crash [#1646](https://github.com/react-native-community/react-native-video/pull/1646) - -### Version 4.4.2 - -- Change compileOnly to implementation on gradle (for newer gradle versions and react-native 0.59 support) [#1592](https://github.com/react-native-community/react-native-video/pull/1592) -- Replaced RCTBubblingEventBlock events by RCTDirectEventBlock to avoid event name collisions [#1625](https://github.com/react-native-community/react-native-video/pull/1625) -- Added `onPlaybackRateChange` to README [#1578](https://github.com/react-native-community/react-native-video/pull/1578) -- Added `onReadyForDisplay` to README [#1627](https://github.com/react-native-community/react-native-video/pull/1627) -- Improved handling of poster image. Fixes bug with displaying video and poster simultaneously. [#1627](https://github.com/react-native-community/react-native-video/pull/1627) -- Fix background audio stopping on iOS when using `controls` [#1614](https://github.com/react-native-community/react-native-video/pull/1614) - -### Version 4.4.1 - -- Fix tvOS picture-in-picture compilation regression [#1518](https://github.com/react-native-community/react-native-video/pull/1518) -- fullscreen rotation issues with iOS built-in controls [#1441](https://github.com/react-native-community/react-native-video/pull/1441) -- Fix player freeze when playing audio files on ExoPlayer [#1529](https://github.com/react-native-community/react-native-video/pull/1529) - -### Version 4.4.0 - -- Fix runtime warning by replacing `UIManager.RCTVideo` with `UIManager.getViewManagerConfig('RCTVideo')` (and ensuring backwards compat) [#1487](https://github.com/react-native-community/react-native-video/pull/1487) -- Fix loading package resolved videos when using video-caching [#1438](https://github.com/react-native-community/react-native-video/pull/1438) -- Fix "message sent to deallocated instance" crash on ios [#1482](https://github.com/react-native-community/react-native-video/pull/1482) -- Display a warning when source is empty [#1478](https://github.com/react-native-community/react-native-video/pull/1478) -- Don't crash on iOS for an empty source [#1246](https://github.com/react-native-community/react-native-video/pull/1246) -- Recover from from transient internet failures when loading on ExoPlayer [#1448](https://github.com/react-native-community/react-native-video/pull/1448) -- Add controls support for ExoPlayer [#1414](https://github.com/react-native-community/react-native-video/pull/1414) -- Fix check for text tracks when iOS caching enabled [#1387](https://github.com/react-native-community/react-native-video/pull/1387) -- Add support for Picture in Picture on iOS [#1325](https://github.com/react-native-community/react-native-video/pull/1325) -- Fix UIManager undefined variable [#1488](https://github.com/react-native-community/react-native-video/pull/1488) - -### Version 4.3.0 - -- Fix iOS video not displaying after switching source [#1395](https://github.com/react-native-community/react-native-video/pull/1395) -- Add the filterEnabled flag, fixes iOS video start time regression [#1384](https://github.com/react-native-community/react-native-video/pull/1384) -- Fix text not appearing in release builds of Android apps [#1373](https://github.com/react-native-community/react-native-video/pull/1373) -- Update to ExoPlayer 2.9.3 [#1406](https://github.com/react-native-community/react-native-video/pull/1406) -- Add video track selection & onBandwidthUpdate [#1199](https://github.com/react-native-community/react-native-video/pull/1199) -- Recovery from transient internet failures and props to configure the custom retry count [#1448](https://github.com/react-native-community/react-native-video/pull/1448) - -### Version 4.2.0 - -- Don't initialize filters on iOS unless a filter is set. This was causing a startup performance regression [#1360](https://github.com/react-native-community/react-native-video/pull/1360) -- Support setting the maxBitRate [#1310](https://github.com/react-native-community/react-native-video/pull/1310) -- Fix useTextureView not defaulting to true [#1383](https://github.com/react-native-community/react-native-video/pull/1383) -- Fix crash on MediaPlayer w/ Android 4.4 & avoid memory leak [#1328](https://github.com/react-native-community/react-native-video/pull/1328) - -### Version 4.1.0 - -- Generate onSeek on Android ExoPlayer & MediaPlayer after seek completes [#1351](https://github.com/react-native-community/react-native-video/pull/1351) -- Remove unneeded onVideoSaved event [#1350](https://github.com/react-native-community/react-native-video/pull/1350) -- Disable AirPlay if sidecar text tracks are enabled [#1304](https://github.com/react-native-community/react-native-video/pull/1304) -- Add possibility to remove black screen while video is loading in Exoplayer [#1355](https://github.com/react-native-community/react-native-video/pull/1355) - -### Version 4.0.1 - -- Add missing files to package.json [#1342](https://github.com/react-native-community/react-native-video/pull/1342) - -### Version 4.0.0 - -- Partial support for timed metadata on Android MediaPlayer [#707](https://github.com/react-native-community/react-native-video/pull/707) -- Support video caching for iOS [#955](https://github.com/react-native-community/react-native-video/pull/955) -- Video caching cleanups [#1172](https://github.com/react-native-community/react-native-video/pull/1172) -- Add ipod-library support [#926](https://github.com/react-native-community/react-native-video/pull/926/files) -- Fix crash on ExoPlayer when there are no audio tracks [#1233](https://github.com/react-native-community/react-native-video/pull/1233) -- Reduce package size [#1231](https://github.com/react-native-community/react-native-video/pull/1231) -- Remove unnecessary import in TextTrackType [#1229](https://github.com/react-native-community/react-native-video/pull/1229) -- Prevent flash between poster and video [#1167](https://github.com/react-native-community/react-native-video/pull/1167) -- Support react-native-dom [#1253](https://github.com/react-native-community/react-native-video/pull/1253) -- Update to ExoPlayer 2.8.2. Android SDK 26 now required [#1170](https://github.com/react-native-community/react-native-video/pull/1170) -- Update to ExoPlayer 2.8.4 [#1266](https://github.com/react-native-community/react-native-video/pull/1266) -- Add fullscreenOrientation option for iOS [#1215](https://github.com/react-native-community/react-native-video/pull/1215) -- Update to ExoPlayer 2.9.0 [#1285](https://github.com/react-native-community/react-native-video/pull/1285) -- Switch useTextureView to default to `true` [#1286](https://github.com/react-native-community/react-native-video/pull/1286) -- Re-add fullscreenAutorotate prop [#1303](https://github.com/react-native-community/react-native-video/pull/1303) -- Make seek throw a useful error for NaN values [#1283](https://github.com/react-native-community/react-native-video/pull/1283) -- Video Filters and Save Video [#1306](https://github.com/react-native-community/react-native-video/pull/1306) -- Fix: volume should not change on onAudioFocusChange event [#1327](https://github.com/react-native-community/react-native-video/pull/1327) -- Update ExoPlayer to 2.9.1 and OkHTTP to 3.12.0 [#1338](https://github.com/react-native-community/react-native-video/pull/1338) - -### Version 3.2.0 - -- Basic fullscreen support for Android MediaPlayer [#1138](https://github.com/react-native-community/react-native-video/pull/1138) -- Simplify default Android SDK code [#1145](https://github.com/react-native-community/react-native-video/pull/1145) [#1146](https://github.com/react-native-community/react-native-video/pull/1146) -- Various iOS sideloaded text track fixes [#1157](https://github.com/react-native-community/react-native-video/pull/1157) -- Fix #1150 where assets with bundled assets don't work on iOS in release mode [#1162](https://github.com/react-native-community/react-native-video/pull/1162) -- Support configuring the buffer on Android ExoPlayer [#1160](https://github.com/react-native-community/react-native-video/pull/1160) -- Prevent sleep from sleeping while videos are playing on Android MediaPlayer [#1117](https://github.com/react-native-community/react-native-video/pull/1117) -- Update NewtonSoft JSON to match react-native-windows version [#1169](https://github.com/react-native-community/react-native-video/pull/1169) - -### Version 3.1.0 - -- Support sidecar text tracks on iOS [#1109](https://github.com/react-native-community/react-native-video/pull/1109) -- Support onAudioBecomingNoisy on iOS [#1131](https://github.com/react-native-community/react-native-video/pull/1131) - -### Version 3.0 - -- Inherit Android buildtools and SDK version from the root project [#1081](https://github.com/react-native-community/react-native-video/pull/1081) -- Automatically play on ExoPlayer when the paused prop is not set [#1083](https://github.com/react-native-community/react-native-video/pull/1083) -- Preserve Android MediaPlayer paused prop when backgrounding [#1082](https://github.com/react-native-community/react-native-video/pull/1082) -- Support specifying headers on ExoPlayer as part of the source [#805](https://github.com/react-native-community/react-native-video/pull/805) -- Prevent iOS onLoad event during seeking [#1088](https://github.com/react-native-community/react-native-video/pull/1088) -- ExoPlayer playableDuration incorrect [#1089](https://github.com/react-native-community/react-native-video/pull/1089) - -### Version 2.3.1 - -- Revert PR to inherit Android SDK versions from root project. Re-add in 3.0 [#1080](https://github.com/react-native-community/react-native-video/pull/1080) - -### Version 2.3.0 - -- Support allowsExternalPlayback on iOS [#1057](https://github.com/react-native-community/react-native-video/pull/1057) -- Inherit Android buildtools and SDK version from the root project [#999](https://github.com/react-native-community/react-native-video/pull/999) -- Fix bug that caused ExoPlayer to start paused if playInBackground was set [#833](https://github.com/react-native-community/react-native-video/pull/833) -- Fix crash if clearing an observer on iOS that was already cleared [#1075](https://github.com/react-native-community/react-native-video/pull/1075) -- Add audioOnly prop for music files [#1039](https://github.com/react-native-community/react-native-video/pull/1039) -- Support seeking with more exact tolerance on iOS [#1076](https://github.com/react-native-community/react-native-video/pull/1076) - -### Version 2.2.0 - -- Text track selection support for iOS & ExoPlayer [#1049](https://github.com/react-native-community/react-native-video/pull/1049) -- Support outputting to a TextureView on Android ExoPlayer [#1058](https://github.com/react-native-community/react-native-video/pull/1058) -- Support changing the left/right balance on Android MediaPlayer [#1051](https://github.com/react-native-community/react-native-video/pull/1051) -- Prevent multiple onEnd notifications on iOS [#832](https://github.com/react-native-community/react-native-video/pull/832) -- Fix doing a partial swipe on iOS causing a black screen [#1048](https://github.com/react-native-community/react-native-video/pull/1048) -- Fix crash when switching to a new source on iOS [#974](https://github.com/react-native-community/react-native-video/pull/974) -- 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) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000..45d257b29a --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,133 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +[INSERT CONTACT METHOD]. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..dff0109c9e --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,120 @@ +# Contributing + +Contributions are always welcome, no matter how large or small! + +We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project. Before contributing, please read the [code of conduct](./CODE_OF_CONDUCT.md). + +## Development workflow + +This project is a monorepo managed using [Bun workspaces](https://bun.sh/docs/install/workspaces). It contains the following packages: + +- An Library package in the `packages/react-native-video` directory. +- An example app in the `example/` directory. + +To get started with the project, run `bun install` in the root directory to install the required dependencies for each package: + +```sh +bun install +``` + +> Since the project relies on Bun workspaces, you cannot use [`npm`](https://github.com/npm/cli) or [`yarn`](https://yarnpkg.com/) for development. + +The [example app](/example/) demonstrates usage of the library. You need to run it to test any changes you make. + +It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app. + +If you want to use Android Studio or XCode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/VideoExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-video`. + +To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `react-native-video` under `Android`. + +You can use various commands from the root directory to work with the project. + +To start the packager: + +```sh +bun example start +``` + +To run the example app on Android: + +```sh +bun example android +``` + +To run the example app on iOS: + +```sh +bun example ios +``` + +Make sure your code passes TypeScript and ESLint. Run the following to verify: + +```sh +bun typecheck +bun lint +``` + +To fix formatting errors, run the following: + +```sh +bun lint --fix +``` + +### Commit message convention + +We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages: + +- `fix`: bug fixes, e.g. fix crash due to deprecated method. +- `feat`: new features, e.g. add new method to the module. +- `refactor`: code refactor, e.g. migrate from class components to hooks. +- `docs`: changes into documentation, e.g. add usage example for the module.. +- `test`: adding or updating tests, e.g. add integration tests using detox. +- `chore`: tooling changes, e.g. change CI config. + +Our pre-commit hooks verify that your commit message matches this format when committing. + +### Linting and tests + +[ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/) + +We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing. + +Our pre-commit hooks verify that the linter and tests pass when committing. + +### Publishing to npm + +We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc. + +To publish new versions, run the following: + +```sh +bun release +``` + +### Scripts + +The `package.json` file contains various scripts for common tasks: + +- `bun install`: setup project by installing dependencies. +- `bun typecheck`: type-check files with TypeScript. +- `bun lint`: lint files with ESLint. +- `bun example start`: start the Metro server for the example app. +- `bun example android`: run the example app on Android. +- `bun example ios`: run the example app on iOS. + +### Sending a pull request + +> **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github). + +When you're sending a pull request: + +- Prefer small pull requests focused on one change. +- Verify that linters and tests are passing. +- Review the documentation to make sure it looks good. +- If your change affects how the library is **used** (API, props, events, or behavior), update the AI agent skill in `skills/react-native-video/` to match — keep it in sync just like the docs. +- Follow the pull request template when opening a pull request. +- For pull requests that change the API or implementation, discuss with maintainers first by opening an issue. + +### License + +By contributing to this project, you agree that your contributions will be licensed under the [MIT License](LICENSE). diff --git a/DRM.md b/DRM.md deleted file mode 100644 index d0ce88bf22..0000000000 --- a/DRM.md +++ /dev/null @@ -1,139 +0,0 @@ -# DRM - -## Provide DRM data (only tested with http/https assets) - -You can provide some configuration to allow DRM playback. -This feature will disable the use of `TextureView` on Android. - -DRM object allows this members: - -| Property | Type | Default | Platform | Description | -| --- | --- | --- | --- | --- | -| [`type`](#type) | DRMType | undefined | iOS/Android | Specifies which type of DRM you are going to use, DRMType is an enum exposed on the JS module ('fairplay', 'playready', ...) | -| [`licenseServer`](#licenseserver) | string | undefined | iOS/Android | Specifies the license server URL | -| [`headers`](#headers) | Object | undefined | iOS/Android | Specifies the headers send to the license server URL on license acquisition | -| [`contentId`](#contentid) | string | undefined | iOS | Specify the content id of the stream, otherwise it will take the host value from `loadingRequest.request.URL.host` (f.e: `skd://testAsset` -> will take `testAsset`) | -| [`certificateUrl`](#certificateurl) | string | undefined | iOS | Specifies the url to obtain your ios certificate for fairplay, Url to the .cer file | -| [`base64Certificate`](#base64certificate) | bool | false | iOS | Specifies whether or not the certificate returned by the `certificateUrl` is on base64 | -| [`getLicense`](#getlicense)| function | undefined | iOS | Rather than setting the `licenseServer` url to get the license, you can manually get the license on the JS part, and send the result to the native part to configure FairplayDRM for the stream | - -### `base64Certificate` - -Whether or not the certificate url returns it on base64. - -Platforms: iOS - -### `certificateUrl` - -URL to fetch a valid certificate for FairPlay. - -Platforms: iOS - -### `getLicense` - -`licenseServer` and `headers` will be ignored. You will obtain as argument the `SPC` (as ASCII string, you will probably need to convert it to base 64) obtained from your `contentId` + the provided certificate via `[loadingRequest streamingContentKeyRequestDataForApp:certificateData contentIdentifier:contentIdData options:nil error:&spcError];`. - You should return on this method a `CKC` in Base64, either by just returning it or returning a `Promise` that resolves with the `CKC`. - -With this prop you can override the license acquisition flow, as an example: - -```js -getLicense: (spcString) => { - const base64spc = Base64.encode(spcString); - const formData = new FormData(); - formData.append('spc', base64spc); - return fetch(`https://license.pallycon.com/ri/licenseManager.do`, { - method: 'POST', - headers: { - 'pallycon-customdata-v2': 'd2VpcmRiYXNlNjRzdHJpbmcgOlAgRGFuaWVsIE1hcmnxbyB3YXMgaGVyZQ==', - 'Content-Type': 'application/x-www-form-urlencoded', - }, - body: formData - }).then(response => response.text()).then((response) => { - return response; - }).catch((error) => { - console.error('Error', error); - }); -} -``` - -Platforms: iOS - -### `headers` - -You can customize headers send to the licenseServer. - -Example: - -```js -source={{ - uri: 'https://media.axprod.net/TestVectors/v7-MultiDRM-SingleKey/Manifest_1080p.mpd', -}} -drm={{ - type: DRMType.WIDEVINE, - licenseServer: 'https://drm-widevine-licensing.axtest.net/AcquireLicense', - headers: { - 'X-AxDRM-Message': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2ZXJzaW9uIjoxLCJjb21fa2V5X2lkIjoiYjMzNjRlYjUtNTFmNi00YWUzLThjOTgtMzNjZWQ1ZTMxYzc4IiwibWVzc2FnZSI6eyJ0eXBlIjoiZW50aXRsZW1lbnRfbWVzc2FnZSIsImZpcnN0X3BsYXlfZXhwaXJhdGlvbiI6NjAsInBsYXlyZWFkeSI6eyJyZWFsX3RpbWVfZXhwaXJhdGlvbiI6dHJ1ZX0sImtleXMiOlt7ImlkIjoiOWViNDA1MGQtZTQ0Yi00ODAyLTkzMmUtMjdkNzUwODNlMjY2IiwiZW5jcnlwdGVkX2tleSI6ImxLM09qSExZVzI0Y3Iya3RSNzRmbnc9PSJ9XX19.FAbIiPxX8BHi9RwfzD7Yn-wugU19ghrkBFKsaCPrZmU' - }, -}} -``` - -### `licenseServer` - -The URL pointing to the licenseServer that will provide the authorization to play the protected stream. - -### `type` - -You can specify the DRM type, either by string or using the exported DRMType enum. -Valid values are, for Android: DRMType.WIDEVINE / DRMType.PLAYREADY / DRMType.CLEARKEY. -for iOS: DRMType.FAIRPLAY - -## Common Usage Scenarios - -### Send cookies to license server - -You can send Cookies to the license server via `headers` prop. Example: - -```js -drm: { - type: DRMType.WIDEVINE - licenseServer: 'https://drm-widevine-licensing.axtest.net/AcquireLicense', - headers: { - 'Cookie': 'PHPSESSID=etcetc; csrftoken=mytoken; _gat=1; foo=bar' - }, -} -``` - -### Custom License Acquisition (only iOS for now) - -```js -drm: { - type: DRMType.FAIRPLAY, - getLicense: (spcString) => { - const base64spc = Base64.encode(spcString); - return fetch('YOUR LICENSE SERVER HERE', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - body: JSON.stringify({ - getFairplayLicense: { - foo: 'bar', - spcMessage: base64spc, - } - }) - }) - .then(response => response.json()) - .then((response) => { - if (response && response.getFairplayLicenseResponse - && response.getFairplayLicenseResponse.ckcResponse) { - return response.getFairplayLicenseResponse.ckcResponse; - } - throw new Error('No correct response'); - }) - .catch((error) => { - console.error('CKC error', error); - }); - } -} -``` diff --git a/DRMType.js b/DRMType.js deleted file mode 100644 index 473536b249..0000000000 --- a/DRMType.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - WIDEVINE: 'widevine', - PLAYREADY: 'playready', - CLEARKEY: 'clearkey', - FAIRPLAY: 'fairplay' -}; diff --git a/FilterType.js b/FilterType.js deleted file mode 100644 index 3d8d9cb40c..0000000000 --- a/FilterType.js +++ /dev/null @@ -1,18 +0,0 @@ -export default { - NONE: '', - INVERT: 'CIColorInvert', - MONOCHROME: 'CIColorMonochrome', - POSTERIZE: 'CIColorPosterize', - FALSE: 'CIFalseColor', - MAXIMUMCOMPONENT: 'CIMaximumComponent', - MINIMUMCOMPONENT: 'CIMinimumComponent', - CHROME: 'CIPhotoEffectChrome', - FADE: 'CIPhotoEffectFade', - INSTANT: 'CIPhotoEffectInstant', - MONO: 'CIPhotoEffectMono', - NOIR: 'CIPhotoEffectNoir', - PROCESS: 'CIPhotoEffectProcess', - TONAL: 'CIPhotoEffectTonal', - TRANSFER: 'CIPhotoEffectTransfer', - SEPIA: 'CISepiaTone', -}; diff --git a/LICENSE b/LICENSE index dc7f43c835..cdc2e44103 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,6 @@ MIT License -Copyright (c) 2016 Brent Vatne, Baris Sencan - +Copyright (c) 2024-present TheWidlarzGroup Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights diff --git a/README.md b/README.md index 1b6a913ec3..bc425eb7a1 100644 --- a/README.md +++ b/README.md @@ -1,1468 +1,165 @@ -## react-native-video +[![React Native Video Component](./docs/static/banners/rnv-banner.png)](https://sdk.thewidlarzgroup.com/?utm_source=rnv&utm_medium=readme&utm_id=banner) -A `