videoView视频未在片段内播放

时间:2018-06-28 00:25:54

标签: android android-fragments android-videoview drm

我正在尝试让视频在片段中播放,但无法播放。除了“文件不是扩展名不是DRM”之外,我没有收到任何其他错误。不确定这是否是视频无法开始的原因

public class HomeFragment extends Fragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.home_page, container, false);
    videoPlay(rootView);

    return inflater.inflate(R.layout.home_page, container, false);

}

public void videoPlay(View rootView){
    MediaController mc = new MediaController(getActivity());
    VideoView videoView = (VideoView)rootView.findViewById(R.id.videoView);
    String videoPath = "android.resource://" + getActivity().getPackageName() + "/" + R.raw.ds;
    videoView.setVideoURI(Uri.parse(videoPath));
    videoView.setMediaController(mc);
    videoView.start();
    Log.i("myTag", "chicken");

}

}

0 个答案:

没有答案