Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix - Webcam not showed on iOS devices and Open URL not work #66

Merged
merged 5 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 3 additions & 1 deletion client/src/characters/MyPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { pushPlayerJoinedMessage } from '../stores/ChatStore'
import { ItemType } from '../../../types/Items'
import { NavKeys } from '../../../types/KeyboardState'
import { JoystickMovement } from '../components/Joystick'
import { openURL } from '../utils'

export default class MyPlayer extends Player {
private playContainerBody: Phaser.Physics.Arcade.Body
Expand Down Expand Up @@ -70,7 +71,8 @@ export default class MyPlayer extends Player {
break
case ItemType.VENDINGMACHINE:
// hacky and hard-coded, but leaving it as is for now
window.open('https://www.buymeacoffee.com/skyoffice', '_blank')
const url = 'https://www.buymeacoffee.com/skyoffice'
openURL(url)
break
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/scenes/Game.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Phaser from 'phaser'

// import { debugDraw } from '../utils/debug'
// import { debugDraw } from '../utils'
import { createCharacterAnims } from '../anims/CharacterAnims'

import Item from '../items/Item'
Expand Down
11 changes: 11 additions & 0 deletions client/src/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export function openURL(url: string) {
const canOpenNewTab = window.open(url, '_blank')

// if the browser blocks the new tab, open the url in the current tab
// this is the case for Safari on iOS
if (!canOpenNewTab) {
let a = document.createElement('a')
a.href = url
a.click()
kevinshen56714 marked this conversation as resolved.
Show resolved Hide resolved
}
}
2 changes: 2 additions & 0 deletions client/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './debug'
export * from './helpers'
kevinshen56714 marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions client/src/web/WebRTC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export default class WebRTC {
// method to add new video stream to videoGrid div
addVideoStream(video: HTMLVideoElement, stream: MediaStream) {
video.srcObject = stream
video.playsInline = true
kevinshen56714 marked this conversation as resolved.
Show resolved Hide resolved
video.addEventListener('loadedmetadata', () => {
video.play()
})
Expand Down