我有一个应用程序可以将.s4格式的短10s视频上传到Parse Server。视频正在保存为文件对象。
我想在Android VideoView中播放该视频,我设置了视频视图,并希望setVideoURI指向保存在Parse Server视频类中的视频。视频播放器加载但视频从不播放。这就是我的样子 -
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Videos"); //"Videos" is the class
query.whereEqualTo("username", activeUserName); //active user has video in Parse
query.orderByDescending("createdAt");
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> objects, ParseException e) {
if (e == null) {
if (objects.size() > 0) {
for (ParseObject object : objects) {
final ParseFile file = (ParseFile) object.get("VideoName"); //"VideoName" is where the mp4 file is stored
file.getDataInBackground(new GetDataCallback() {
@Override
public void done(byte[] data, ParseException e) {
if (e == null && data != null) {
VideoView videoView = (VideoView)findViewById(R.id.videoView);
//This may be wrong
videoView.setVideoURI(Uri.parse("VideoName"));
MediaController mediaController = new MediaController(VideoFeedActivity.this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
videoView.start();