Skip to content

Commit

Permalink
Persistent Playlist (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared Kotoff authored Nov 23, 2021
1 parent dbc7754 commit 13cd9f2
Show file tree
Hide file tree
Showing 9 changed files with 237 additions and 109 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,22 @@ jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Set up Go
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
-
name: Cache Go modules
- name: Cache Go modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
-
name: Run GoReleaser
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
if: startsWith(github.ref, 'refs/tags/')
with:
Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@ name: Mark stale issues and pull requests

on:
schedule:
- cron: "30 1 * * *"
- cron: '30 1 * * *'

jobs:
stale:

runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write

steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Closing due to staleness'
stale-pr-message: 'Closing due to staleness'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Closing due to staleness'
stale-pr-message: 'Closing due to staleness'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'
8 changes: 3 additions & 5 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
builds:
-
goos:
- goos:
- windows
- darwin
- linux
goarch:
- amd64
archives:
-
replacements:
- replacements:
amd64: 64-bit
386: 32-bit
darwin: macos
Expand All @@ -20,4 +18,4 @@ archives:
- LICENSE*
- LICENCE*
- README*
- CHANGELOG*
- CHANGELOG*
9 changes: 6 additions & 3 deletions FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# These are supported funding model platforms

custom:
[
'https://www.twitch.tv/subs/updownleftdie',
'https://www.guilded.gg/UpDownLeftDie/subscriptions?r=Vmy2GNwA',
'https://www.paypal.me/jaredkotoff',
]
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: updownleftdie
open_collective: # Replace with a single Open Collective username
Expand All @@ -9,5 +14,3 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom:
["https://www.paypal.me/jaredkotoff", "https://www.twitch.tv/subs/updownleftdie", "https://www.guilded.gg/UpDownLeftDie/subscriptions?r=Vmy2GNwA"]
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Play videos in random order!

*Perfect for BRB screens!*
_Perfect for BRB screens!_

## [Download](https://github.com/UpDownLeftDie/obs-random-videos/releases/latest)

Expand All @@ -23,32 +23,32 @@ Play videos in random order!

#### Video

* mp4
* m4v
* webm
* mpeg4
- mp4
- m4v
- webm
- mpeg4

#### Audio

* mp3
* ogg
* aac
- mp3
- ogg
- aac

## Notes

* Set `Refresh browser when scene becomes active` to randomize on each load
* Video resolutions should match your canvas aspect ratio
* **Autoplay only works in OBS!**
* If you want to test this in your browser:
- Set `Refresh browser when scene becomes active`
- Video resolutions should match your canvas aspect ratio
- **Autoplay only works in OBS!**
- If you want to test this in your browser:
1. Open the `obs-random-videos.html` with your browser
2. Right-click on the image and click "Show controls"
3. Hit the play button
* Pro tip: webm videos support transparency (convert mov to webm to save on file size)
- Pro tip: webm videos support transparency (convert mov to webm to save on file size)

## TODO

* Audio-only or video-only modes
* Option for cross-fading between videos
* Option to HTML background color
* Good for videos with weird aspect ratio
* Good for audio files
- Audio-only or video-only modes
- Option for cross-fading between videos
- Option to HTML background color
- Good for videos with weird aspect ratio
- Good for audio files
12 changes: 8 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
module github.com/UpDownLeftDie/obs-random-videos/v2

go 1.16
go 1.17

require github.com/sparkdemcisin81/promptui v1.0.0

require (
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
github.com/juju/ansiterm v0.0.0-20210929141451-8b71cc96ebdc // indirect
github.com/lunixbochs/vtclean v1.0.0 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/sparkdemcisin81/promptui v1.0.0
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 // indirect
github.com/mattn/go-colorable v0.1.11 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359 // indirect
)
23 changes: 15 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,35 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5O
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a h1:FaWFmfWdAUKbSCtOU2QjDaorUexogfaMgbipgYATUMU=
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a/go.mod h1:UJSiEoRfvx3hP73CvoARgeLjaIOjybY9vj8PUPPFGeU=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/juju/ansiterm v0.0.0-20210929141451-8b71cc96ebdc h1:ZQrgZFsLzkw7o3CoDzsfBhx0bf/1rVBXrLy8dXKRe8o=
github.com/juju/ansiterm v0.0.0-20210929141451-8b71cc96ebdc/go.mod h1:PyXUpnI3olx3bsPcHt98FGPX/KCFZ1Fi+hw1XLI6384=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
github.com/lunixbochs/vtclean v1.0.0 h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+LVb8=
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.10/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs=
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/sparkdemcisin81/promptui v1.0.0 h1:GGK4vlIZP36dyM1PgKH0utVkk13kDUqOS5sy6XqeU6I=
github.com/sparkdemcisin81/promptui v1.0.0/go.mod h1:RpZAFCsCFF7OVe+B1Pc4gEA1OAW0n7uQq43ck3rPpNk=
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 h1:hZR0X1kPW+nwyJ9xRxqZk1vx5RUObAPBdKVvXPDUH/E=
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359 h1:2B5p2L5IfGiD7+b9BOoRMC6DgObAVZV+Fsp050NqXik=
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
53 changes: 40 additions & 13 deletions js/body.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,44 @@
const player = document.getElementById("videoPlayer1");
const player2 = document.getElementById("videoPlayer2");
player.addEventListener("ended", () => playNext(player2, player), {passive: true});
player2.addEventListener("ended", () => playNext(player, player2), {passive: true});
// @ts-check
const player = /** @type {HTMLMediaElement} */ (
document.getElementById('videoPlayer1')
);

/* Initial logic */
const player2 = /** @type {HTMLMediaElement} */ (
document.getElementById('videoPlayer2')
);
player.addEventListener(
'ended',
() => {
if (!loopFirstVideo) {
progressPlaylistState();
}
playNext(player2, player);
},
{
passive: true,
},
);
player2.addEventListener(
'ended',
() => {
if (!loopFirstVideo) {
progressPlaylistState();
}
playNext(player, player2);
},
{
passive: true,
},
);

const mp4Source = player.getElementsByClassName("mp4Source")[0];
let video = `${mediaFolder}${mediaFiles[0]}`;
// check if we played this video last run
if (mediaFiles.length > 1 && localStorage.getItem("lastPlayed") === video) {
video = `${mediaFolder}${mediaFiles[1]}`;
}
mp4Source.setAttribute("src", video);
/***** Initial load *****/

const mp4Source = player.getElementsByClassName('mp4Source')[0];
let video = getNextPlaylistItem();
// have to move the state forward after getting the first video
progressPlaylistState();

mp4Source.setAttribute('src', video);
player.load();

playNext(player, player2);
playNext(player, player2);
Loading

0 comments on commit 13cd9f2

Please sign in to comment.