More HTML 5 Multimedia




CS174

Chris Pollett

May 9, 2016

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. The only two requirements we gave in our definition of scalable web-site was that it could handle more traffic and more data.
  2. A content delivery network might make use of a distributed hash table.
  3. Apache Benchmark is typically used for load balancing web requests.

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