Help us understand the problem. What is going on with this article?

React Player でロード時に指定位置から動画or音声再生させる方法

More than 1 year has passed since last update.

ページロード時にYoutubeの ?t=
みたいな感じで、指定の秒数から再生を始めるページの実装を想定しています。

React Playerというわりと利用ダウンロード数が高いコンポーネント採用し動画再生の実装しています。

React Player内で用意されている
seekTo関数を使うことで指定位置から再生可能みたいです。。

seekTo=
適当なイベント発生時にseekTo(位置(秒指定))をよぶことでジャンプ可能なかんすう。

コンポーネント生成時かプロパティに突っ込む方法で模索

export class VideoQiitaPage extends Component<Props, State> {

    player: ReactPlayer | undefined;

    ref = (player:ReactPlayer) => {
        this.player = player;
        this.movePosition();
    }

    movePosition(position : number) { 
        let aaa: any = { type: 'seconds' };
        if (this.player){
            this.player.seekTo(position); 
        }
    }

    render() {
        return (
            <React.Fragment>
            <ReactPlayer
                ref={this.ref}
                url={'http://xn--hhro09bn9j8uh.com/movie/94neco/neco02_720.mp4'}
                controls
                />

むつかしいことではないですが、、、
サンプルや詳細をTypeScriptで説明しているサイトやドキュメントなく嵌りました。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした