我有一个 android 应用程序,可以很好地处理片段,
我需要显示片段中的视频,但为了做到这一点,我需要实例化媒体控制器,
但我得到:
The constructor MediaController() is undefined
这是我的代码:
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;
}
}
那么,如何实例化我的媒体控制器?
谢谢!