Skip to content
Merged

Cgb #29

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Windows Phone/VineCache/VineCache/ParseLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public void UploadVideo(byte[] videoData, PLNode node)
var video = new ParseObject("Videos");
video["Video"] = file;
video["Node"] = node.pfNode;
var relation = node.pfNode.GetRelation<ParseObject>("Videos");
var relation = _PLPlayer.pfPlayer.GetRelation<ParseObject>("Videos");
relation.Add(video);
node.pfNode.SaveAsync();
}
Expand Down
38 changes: 36 additions & 2 deletions Windows Phone/VineCache/VineCache/UploadVideoPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Media.Capture;
using Windows.Media.MediaProperties;
using Windows.Phone.UI.Input;
using Windows.Storage;
using Windows.Storage.Streams;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
Expand Down Expand Up @@ -51,6 +53,9 @@ private async void StartRecordingVideo()
StorageFile videoStorageFile = await KnownFolders.VideosLibrary.CreateFileAsync(VideoFileName, CreationCollisionOption.ReplaceExisting);
MediaEncodingProfile encodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.HD720p);
await this.mediaCapture.StartRecordToStorageFileAsync(encodingProfile, videoStorageFile);

await Task.Delay(6000);
StopRecordingVideo();
}
}

Expand All @@ -59,6 +64,34 @@ private async void StopRecordingVideo()
await this.mediaCapture.StopRecordAsync();
}

private async void UploadRecordedVideo()
{
StorageFile videoStorageFile = await KnownFolders.VideosLibrary.GetFileAsync(VideoFileName);
if (videoStorageFile != null)
{
byte[] videoData = await ReadFile(videoStorageFile);
App.parseDB.UploadVideo(videoData, ParseDB._PLNodes[App.currentNodeNumba]);
}
}

/// <summary>
/// Loads the byte data from a StorageFile
/// </summary>
/// <param name="file">The file to read</param>
private static async Task<byte[]> ReadFile(StorageFile file)
{
byte[] fileBytes = null;
using (IRandomAccessStreamWithContentType stream = await file.OpenReadAsync())
{
fileBytes = new byte[stream.Size];
using (DataReader reader = new DataReader(stream))
{
await reader.LoadAsync((uint)stream.Size);
reader.ReadBytes(fileBytes);
}
}
return fileBytes;
}

/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
Expand All @@ -69,17 +102,18 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
{
this.InitVideoCapture();
}

private void StartRecordingButton_Click(object sender, RoutedEventArgs e)
{
StartRecordingVideo();
}

private void UploadRecordingButton_Click(object sender, RoutedEventArgs e)
{
StopRecordingVideo();
UploadRecordedVideo();
}


private void videoMediaElement_Tapped(object sender, RoutedEventArgs e)
{

Expand Down