0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ReactPlayer+SafariでgetUserMediaするとReactPlayerで再生していた動画が再生される

0
Posted at

ReactPlayerでビデオを再生した後、
navigator.getUserMediaを実行すると、何故かReactPlayerで再生していたビデオが再生されます。
(iOS+Safariの場合のみ)
なお、通常のvideoタグ等による再生では発生しませんので、ReactPlayer限定の現象です。

対応策

ReactPlayerのproperty playingにfalseを渡す。
unmountされる前に、ReactPlayerのplayingにfalseを渡す必要があります。
仮にReactPlayerがunmountされても、画面がreloadされない限り何故か情報が残存し、getUserMediaを行ったタイミングで再生されてしまいます。

なお、playingをfalseにするためにReactPlayerを保持しているコンポーネントのcomponentWillMountを使ってもダメです。
componentWillMountが呼ばれた後にrenderが走らないためです。
Componentをunmountさせる処理の前に差し込みましょう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?