Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
#If ignorance is bliss, then somebody knock the smile off my face

*.csproj.user
*.suo
*.cache
# macOS
.DS_Store
Thumbs.db
*.DS_Store

# Editor swap/backup files
*.bak
*.cache
*.log
*.swp
*.user

# JetBrains IDEs
.idea/

# Visual Studio
*.suo
*.user
*.csproj.user

# Android build output
build/
*.apk
*.aab

# Android local config (contains machine-specific SDK path)
local.properties

# Gradle caches and wrapper downloads
.gradle/

# Node / npm (for Cordova tooling)
node_modules/
34 changes: 29 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
Video Player plugin for Cordova/PhoneGap
========================================

A Cordova plugin that simply allows you to immediately play a video in fullscreen mode.
A Cordova plugin that allows you to immediately play a video in fullscreen mode.

> **Platform support:** Android only.

# Installation

This plugin use the Cordova CLI's plugin command. To install it to your application, simply execute the following (and replace variables).
# Installation

```
cordova plugin add cordova-plugin-video-player
```

## Permissions

To play videos from device storage, your app must declare the appropriate storage/media permission in its `AndroidManifest.xml` and request it at runtime on Android 6.0+ (API 23+):

- On **Android 12L and below** (API 23–32), use `READ_EXTERNAL_STORAGE`.
- On **Android 13+** (API 33+), use `READ_MEDIA_VIDEO` for video files.

A typical manifest might include:

```xml
<!-- For API 23–32 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- For API 33+ -->
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
```

HTTP/HTTPS and bundled asset videos (`file:///android_asset/`) do not require these permissions.

> **Note:** On Android 10+ (API 29+), scoped storage can affect direct file-path access on external storage. Prefer using `content://` URIs from `MediaStore` where possible.


# Using

Expand Down Expand Up @@ -70,9 +90,13 @@ VideoPlayer.play(

# Troubleshooting

**When playing a video for the first time, everything works great. when calling .close() function the video closes great. 2nd time around, the .play() is called the same way as the first time. The video plays fine for the second time. Now when trying to close it before the video ends, the app fatally crash.**
**Videos played from device storage fail silently or crash.**

Ensure your app has declared and requested the correct permission at runtime:
- `READ_EXTERNAL_STORAGE` on Android 6.0–12L (API 23–32)
- `READ_MEDIA_VIDEO` on Android 13+ (API 33+)

When the "completed" event gets fired, make sure you close the video in the "completed" event to clear that instance so that if you have another video they don't both play.
Without the appropriate permission, `setDataSource` will fail and the error callback will fire.


# Licence MIT
Expand Down
30 changes: 30 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Run unit tests
test:
cd tests/android && ./gradlew test

# Clean test build artifacts then run tests (forces full rebuild)
test-clean:
cd tests/android && ./gradlew clean test

# Clean test build artifacts only
clean:
cd tests/android && ./gradlew clean

# Open the HTML test report in the browser
report: test
open tests/android/build/reports/tests/testDebugUnitTest/index.html

# Run Android lint on the test module
lint:
cd tests/android && ./gradlew lint

# Run lint and tests — useful as a pre-commit/CI check
check: lint test

# List all resolved dependencies for the test module
deps:
cd tests/android && ./gradlew dependencies --configuration debugUnitTestRuntimeClasspath

# Validate plugin.xml is well-formed XML
validate:
xmllint --noout plugin.xml && echo "plugin.xml is valid"
14 changes: 3 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
{
"name": "cordova-plugin-video-player",
"version": "1.0.1",
"description": "A Codova plugin that simply allows you to immediately play a video in fullscreen mode.",
"description": "A Cordova plugin that simply allows you to immediately play a video in fullscreen mode.",
"cordova": {
"id": "cordova-plugin-video-player",
"platforms": [
"android",
"ios"
"android"
]
},
"engines": {
"cordovaDependencies": {
"2.0.0": {
"cordova": ">100"
}
}
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "cd tests/android && ./gradlew test"
Comment thread
MattyB95 marked this conversation as resolved.
},
"repository": {
"type": "git",
Expand Down
Loading