本文介绍了机器人,构造的MediaController()是未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Android应用程序,做工精细用片段,
I have an android app, working fine with fragments,
我需要从展示片段的视频,但为了做到这一点,我需要实例化的MediaController,
I need to show a video from a fragment, but in order to do this, I need to instantiate mediacontroller,
但我得到:
The constructor MediaController() is undefined
在这里我的code:
here my code:
package com.orchard.elasto.custom;
import com.egoclean.elasto.R;
import android.content.Context;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.VideoView;
//public class VideoView {
public class VideoViewBox extends Fragment{
// public MediaController mc;
private MediaController mediaController = new MediaController(this);
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//return inflater.inflate(R.layout.video_view, container,false);
View view = inflater.inflate(R.layout.video_view, container,false);
VideoView mVideo = (VideoView) view.findViewById(R.id.video_viewer);;
mediaController.setAnchorView(mVideo);
//Set video link (mp4 format )
// Uri video = Uri.parse("android.resource://com.egoclean.elasto/raw/shoulder");
Uri video = Uri.parse("android.resource://" + getClass().getPackage().getName() + "/" + R.raw.video1);
mVideo.setMediaController(mediaController);
mVideo.setVideoURI(video);
mVideo.start();
return view;
}
}
那么,
如何实例化我的媒体控制器?
so ,how to instantiate my media controller?
谢谢!
推荐答案
这样的事情,也许,
MediaController mediaController = new MediaController(getActivity().getApplicationContext());
这篇关于机器人,构造的MediaController()是未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!