More HTML 5 Multimedia




CS174

Chris Pollett

Nov. 25, 2013

Outline

jQuery

Detecting Orientation Changes in HTML 5

Orientation Change Code

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Portrait or Landscape</title> 
    <meta id="myview" name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /> 
    <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> 
    <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
    <script>
    $(function(){
        // Orientation Change
        // When orientation changes event is triggered
        // exposing an orientation property of either
        // landscape or portrait
        $('body').bind('orientationchange', function(event){
            changeOrientation(event.orientation)
        })

        // Change the style depending on orientation
        function changeOrientation(ori) {
            // Remove all classes
            $("#orientation").removeClass('portrait landscape');
            $("#orientation").addClass(ori);
            $("#orientation").html("<p>"+ori.toUpperCase()+"</p>");
        }

        $("body").trigger("orientationchange");
    })
    </script>
    <style>
    div.portrait {
      background-color: blue;
      width: 100%;
      height: 100%;
    }
    div.landscape {
      background-color: red;
      width: 100%;
      height: 100%;
    }
    p {
        font-size:24px;
        color:white;
    }
    </style>
</head> 
<body> 

<div data-role="page">
 
    <div data-role="header">
        <h1>Orientation</h1>
    </div><!-- /header -->
 
    <div data-role="content">
    <div id="orientation" class="portrait" ></div>
    </div><!-- /content -->
 
    <div data-role="footer">
        <h4>My Footer</h4>
    </div><!-- /footer -->
</div><!-- /page -->

</body>
</html>

Quiz

Which of the following statements is true?

  1. Memcache uses disk memory to cache objects.
  2. A reverse proxy is used by a company if they have only one connection to the internet and they want to cache accesses to it to conserve the bandwidth of employees browsing the web.
  3. The viewport of a browser is the virtual window area in which it renders a web page.

HTML 5 Local Storage

Ajax in jQuery

HTML 5 WebSockets

HTML 5 WebSockets -- HTTP

HTML 5 WebSockets -- Javascript

Below are the basic WebSocket Javascript functions (websocket URI's are prefixed with ws: or wss: (secure)):

var webSocket = new
WebSocket("ws://some.websocketplace.org");
// Associate listeners
webSocket.onopen = function(evt) {
alert("The connection was opened");
};
webSocket.onmessage = function(evt) {
alert("Received message: " + evt.data);
};
webSocket.onclose = function(evt) {
alert("The connection was closed");
};
webSocket.onerror = function(evt) {
alert("Ouch an error!");
};

webSocket.send("This is some WebSocket data!");
// Close WebSocket
webSocket.close();

Two-Dimensional Graphics in HTML

Canvas Tag

Touch Events HTML5

Video and Audio Tags

Determining Location in HTML 5

HTML Mapping

Google Maps

Google Map

A Google Map with Pin

Open Street Map

Open Street Map Screen Shot

Open Street Map Example