Giter Site home page Giter Site logo

radio-player's Introduction

MIT Licence JavaScript

Radio Player

A simple set of configuration files to make a station at the top of your page.

Screenshots

Rebuild Design

Features

Below is a section of features, and their corresponding code, so you can better understand how this project was completed.

Clock Feature

Without using any API, a clock is rendered on to the radio player to make the player more aesthetically pleasing.

function clock() {
	var date = new Date();
	var mins = date.getMinutes();
	var hours = date.getHours();
	var secs = date.getSeconds();
	if (hours==0) {
		if (mins < 10) {
			if (secs < 10) {
				var currenttime = "12"+":0"+mins+":0"+secs+" AM";
			} else {
				var currenttime = "12"+":0"+mins+":"+secs+" AM";
			}
		} else if (mins > 9) {
			if (secs < 10) {
				var currenttime = "12"+":"+mins+":0"+secs+" AM";
			} else {
				var currenttime = "12"+":"+mins+":"+secs+" AM";
			}
		}
	} else if (hours!=0) {
		if (hours < 12) {
			if (mins < 10) {
				if (secs < 10) {
					var currenttime = hours+":0"+mins+":0"+secs+" AM";
				} else {
					var currenttime = hours+":0"+mins+":"+secs+" AM";
				}
			} else if (mins > 9) {
				if (secs < 10) {
					var currenttime = hours+":"+mins+":0"+secs+" AM";
				} else {
					var currenttime = hours+":"+mins+":"+secs+" AM";
				}
			}
		} else if (hours > 12) {
			if (mins < 10) {
				if (secs < 10) {
					var currenttime = hours-12+":0"+mins+":0"+secs+" PM";
				} else {
					var currenttime = hours-12+":0"+mins+":"+secs+" PM";
				}
			} else if (mins > 9) {
				if (secs < 10) {
					var currenttime = hours-12+":"+mins+":0"+secs+" PM";
				} else {
					var currenttime = hours-12+":"+mins+":"+secs+" PM";
				}
			}
		}
	}
	document.getElementById("localTime").innerHTML = ("Local Time: "+currenttime)
	setTimeout(clock,0.1);
}

Volume Slider

Using an input slider, the volume can be easily changed in miliseconds!

function changeVolume(x) {
	if (x <= 0) {
		return console.warn("Volume is not valid");
	}
	if (x == undefined) {
		x = 50;
	}
	console.log(x)
	volumeSlider.value = x;
	radioVolume.innerHTML = "Volume: "+x+"%";
	volume = x/100;
	radioAudio.volume = volume;
}

JSON Stream List

Using JSON, a stream list is created that can be dynamically added manually.

var streamList = [
	`{ 
		"streams": [
			{"name": "103.7 The Q", "link": "http://wqen-fm.akacast.akamaistream.net/7/895/31814/v1/auth.akacast.akamaistream.net/wqen-fm"},
			{"name": "Example 1", "link": ""},
			{"name": "Example 2", "link": ""},
			{"name": "Example 3", "link": ""}
		]
	}`
]
var _streamList = JSON.parse(streamList);

Compiling The JSON Stream List

With the JSON list that was created, it adds the stations to the radio player's station selection.

function buildStreamList() {
	if (!ran) {
		for (var i = 0; i < _streamList.streams.length; i++) {
			streamSelect.innerHTML += '<option value="'+i+'">'+_streamList.streams[i].name+'</option>';
		}
		ran = true;
	} else {
		return console.warn("Stream list already built.")
	}
}

License

The license used is the MIT License, which can be found here, LICENSE

radio-player's People

Contributors

johnboydev avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

annas-airstudio

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.