Git Product home page Git Product logo

android-vedio-upload-and-download's Introduction

android-vedio-upload-and-download

安卓视频上传与下载 核心代码:

               if (localUrl == null) {
		localUrl = Environment.getExternalStorageDirectory()
			.getAbsolutePath()
			+ "/VideoCache/"
			+ System.currentTimeMillis() + ".mp4";
			}
			Log.d("localUrl: " , localUrl);
			File cacheFile = new File(localUrl);
			if (!cacheFile.exists()) {
				cacheFile.getParentFile().mkdirs();
			       	try {
					cacheFile.createNewFile();
			       	} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			readSize = cacheFile.length();
			try {
			out = new FileOutputStream(cacheFile, true);
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			if (mediaLength == -1) {
				return;
			}
			mHandler.sendEmptyMessage(VIDEO_STATE_UPDATE);
	            try {
	            while ((len = inputStream.read(buffer)) != -1) {
	                // 处理下载的数据
	            	try{
						out.write(buffer, 0, len);
						readSize += len;
	               } catch (Exception e) {
					e.printStackTrace();
				}
				
				
				
				if(cachepercent==100.0||cachepercent==100.00){
				mVideoView.setVideoPath(localUrl);
				mVideoView.start();
				String s1 = String.format("已缓存: [%.2f%%]", cachepercent);
				tvcache.setText(s1);
				return;

android-vedio-upload-and-download's People

Contributors

qht1003077897 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.