Beispiel #1
0
        public ValueTask <int> Play(HowlOptions options)
        {
            Guard.HasNoNulls(options.Sources, nameof(options.Sources));
            Guard.Condition(options.Sources, sources => sources.Length > 0, nameof(options.Sources));
            // Guard.Condition(options.Formats, formats => formats == null || formats.Length == options.Sources.Length, nameof(options.Formats));

            return(_runtime.InvokeAsync <int>("howl.play", _dotNetObjectReference, options));
        }
Beispiel #2
0
        public ValueTask <int> Play(params string[] sources)
        {
            Guard.HasNoNulls(sources, nameof(sources));

            var options = new HowlOptions
            {
                Sources = sources
            };

            return(Play(options));
        }
Beispiel #3
0
        public ValueTask <int> Play(byte[] audio, string mimetype)
        {
            Guard.NotNull(audio, nameof(audio));
            Guard.NotNullOrEmpty(mimetype, nameof(mimetype));

            // http://www.iandevlin.com/blog/2012/09/html5/html5-media-and-data-uri/
            var    audioAsBase64 = Convert.ToBase64String(audio);
            string html5AudioUrl = $"data:{mimetype};base64,{audioAsBase64}";

            var options = new HowlOptions
            {
                Sources = new[] { html5AudioUrl }
            };

            return(_runtime.InvokeAsync <int>("howl.play", _dotNetObjectReference, options));
        }