public void OnCollapsed(FlurryAdNative adNative) { var handler = OnCollapsedHandler; if (handler != null) { handler(adNative, EventArgs.Empty); } }
public void OnImpressionLogged(FlurryAdNative adNative) { var handler = OnImpressionLoggedHandler; if (handler != null) { handler(adNative, EventArgs.Empty); } }
public void OnShowFullscreen(FlurryAdNative adNative) { var handler = OnShowFullscreenHandler; if (handler != null) { handler(adNative, EventArgs.Empty); } }
public void OnError(FlurryAdNative adNative, FlurryAdErrorType NativeErrorType, int NativeError) { var handler = OnErrorHandler; if (handler != null) { handler(adNative, new ErrorEventArgs(NativeErrorType, NativeError)); } }
public void OnAppExit(FlurryAdNative adNative) { var handler = OnAppExitHandler; if (handler != null) { handler(adNative, EventArgs.Empty); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Save); this._userPremiumStatus = Intent.GetStringExtra(PremiumInterface.UserPremiunStatus.StatusFlags.ACTIVITY_FLAG); //set up tracking and track this activity trackingInterface = new TrackingInterface(this); //trackingInterface.TrackScreen(TrackingInterface.ActivityNames.SaveActivity); shareButton = FindViewById <Button> (Resource.Id.shareButton); saveLayout = FindViewById <LinearLayout> (Resource.Id.saveLayout); mainSaveLayout = FindViewById <LinearLayout> (Resource.Id.mainSaveLayout); adLinearLayout = FindViewById <LinearLayout> (Resource.Id.adLinearLayout); adViewHolder = new AdViewHolder(this); pm = (PowerManager)GetSystemService(Context.PowerService); wl = pm.NewWakeLock(WakeLockFlags.ScreenDim, "My Tag"); ActionBar.Title = ""; internalPath = FilesDir.Path; rawFileName = "my_file"; List <string> fileNamesArray = new List <string>(); foreach (File file in this.FilesDir.ListFiles()) { fileNamesArray.Add(file.Name); } rawFileName = GetFullFileNameFromArray(rawFileName, fileNamesArray.ToArray()); outputName = "final.mp4"; finalFileName = "Gifaroo" + UUID.RandomUUID() + ".mp4"; ffmpeg = FFmpeg.GetInstance(this); commandDimensions = FffmpegTools.GetResizeCommandDimensions(this, rawFileName); mainSaveLayout.RemoveView(saveLayout); mainSaveLayout.RemoveView(adViewHolder.adLinearLayout); //Load ad only if the user is not premium if (this._userPremiumStatus == PremiumInterface.UserPremiunStatus.StatusFlags.STATUS_FREE) { Flurry.Analytics.FlurryAgent.SetLogEnabled(false); Flurry.Analytics.FlurryAgent.Init(this, "ZTKSCWYBWHW9D6F28KY5"); nativeAd = new Flurry.Ads.FlurryAdNative(this, "save_activity_native_ad"); nativeAd.FetchAd(); } #region ffmpeg load & execution CreateTxtFile(this); string[] commands = new string[] { "-y -i " + internalPath + "/" + rawFileName + " -vf scale=" + commandDimensions + " -preset superfast " + internalPath + "/output_mp4.mp4", "-y -i " + internalPath + "/background.jpg -vf scale=700:700 " + internalPath + "/background_scaled.jpg", "-y -i " + internalPath + "/top.png -vf scale=700:700 " + internalPath + "/top_scaled.png", "-y -loop 1 -i " + internalPath + "/background_scaled.jpg -i " + internalPath + "/output_mp4.mp4 -filter_complex overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:shortest=1 -preset superfast -codec:a copy -movflags +faststart " + internalPath + "/output_1.mp4", "-y -i " + internalPath + "/output_1.mp4 -loop 1 -i " + internalPath + "/top_scaled.png -filter_complex overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:shortest=1 -preset superfast -codec:a copy -movflags +faststart " + internalPath + "/final_unlooped.mp4", "-y -f concat -i " + internalPath + "/myList.txt -c copy " + internalPath + "/mute_final.mp4", "-y -i " + internalPath + "/mute_final.mp4 -i " + internalPath + "/10sec.mp3 -c:v libx264 -crf 19 -preset ultrafast -shortest -c:a aac -strict experimental -pix_fmt yuv420p -f mp4 -b:a 192k -y " + internalPath + "/" + outputName }; string[] progressMessages = new string[] { "Doing some work...", "Making progress...", "Still working...", "Just a little bit more...", "Adding some final touches..." }; //attempt to load ffmpeg and then execute the commands. FffmpegTools.XLoadBinaryResponseHandler loadResponseHandler = new FffmpegTools.XLoadBinaryResponseHandler(); FffmpegTools.XExecuteBinaryResponseHandler executeResponseHandler = new FffmpegTools.XExecuteBinaryResponseHandler(); //copy the ute audio file to the apps internal directory if it does not exist yet. if (new File(FilesDir.Path, "10sec.mp3").Exists() == false) { try { CopyFromAssetsToStorage(this, "10sec.mp3", "10sec.mp3"); }catch (Exception) { Log.Debug("GIFAROO", "10sec.mp3 copy failed!"); //TODO: Remove for release } } if (shouldRunffmpeg == true) { wl.Acquire(); progressD = new ProgressDialog(this); progressD.SetMessage(progressMessages[0]); progressD.SetCanceledOnTouchOutside(false); XOnCancelListener cancelListener = new XOnCancelListener(); progressD.SetOnCancelListener(cancelListener); cancelListener.EOnCanceled += (object cancelSender, EventArgs eCancel) => { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetMessage("Are you sure that you want to cancel?").SetTitle("Cancel?"); builder.SetPositiveButton("Yes", ((sender, e) => { try{ threadsCanceled = true; Finish(); } catch (Exception) {} })); builder.SetNegativeButton("No", ((sender, e) => { progressD.Show(); })); AlertDialog aDialog = builder.Create(); aDialog.Show(); }; //Launched when the attempt to load the ffmpeg is finished loadResponseHandler.OnFfmpegLoadindAttemptFinished += (object sender, EventArgs e) => { if (loadResponseHandler.failed == false) { new TaskFactory().StartNew(() => { //var commandArray = new[] { commands[executeResponseHandler.commandsPosition] }; ffmpeg.Execute( commands[executeResponseHandler.commandsPosition].Split(), executeResponseHandler); }); } else if (loadResponseHandler.failed == true) { trackingInterface.TrackFffmgFailure(true); } }; executeResponseHandler.OnExecutionFinished += (object sender, EventArgs e) => { if (executeResponseHandler.commandsPosition < commands.Length && threadsCanceled == false && executeResponseHandler.failed == false) //run only if the threads hav not been canceled { try{ progressD.SetMessage(progressMessages[executeResponseHandler.commandsPosition]); }catch (Exception) {} new TaskFactory().StartNew(() => { ffmpeg.Execute( commands[executeResponseHandler.commandsPosition].Split(), executeResponseHandler); }); //TODO: find a better implementation if (executeResponseHandler.failed == true) { //Report failure to analytics trackingInterface.TrackFffmgFailure(false, executeResponseHandler.commandsPosition); //One of the commands failed progressD.Dismiss(); if (wl.IsHeld) //release the wakelock if it is held { wl.Release(); } System.Console.WriteLine("FAILED: "); } } else { //all commands were executed, share and show ad if the user is not premium. if (progressD != null && progressD.IsShowing) { progressD.Dismiss(); } wl.Release(); if (executeResponseHandler.failed == false) { //all commands succeded mainSaveLayout.AddView(saveLayout); //show ad if (_userPremiumStatus == PremiumInterface.UserPremiunStatus.StatusFlags.STATUS_FREE && nativeAd.IsReady == true) { nativeAd.SetTrackingView(adLinearLayout); if (nativeAd.GetAsset("summary") != null) { nativeAd.GetAsset("summary").LoadAssetIntoView(adViewHolder.summary); } if (nativeAd.GetAsset("headline") != null) { nativeAd.GetAsset("headline").LoadAssetIntoView(adViewHolder.headline); } if (nativeAd.GetAsset("source") != null) { nativeAd.GetAsset("source").LoadAssetIntoView(adViewHolder.source); } if (nativeAd.GetAsset("secBrandingLogo") != null) { nativeAd.GetAsset("secBrandingLogo").LoadAssetIntoView(adViewHolder.secBrandingLogo); } if (nativeAd.GetAsset("secHqImage") != null) { nativeAd.GetAsset("secHqImage").LoadAssetIntoView(adViewHolder.secHqImage); } if (nativeAd.GetAsset("secImage") != null) { nativeAd.GetAsset("secImage").LoadAssetIntoView(adViewHolder.secImage); } if (nativeAd.GetAsset("headline") != null) { nativeAd.GetAsset("headline").LoadAssetIntoView(adViewHolder.headline); } if (nativeAd.GetAsset("callToAction") != null) { adViewHolder.callToAction.Text = nativeAd.GetAsset("callToAction").Value; } mainSaveLayout.AddView(adViewHolder.adLinearLayout); } else //make it all non-visible { } } } }; progressD.Show(); //new TaskFactory ().StartNew(()=>{ try{ ffmpeg.LoadBinary(loadResponseHandler); }catch (Exception) {} //}); } shareButton.Click += (object sender, EventArgs e) => { CreateVideoShareIntent(this, outputName); }; #endregion }