1

嗨,我尝试在 videoview 中播放视频并播放视频,但 mediacontroller 无法在下面运行我的代码。我使用了片段。

public class ItemDetailFragment extends Fragment {

    public static final String ARG_ITEM_ID = "item_id";

    private DummyContent.DummyItem mItem;


    public ItemDetailFragment() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (getArguments().containsKey(ARG_ITEM_ID)) {
            // Load the dummy content specified by the fragment
            // arguments. In a real-world scenario, use a Loader
            // to load content from a content provider.
            mItem = DummyContent.ITEM_MAP.get(getArguments().getString(
                    ARG_ITEM_ID));
            Log.v("log_tag","mItem   ::; "+ mItem);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_item_detail,
                container, false);
        VideoView vcVideoView;
        // Show the dummy content as text in a TextView.
        if (mItem != null) {
            /*((TextView) rootView.findViewById(R.id.item_detail))
                    .setText(mItem.url);*/

            vcVideoView=((VideoView) rootView.findViewById(R.id.videoView));
        //  .setVideoPath(mItem.url);
            MediaController mc = new MediaController(this);
            //vcVideoView.setMediaController(new MediaController());
            //vcVideoView.setMediaController(mc);
            Uri uri = Uri.parse(mItem.url);
            vcVideoView.setVideoURI(uri);
            vcVideoView.setSoundEffectsEnabled(true);
            vcVideoView.requestFocus();
            vcVideoView.start();
        }

        return rootView;
    }
}

错误是The constructor MediaController(ItemDetailFragment) is undefined!!如何解决它。请帮助我!

4

0 回答 0