Skip to content
Merged
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
78 changes: 67 additions & 11 deletions Windows Phone/VineCache/VineCache/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
using Facebook.Client;
using Facebook;
using Facebook.Client;
using Parse;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Devices.Geolocation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage;
using Windows.Storage.Streams;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
Expand All @@ -29,16 +34,24 @@ public sealed partial class App : Application
{
private TransitionCollection transitions;
private static Geolocator s_GPS;

/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
public static ParseDB parseDB;
public static string facebookToken;
public static string facebookName;
public static string facebookID;
public static string facebookEmail;
public static int currentNodeNumba = 0;

/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
this.Suspending += this.OnSuspending;
}
ParseClient.Initialize("ODbBwcIu8uZ4zuJ8PGsinEtXeyUswCXL9pUnddov", "0xnE8Q36PWvW517XvQlCEyBmKS0etT5VEdP5gyaP");
parseDB = new ParseDB();
}

/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
Expand Down Expand Up @@ -105,6 +118,8 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)

// Ensure the current window is active
Window.Current.Activate();

//ParseAnalytics.TrackAppOpenedAsync();
}

/// <summary>
Expand Down Expand Up @@ -156,9 +171,50 @@ private void OnFacebookAuthenticationFinished(AccessTokenData session)
{
Frame rootFrame = Window.Current.Content as Frame;
rootFrame.Navigate(typeof(DisplayVideoPage));
}

internal static Geolocator GPS
facebookToken = session.AccessToken;
facebookID = session.FacebookId;

parseDB.parseDelegate = new VineCacheParseDelegate();
parseDB.GetNextAvailableEvent();
}

internal class VineCacheParseDelegate : ParseDelegate
{
public void EventResult(PLEvent eventItem)
{
FacebookClient client = new FacebookClient(facebookToken);
client.GetTaskAsync("me", new { fields = "name, id, email" }).ContinueWith((Task<object> task, object item) => {
dynamic facebookInfo = task.Result;
App.facebookName = facebookInfo.name;
App.facebookID = facebookInfo.id;
//App.facebookEmail = facebookInfo.email;
parseDB.CreatePlayer(App.facebookName, App.facebookEmail, App.facebookID, item as PLEvent);
parseDB.GetMap(item as PLEvent);
}, eventItem);

}

public void MapResult(PLMap mapItem)
{
parseDB.GetNodes(mapItem);
}

public void NodeResult(List<PLNode> nodeList)
{
parseDB.RetrieveVideo(nodeList[currentNodeNumba]);
}

public async void VideoRetrieved(PLNode node)
{
InMemoryRandomAccessStream s = new InMemoryRandomAccessStream();
StorageFolder folder = KnownFolders.VideosLibrary;
StorageFile file = await folder.CreateFileAsync("vinecachetargetvideo.mp4", CreationCollisionOption.ReplaceExisting);
await FileIO.WriteBytesAsync(file, node.Video as byte[]);
}
}


internal static Geolocator GPS
{
get
{
Expand Down
11 changes: 9 additions & 2 deletions Windows Phone/VineCache/VineCache/DisplayVideoPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.Devices.Geolocation;
using Windows.Storage;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkID=390556

Expand Down Expand Up @@ -73,8 +74,9 @@ protected override void OnNavigatedTo(NavigationEventArgs e)

private async void videoMediaElement_Tapped(object sender, TappedRoutedEventArgs e)
{
this.NavigateToUploadVideoPage();
videoMediaElement.Play();
SetVideoTarget();
//this.NavigateToUploadVideoPage();
videoMediaElement.Play();
distanceToObjectProgressBar.Value = 50;
if (this.startingPoint == null)
{
Expand All @@ -87,6 +89,11 @@ private async void videoMediaElement_Tapped(object sender, TappedRoutedEventArgs
}
}

public void SetVideoTarget()
{
this.videoMediaElement.Source = new Uri(KnownFolders.VideosLibrary.Path + "/vinecachetargetvideo.mp4");
}

private void NavigateToUploadVideoPage()
{
Frame rootFrame = Window.Current.Content as Frame;
Expand Down
2 changes: 1 addition & 1 deletion Windows Phone/VineCache/VineCache/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Grid x:Name="BootPanel" Background="Transparent" Visibility="Visible">
<TextBlock x:Name="bootAppNameTextBlock" TextAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap" Text="VineCache" FontSize="40" VerticalAlignment="Top" Height="48" Width="385" Foreground="Green" Margin="7,81,8,0"/>
<Image x:Name="bootImage" HorizontalAlignment="Center" Height="383" Margin="0,70,0,0" VerticalAlignment="Center" Width="380" Source="Assets/flower-vine-hi.png"/>
<facebookControls:LoginButton x:Name="facebookLoginButton" Grid.Row="2" Margin="0,0,0,80" Width="200" HorizontalAlignment="Center" VerticalAlignment="Bottom" SessionStateChanged="facebookLoginButton_OnSessionStateChanged" />
<facebookControls:LoginButton x:Name="facebookLoginButton" Grid.Row="2" Margin="0,0,0,80" Width="200" HorizontalAlignment="Center" VerticalAlignment="Bottom" Permissions="public_profile" SessionStateChanged="facebookLoginButton_OnSessionStateChanged" />
</Grid>
</Grid>
</Page>
Binary file not shown.
Binary file added Windows Phone/VineCache/VineCache/Parse.Phone.dll
Binary file not shown.
Binary file added Windows Phone/VineCache/VineCache/Parse.WinRT.dll
Binary file not shown.
Binary file added Windows Phone/VineCache/VineCache/Parse.dll
Binary file not shown.
Loading