{"action":"closed","issue":{"url":"https://api.github.com/repos/unosquare/ffmediaelement/issues/197","repository_url":"https://api.github.com/repos/unosquare/ffmediaelement","labels_url":"https://api.github.com/repos/unosquare/ffmediaelement/issues/197/labels{/name}","comments_url":"https://api.github.com/repos/unosquare/ffmediaelement/issues/197/comments","events_url":"https://api.github.com/repos/unosquare/ffmediaelement/issues/197/events","html_url":"https://github.com/unosquare/ffmediaelement/issues/197","id":309264367,"number":197,"title":"Open command to easy await async media loading","user":{"login":"Ocimandias","id":32926795,"avatar_url":"https://avatars0.githubusercontent.com/u/32926795?v=4","gravatar_id":"","url":"https://api.github.com/users/Ocimandias","html_url":"https://github.com/Ocimandias","followers_url":"https://api.github.com/users/Ocimandias/followers","following_url":"https://api.github.com/users/Ocimandias/following{/other_user}","gists_url":"https://api.github.com/users/Ocimandias/gists{/gist_id}","starred_url":"https://api.github.com/users/Ocimandias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ocimandias/subscriptions","organizations_url":"https://api.github.com/users/Ocimandias/orgs","repos_url":"https://api.github.com/users/Ocimandias/repos","events_url":"https://api.github.com/users/Ocimandias/events{/privacy}","received_events_url":"https://api.github.com/users/Ocimandias/received_events","type":"User","site_admin":false},"labels":[{"id":316825423,"url":"https://api.github.com/repos/unosquare/ffmediaelement/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":316825426,"url":"https://api.github.com/repos/unosquare/ffmediaelement/labels/question","name":"question","color":"cc317c","default":true}],"state":"closed","locked":false,"assignee":{"login":"mariodivece","id":351978,"avatar_url":"https://avatars3.githubusercontent.com/u/351978?v=4","gravatar_id":"","url":"https://api.github.com/users/mariodivece","html_url":"https://github.com/mariodivece","followers_url":"https://api.github.com/users/mariodivece/followers","following_url":"https://api.github.com/users/mariodivece/following{/other_user}","gists_url":"https://api.github.com/users/mariodivece/gists{/gist_id}","starred_url":"https://api.github.com/users/mariodivece/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mariodivece/subscriptions","organizations_url":"https://api.github.com/users/mariodivece/orgs","repos_url":"https://api.github.com/users/mariodivece/repos","events_url":"https://api.github.com/users/mariodivece/events{/privacy}","received_events_url":"https://api.github.com/users/mariodivece/received_events","type":"User","site_admin":false},"assignees":[{"login":"mariodivece","id":351978,"avatar_url":"https://avatars3.githubusercontent.com/u/351978?v=4","gravatar_id":"","url":"https://api.github.com/users/mariodivece","html_url":"https://github.com/mariodivece","followers_url":"https://api.github.com/users/mariodivece/followers","following_url":"https://api.github.com/users/mariodivece/following{/other_user}","gists_url":"https://api.github.com/users/mariodivece/gists{/gist_id}","starred_url":"https://api.github.com/users/mariodivece/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mariodivece/subscriptions","organizations_url":"https://api.github.com/users/mariodivece/orgs","repos_url":"https://api.github.com/users/mariodivece/repos","events_url":"https://api.github.com/users/mariodivece/events{/privacy}","received_events_url":"https://api.github.com/users/mariodivece/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/unosquare/ffmediaelement/milestones/5","html_url":"https://github.com/unosquare/ffmediaelement/milestone/5","labels_url":"https://api.github.com/repos/unosquare/ffmediaelement/milestones/5/labels","id":3169264,"number":5,"title":"2.30 - Michelob","description":"Release 3.4.230","creator":{"login":"mariodivece","id":351978,"avatar_url":"https://avatars3.githubusercontent.com/u/351978?v=4","gravatar_id":"","url":"https://api.github.com/users/mariodivece","html_url":"https://github.com/mariodivece","followers_url":"https://api.github.com/users/mariodivece/followers","following_url":"https://api.github.com/users/mariodivece/following{/other_user}","gists_url":"https://api.github.com/users/mariodivece/gists{/gist_id}","starred_url":"https://api.github.com/users/mariodivece/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mariodivece/subscriptions","organizations_url":"https://api.github.com/users/mariodivece/orgs","repos_url":"https://api.github.com/users/mariodivece/repos","events_url":"https://api.github.com/users/mariodivece/events{/privacy}","received_events_url":"https://api.github.com/users/mariodivece/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":12,"state":"open","created_at":"2018-03-07T16:24:40Z","updated_at":"2018-03-28T16:34:21Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2018-03-28T08:17:42Z","updated_at":"2018-03-28T16:34:21Z","closed_at":"2018-03-28T16:34:21Z","author_association":"NONE","body":"# Feature request: Open command to easy await async media loading\r\n\r\nWhile 'Source' property could be used to load media and wait for Open state with some code, would be useful to have an awaitable Open command that could be invoked like Play, Pause, Stop and Close.\r\n\r\nThe only point is the way to update the value of Dependency Property related to Source without triggering change events.\r\n\r\nI have made a local version and I attached a sample of the code. I'm sure that there's a better way to do it.\r\n\r\nHope this will help.\r\n\r\n## Issue Categories\r\n\r\n - [ ] Bug\r\n - [x] Feature Request\r\n - [ ] Question\r\n - [ ] Not sure\r\n\r\n## Version Information\r\n\r\n - [ ] NuGet Package *Enter Version Number Here*\r\n - [x] Build From *Master* branch Latest - v2.20.0\r\n - [ ] Build from *Branch Name*, Commit *Enter commit id. Example: 704c482*\r\n\r\n\r\n### C#\r\nAt MediaEngine.Controller.cs\r\n\r\n        /// <summary>\r\n        /// Opens the specified URI.\r\n        /// </summary>\r\n        /// <param name=\"uri\">The URI.</param>\r\n        /// <returns>The awaitable task</returns>\r\n        /// <exception cref=\"InvalidOperationException\">Source</exception>\r\n        public async Task Open(Uri uri)\r\n        {\r\n            if (BeginSynchronousCommand() == false) return;\r\n\r\n            try\r\n            {\r\n                if (uri != null)\r\n                {\r\n                    await Commands.CloseAsync();\r\n                    await Commands.OpenAsync(uri);\r\n                }\r\n                else\r\n                {\r\n                    await Commands.CloseAsync();\r\n                }\r\n            }\r\n            catch\r\n            {\r\n                throw;\r\n            }\r\n            finally\r\n            {\r\n                EndSynchronousCommand();\r\n            }\r\n        }\r\n\r\nAt MediaElement.DependencyProperties.cs\r\n\r\n       private static Uri _Source = null;\r\n\r\n        private static object OnSourcePropertyChanging(DependencyObject d, object value)\r\n        {\r\n            var element = d as MediaElement;\r\n            if (element == null || element.MediaCore == null || element.MediaCore.IsDisposed) return null;\r\n            return _Source;\r\n\r\n            // return value;\r\n        }\r\n\r\n        private static async void OnSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)\r\n        {\r\n            var element = d as MediaElement;\r\n            if (e.NewValue == null && e.OldValue != null && element.IsOpen)\r\n            {\r\n                _Source = null;\r\n                await element.Close();\r\n            }\r\n            else if (e.NewValue != null && element.IsOpening == false && e.NewValue is Uri uri)\r\n            {\r\n                if (_Source != uri)\r\n                {\r\n                    _Source = uri;\r\n                    await element?.MediaCore?.Open(_Source);\r\n                }\r\n\r\n            // await element?.MediaCore?.Open(e.NewValue as Uri);\r\n            }\r\n        }"}}
{"actor":{"display_login":"mariodivece"}}