How to add video playback and resource to android application

后端 未结 2 599
别跟我提以往
别跟我提以往 2021-02-05 23:56

I have got problem with my idea on andriod app. I\'d like to play video in it, but I don\'t want to download it from interenet. In other case, I want to have it on device.

相关标签:
2条回答
  • 2021-02-06 00:25
    videoView = (VideoView) findViewById(R.id.videoview);
    
    videoview.setVideoPath("android.resource://" getPackageName() + "/" + R.raw.nameofvideofile);
    
    videoView.start();
    
    0 讨论(0)
  • 2021-02-06 00:32

    You can put a video into app resources - just put it into res/raw folder. You can play it like this:

    VideoView videoview = (VideoView) findViewById(R.id.videoview);
    
    Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.splash);
    
    videoview.setVideoURI(uri);
    videoview.start();
    

    The main thing to consider here is the size of your video. As video files can be quite large, your resulting apk file can also get unacceptably large. Personally, I would rarely want to download an app from the market that weighs in at 10 meg (there are exceptions, of course).

    0 讨论(0)
提交回复
热议问题