コード例 #1
0
ファイル: MovieStreamHelper.cs プロジェクト: locana/uwpmm
        public async void Finish()
        {
            StreamProcessor.CloseConnection();

            var dispatcher = SystemUtil.GetCurrentDispatcher();

            if (dispatcher != null)
            {
                await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    MoviePlaybackData.Image = null;
                });
            }

            if (AvContent == null)
            {
                return;
            }

            try
            {
                await AvContent.StopStreamingAsync().ConfigureAwait(false);
            }
            catch (Exception)
            {
                DebugUtil.Log("Failed to stop movie stream");
            }
            finally
            {
                AvContent = null;
            }
        }
コード例 #2
0
 async void StreamProcessor_PlaybackInfoRetrieved(object sender, PlaybackInfoEventArgs e)
 {
     // DebugUtil.Log("playback info: " + MoviePlaybackData.FileName + " " + e.Packet.CurrentPosition.TotalMilliseconds);
     await SystemUtil.GetCurrentDispatcher()?.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         MoviePlaybackData.CurrentPosition = e.Packet.CurrentPosition;
         MoviePlaybackData.Duration        = e.Packet.Duration;
     });
 }
コード例 #3
0
        protected async void NotifyChangedOnUI(string name, CoreDispatcherPriority priority = CoreDispatcherPriority.Normal)
        {
            var dispatcher = SystemUtil.GetCurrentDispatcher();

            if (dispatcher == null)
            {
                return;
            }

            await dispatcher.RunAsync(priority, () =>
            {
                NotifyChanged(name);
            });
        }
コード例 #4
0
        private async void LoadLicenseFile()
        {
            if (string.IsNullOrEmpty(license))
            {
                var installedFolder = Package.Current.InstalledLocation;
                var folder          = await installedFolder.GetFolderAsync("Assets");

                var file = await folder.GetFileAsync("License.txt");

                var stream = await file.OpenReadAsync();

                var reader = new StreamReader(stream.AsStreamForRead());
                license = reader.ReadToEnd();
                license = license.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\r\n"); // Avoid autocrlf effect
            }
            await SystemUtil.GetCurrentDispatcher().RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                FormatRichText(Contents, license);
            });
        }
コード例 #5
0
ファイル: MovieStreamHelper.cs プロジェクト: locana/uwpmm
        public async Task <bool> Start(AvContentApiClient api, PlaybackContent content, string name)
        {
            if (IsProcessing)
            {
                throw new InvalidOperationException("Already processing");
            }
            AvContent = api;

            try
            {
                var location = await api.SetStreamingContentAsync(content).ConfigureAwait(false);

                await api.StartStreamingAsync().ConfigureAwait(false);

                RunLoop(false);

                var success = await StreamProcessor.OpenConnection(new Uri(location.Url)).ConfigureAwait(false);

                if (!success)
                {
                    AvContent = null;
                }

                var dispatcher = SystemUtil.GetCurrentDispatcher();
                if (dispatcher != null)
                {
                    await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        MoviePlaybackData.FileName = name;
                    });
                }

                return(success);
            }
            catch (Exception e)
            {
                DebugUtil.Log(e.StackTrace);
                AvContent = null;
                return(false);
            }
        }