ios - 於 Android 手提電話使用 Meteor 應用程式播放影片
天蓬老师
天蓬老师 2017-04-18 09:27:08
0
1
283

根據另一個程式,我製作了一段影片,並使他成功地於IOS運行。
以下是編程參考。

var xhr = new XMLHttpRequest();

xhr.open("get", "/video/justForTest.mp4");
xhr.responseType = "arraybuffer";

xhr.addEventListener("load", function() {
  var arrayBufferView = new Uint8Array(this.response);
  var blob = new Blob([arrayBufferView], {type: "video/mp4"});
  var url = window.URL.createObjectURL(blob);

  document.getElementById("mobileAppVideo").src = url;
});

xhr.send();

此段代碼來源於以下網址
(https://github.com/meteor/met...

我根據以上代碼,成功在 IOS 播放了 mp4 影片。但我不知道如何在 Android 手機應用程式播放影片。請問有人知道一個成功在 Android 手機應用程式內播放 mp4 影片嗎?懇請大家指點。

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(1)
黄舟

The easiest way is to use the VideoView control provided by Android
Use the following two methods to play videos:
setVidePath(String path): load the video represented by the path file
setVideoURI(Uri uri): load the video corresponding to the uri

You can also use SurfaceView combined with MediaPlayer to play videos. You can google the code yourself

There is an open source player from Google on github named hExoPlayer

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!