2
2

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.

PhoneGap Androidアプリ html5 videoタグで動画再生

Last updated at Posted at 2014-11-27

##概要
PhoneGap で Android アプリを書き出すと、ローカルにある動画ファイルを video タグで再生しようとしても、再生できません。
プラグイン等を使わず、video タグで再生させる方法です。

(ざっくりと文字だけ説明です。分かりづらければコメントいただければ改善します。)

##前提
video タグを使って html 単体であれば動画再生できる状態のソースがある前提です。

html
<video src="mymovie.mp4" controls></video>

##ファイルの移動
html ファイルと同じフォルダにある動画ファイル mymovie.mp4 を
platforms\android\res\raw
フォルダに移動します。

platforms\android フォルダがない場合は、一度 Android 用にビルドすれば生成されます。
platforms\android\res\raw フォルダは最初ないので、フォルダを作成します。

##コード書き換え
html を以下のように書き換えます。

html
<video src="android.resource://com.phonegap.helloworld/raw/mymovie" controls></video>

com.phonegap.helloworld 部分は、アプリIDです。

これで再生できました。

注:
・拡張子をつけないこと!
・raw フォルダに入れること!(勝手な名前つけない)
・ファイル名に使えるのは、小文字アルファベットと数字。

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?