Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

AngleSharp

, 3 Jul 2013
Bringing the DOM to C# with a HTML5/CSS3 parser written in C#.
Demo.zip
AngleSharp
Css
Tokens
DOM
Collections
Css
Properties
Rules
Selector
Values
Enums
Exception
Html
Basic
Formatting
Forms
Frames
Head
Lists
Media
Objects
Semantic
Tables
Interfaces
Mathml
Objects
Svg
Various
Xml
Foundation
Attributes
Helpers
Mutations
Html
Tokens
Properties
Stream
Xml
Tokens
packages
ModernUI.WPF.1.0.4
lib
net40
FirstFloor.ModernUI.dll
Microsoft.Windows.Shell.dll
net45
FirstFloor.ModernUI.dll
ModernUI.WPF.1.0.4.nupkg
ModernUI.WPF.1.0.4.nuspec
OxyPlot.Core.2013.1.49.1
lib
portable-net4+sl4+wp71+win8
OxyPlot.dll
OxyPlot.Core.2013.1.49.1.nupkg
OxyPlot.Core.2013.1.49.1.nuspec
OxyPlot.Wpf.2013.1.49.1
lib
NET40
OxyPlot.Wpf.dll
OxyPlot.Xps.dll
NET45
OxyPlot.Wpf.dll
OxyPlot.Xps.dll
OxyPlot.Wpf.2013.1.49.1.nupkg
OxyPlot.Wpf.2013.1.49.1.nuspec
Samples
Logo.ico
Pages
Properties
Settings.settings
ViewModels
Source.zip
Documents
using System;

namespace AngleSharp.DOM.Html
{
    /// <summary>
    /// Represents the abstract base for HTML media (audio / video) elements.
    /// </summary>
    public abstract class HTMLMediaElement : HTMLElement
    {
        #region Members

        /// <summary>
        /// The source url.
        /// </summary>
        protected String source;
        /// <summary>
        /// The state of the network.
        /// </summary>
        protected MediaNetworkState network;
        /// <summary>
        /// The state of the media.
        /// </summary>
        protected MediaReadyState ready;
        /// <summary>
        /// Currently seeking ?
        /// </summary>
        protected Boolean seeking;
        /// <summary>
        /// The total time (duration).
        /// </summary>
        protected Double duration;
        /// <summary>
        /// The current time.
        /// </summary>
        protected Double currentTime;

        #endregion

        #region ctor

        internal HTMLMediaElement()
        {
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the media source.
        /// </summary>
        public string Src
        {
            get { return GetAttribute("src"); }
            set { SetAttribute("src", value); }
        }

        /// <summary>
        /// Gets or sets the cross-origin attribute.
        /// </summary>
        public string CrossOrigin
        {
            get { return GetAttribute("crossorigin"); }
            set { SetAttribute("crossorigin", value); }
        }

        /// <summary>
        /// Gets or sets the preload attribute.
        /// </summary>
        public string Preload
        {
            get { return GetAttribute("preload"); }
            set { SetAttribute("preload", value); }
        }

        /// <summary>
        /// Gets the current network state.
        /// </summary>
        public MediaNetworkState NetworkState
        {
            get { return network; }
        }

        /// <summary>
        /// Gets the current ready state.
        /// </summary>
        public MediaReadyState ReadyState
        {
            get { return ready; }
        }

        /// <summary>
        /// Gets if seeking is currently active.
        /// </summary>
        public bool Seeking
        {
            get { return seeking; }
        }

        /// <summary>
        /// Gets the current media source.
        /// </summary>
        public string CurrentSrc
        {
            get { return source; }
        }

        /// <summary>
        /// Gets the time in seconds.
        /// </summary>
        public double Duration
        {
            get { return duration; }
        }

        /// <summary>
        /// Gets or sets the current time in seconds.
        /// </summary>
        public double CurrentTime
        {
            get { return currentTime; }
            set
            {
                if (value < 0)
                    currentTime = 0;
                else if (value > Duration)
                    currentTime = Duration;
                else
                    currentTime = value;

                //TODO Current Time changed!
            }
        }

        //TODO
        //http://www.w3.org/TR/html5/embedded-content-0.html#htmlmediaelement

        #endregion

        #region Methods

        /// <summary>
        /// Loads the media specified for this element.
        /// </summary>
        public void Load()
        {
            //TODO
        }

        /// <summary>
        /// Tries to play the media for this element.
        /// </summary>
        public void Play()
        {
            //TODO
        }

        /// <summary>
        /// Pauses the playback of the media for this element.
        /// </summary>
        public void Pause()
        {
            //TODO
        }

        #endregion

        #region Enumerations

        /// <summary>
        /// An enumeration of possible network states.
        /// </summary>
        public enum MediaNetworkState : ushort
        {
            /// <summary>
            /// The element has not yet been initialized.
            /// Everything is in initial state.
            /// </summary>
            Empty = 0,
            /// <summary>
            /// The element's resource selection alg. is active.
            /// No network usage at the moment, but nothing
            /// loaded.
            /// </summary>
            Idle = 1,
            /// <summary>
            /// The download is in progress.
            /// </summary>
            Loading = 2,
            /// <summary>
            /// The element's resource selection alg. is active,
            /// but has not yet found a resource to use.
            /// </summary>
            NoSource = 3
        }

        /// <summary>
        /// An enumeration of media ready states.
        /// </summary>
        public enum MediaReadyState : ushort
        {
            /// <summary>
            /// No information is available.
            /// </summary>
            Nothing = 0,
            /// <summary>
            /// Enough information obtained such that the duration of the
            /// resource is available.
            /// </summary>
            Metadata = 1,
            /// <summary>
            /// Data for immediate playback is available, but not enough
            /// to advance.
            /// </summary>
            CurrentData = 2,
            /// <summary>
            /// Enough data for the current and further positions are 
            /// available.
            /// </summary>
            FutureData = 3,
            /// <summary>
            /// All conditions are met and playback should immediately
            /// execute.
            /// </summary>
            EnoughData = 4
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The BSD License

Share

About the Author

Florian Rappl
Chief Technology Officer
Germany Germany
Florian is from Regensburg, Germany. He started his programming career with Perl. After programming C/C++ for some years he discovered his favorite programming language C#. He did work at Siemens as a programmer until he decided to study Physics. During his studies he worked as an IT consultant for various companies.
 
Florian is also giving lectures in C#, HTML5 with CSS3 and JavaScript, and other topics. Having graduated from University with a Master's degree in theoretical physics he is currently busy doing his PhD in the field of High Performance Computing.
Follow on   Google+

| Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 4 Jul 2013
Article Copyright 2013 by Florian Rappl
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid