video gets stored in parse.
public void uvideo(View v) throws FileNotFoundException, IOException
{
File f = new File("/sdcard/Sample.3gp");
byte[] videoUp=new byte[576600];
videoUp = IOUtils.toByteArray( new FileInputStream(f));
files = new ParseFile("testVideo1", videoUp);
files.saveInBackground(new SaveCallback() {
public void done(ParseException e) {
if(e==null) {
// SUCCESS!!!
} else {
e.printStackTrace();
}
}
}, new ProgressCallback() {
public void done(Integer percentDone) {
System.out.println("Progress :" + percentDone);
}
});
}
// this code doesnt't work
public void recievev(View c)
{
jobApplications = new ParseObject("Testvideo");
jobApplications.put("applicantName", "Joe Smith");
jobApplications.put("applicantResumevideo", files);
jobApplications.saveInBackground();
ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();
// If you would like all objects to be private by default, remove this line.
defaultACL.setPublicReadAccess(true);
ParseACL.setDefaultACL(defaultACL, true);
}
// this code doesnt't work
public void rvideo(View c)
{
ParseFile applicantResume = (ParseFile)jobApplications.get("applicantResumevideo");
applicantResume.getDataInBackground(new GetDataCallback() {
public void done(byte[] data, ParseException e) {
if (e == null) {
// data has the bytes for the resume
String strFile = Base64.encodeToString(data, Base64.NO_WRAP);
try
{
BufferedReader br=new BufferedReader(new FileReader(strFile));
BufferedWriter bw = new BufferedWriter(new FileWriter("/sdcard/s.3pg"));
String line=br.readLine();
String dt="";
while(line != null)
{
//System.out.println(line);
dt = dt+"\n"+line;
line = br.readLine();
}
br.close();
bw.write(dt);
bw.close();
}
catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//Bitmap bMap = BitmapFactory.decodeByteArray(data, 0, data.length);
catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} else {
// something went wrong
}
}
});
dvideo();
}
// this code doesnt't work because video doesn't get download
public void dvideo()
{
VideoView v = (VideoView) findViewById(R.id.videoView1);
Uri u=Uri.parse("/sdcard/S.3gp");
v.setVideoURI(u);
v.start();
}
video gets played in browser when I click on video stored in parse, it gets downloaded to downloads folder and I can play in any media player. How to download video from parse and store it in parse and play in video view?
You are going to need to use a media controller. I came across this same problem before. Here is an example. i being the variable for the ParseObject you retrieved in your query. This code was written in C# for Xamarin for Android though. It can be easily converted just lowercasing some these letters.
var videoVar = i.Get<ParseFile> ("video");
string videoUrl = videoVar.Url.ToString ();
VideoView video = FindViewById <VideoView> (Resource.Id.videoView);
var uri = Android.Net.Uri.Parse (videoUrl);
video.SetVideoURI (uri);
MediaController mc = new MediaController (this);
video.SetMediaController (mc);
video.RequestFocus ();
mc.Show ();
video.Start ();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.