In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how Android uses VideoView to play videos, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
Give Android VideoView a file directory and you can play video files directly from smart devices. Now take test.mp4, a video file that was shot and renamed with your phone beforehand, as an example.
(1) you need to write a ViedoView in the layout file:
(2) Don't forget to add permission to read and write external storage in the AndroidManifest.xml file:
(3) set the file directory for VideoView in the java code, and then play it on start:
Public class MainActivity extends Activity {@ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.activity_main); VideoView videoView = (VideoView) findViewById (R.id.videoView); / / the path obtained is equal to: / storage/emulated/0/DCIM File path = Environment .getExternalStoragePublicDirectory (Environment.DIRECTORY_DCIM) / / stitching the full path File f = new File (path, "/ Camera/test.mp4"); / / f.getAbsolutePath () = / storage/emulated/0/DCIM//\ Camera/test.mp4 videoView.setVideoPath (f.getAbsolutePath ()) at this time; / / starting video playback videoView.start (); / / VideiView gaining focus / / videoView.requestFocus () }} above is all the content of the article "how to play videos with Android using VideoView". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.