This Music: Prohibited

From Robert-Depot
Revision as of 19:05, 3 June 2010 by Krkim (talk | contribs)

Jump to: navigation, search

Motivation

For my project, I was thinking of the recent news of Pakistan banning Youtube and Facebook because of conflict between the content of these websites and the main religion. This led me to think about the government's role in the everyday lives of its citizens. During WWII, the Nazi regime restricted Germans from listening to Western radio and therefore Western music. Similarly, Britain also limited its citizens' radio. Tito of former Yugoslavia also aimed to limit the type of music that people of his country listened to, such as rock music, although Yugoslavia's power over the everyday lives of their citizens was not as ubiquitous as other totalitarian governments.

Interactive Paradigm

With this concept, I wanted to have one input taking in song information somehow and the computer reacting in a way that either accepts or rejects the music. An example would be a clearly Western song that is "rejected" by Germany or Yugoslavia's government through an image.

Technical Description

I was thinking about perhaps having an input of a fake preset "radio" songs connecting through an Arduino to the computer in which the computer would display an accepting or rejecting image in reaction to the song that arises caused by the knobs on the fake radio. My arduino, however, might be broken, so I am still thinking of other ways of taking in input. I am researching if there's a way that I could utilize song recognition applications so that the user could sing or play something and the computer image would either reject it. The third method of input I am considering is taking in a Twitter RSS feed based on the a search with "concert" or "konzert" as the key word. I'm not sure what is feasible yet.

What I chose in the end to do was use YouTube as the source of music. Previously, everyone listened to the radio for news and music. Today, however, many utilize YouTube as a way to listen to songs and vlogs dealing with news.

I used the Netbeans IDE to use html, java, javascript and css to build a faux-YouTube. If one entered keywords that did not adhere to the standards of any of the countries, the blocking image would appear. For example, if one typed, "mein hut der hat drei ecken," images of US's Roosevelt and Britain's Churchill would appear to stop the site from going to and searching for the phrase on YouTube. Identically, the same would happen if one typed something like "god bless america." An SS officer would appear to stop the website. If the phrase clears both of these restrictions, it will go ahead and allow the user to search for it on YouTube.

Functional Diagrams

user input -> my project through netbeans -> Youtube or -> Blocking Image

or

user input -> sphinx - 4 -> Blocking Image

Visual Concept

Documentation

Doc1.png Doc2.png Doc3.png Doc4.png

Source Code

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <title>YouTuber: Be Censored</title> 
    <script type="text/javascript" src="youtuber2.js"></script> 
    <link rel="stylesheet" type="text/css" href="tinyStillman.css" /> 
</head> 
    <body> 
        <form name ="youtubeForm"> 
            <input type="text" id="inputBoxer" name="inputBox" value="" size="80"/> 
            <input type="button" value="Search" onclick="searchYoutube()"/> 
        </form> 
</body> 
</html> 

JAVASCRIPT:

// global
var request;
// function for updating the url
function searchYoutube() {
    var inputBox = document.getElementById("inputBoxer").value;
    inputBox = (inputBox.trim()).toString();
    //searchQuery = inputBox2;
    //searchQuery = "form";
    var url = "http://localhost:8080/Sessions2/tinyStillman?inputBox=" + inputBox;
    //url = "inputBox=" + searchQuery;
    //if (microsoftBrowser) { // special treatment for Microsoft IE
      //  request = new ActiveXObject("Microsoft.XMLHTTP");
    //} else { // must be one of the other browsers
    request = new XMLHttpRequest();
    //}
    //alert ("what");
    request.open("GET", url, true);
    request.onreadystatechange = ajaxCallback;
    request.send(null);
}
function ajaxCallback() {
    if (request.readyState == 4) {
        if (request.status == 200) {
            var searchAnswer = request.responseText;
            //searchAnswer = searchAnswer.getElementById("url");
            //searchAnswer = searchAnswer.toString();
            //window.location = searchAnswer;
            //document.location = searchAnswer;
            location.replace(searchAnswer);
            //out.println("got here");
        }
    }
}
window.onload = function() {
    //body = document.getElementsByTagName("body");
    //body[0].style.backgroundColor = "#ffffff";
}

CSS:

/* Document   : tinyStillman
    Created on : Jun 2, 2010, 12:52:26 AM
    Author     : Kelley
    Description:
        Purpose of the stylesheet follows.
*/
root { 
    display: block;
}
body {
  background-image: url("http://farm5.static.flickr.com/4014/4665007323_788ac24b36_b.jpg");
  background-repeat: no-repeat;
  background-position: top center;
  background-attachment: fixed;
}
form
{
    float: left;
    margin-left: 16.7%;
    margin-top: 6.5px;
    position:relative;
}
input[type=text]{
    width:225px;
    height:18px;
}
input[type=button]{
    border: 1px outset gray;
    background-color:white;
}
background-image{
    position:relative;
}

JAVA:

     * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
package edu.ucsd.visarts.session;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.*;
public class tinyStillman extends HttpServlet {
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/plain");
        PrintWriter out = response.getWriter();
        String message = null;
        String [] germanArticles = {"deutschen","deutschland","deutsch","deutsche",
                                    "bundesrepublik",
                                    "der","das","die","den","dem","des",
                                    "dessen","deren","wessen",
                                    "mein","meinen","meiner","meines", "meine",
                                    "ich", "du","dich","sie","er","ihr","wir",
                                    "sind", "bin","ist","bist","sein",
                                    "auf","von","bei","an","liebe"};
        String [] englishIsh = {"english","queen","united kingdom","british","united kingdom",
                                "states","united states","american", "america","god",
                                "i","you","yours","me","my","she","he","her","him",
                                "hers","his",
                                "is","are","am","in","out","the", "a","love","at"};
        try {
            // declare some local vars
            String [] search;
            String searchFinal = "you've got a knack to vivify";
            String colorArg = request.getParameter("inputBox"); // will return null if none
            search = new String [10];
            search = colorArg.split(" ");
            searchFinal = "";
            int germanNumber = 0;
            int englishNumber = 0;
            for (int g = 0; g < germanArticles.length; g++){
                for (int s = 0; s < search.length; s++){
                    if (search[s].equalsIgnoreCase(germanArticles[g])){
                        germanNumber++;
                    }
                }
            }
            for (int g = 0; g < englishIsh.length; g++){
                for (int s = 0; s < search.length; s++){
                    if (search[s].equalsIgnoreCase(englishIsh[g])){
                        englishNumber++;
                    }
                }
            }
            if (germanNumber > englishNumber){
                searchFinal = "h ttp://farm5.static.flickr.com/4032/4666513039_22c4f4d02a_b.jpg";
                message = searchFinal;
            }
            else if (englishNumber > germanNumber){
                searchFinal = "h ttp://farm5.static.flickr.com/4040/4667136438_5b9b33a396_b.jpg";
                message = searchFinal;
            }
            else {
                for (int i = 0; i < search.length; i ++){
                    searchFinal = searchFinal + search [i] + "+";
                }
                searchFinal = "http://www.youtube.com/results?search_query=" +
                            searchFinal + "&aq=f";
                message = searchFinal;
            }
            out.println(searchFinal);
        } finally {
            out.close();
        }
    } 
    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** 
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    } 
    /** 
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response<math>Insert formula here</math>
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }
    /** 
     * Returns a short description of the servlet.
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Tiny Stillman";
    }// </editor-fold>
}