Skip to content

Commit

Permalink
Readded popup if no vlc plugin. Remote control of the volume.
Browse files Browse the repository at this point in the history
  • Loading branch information
fyhertz committed Jun 24, 2013
1 parent 76a76c0 commit dcc9143
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 28 deletions.
10 changes: 7 additions & 3 deletions assets/www/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
style="visibility:hidden;"
id="vlcv">
</embed>
<div id="sound">
<div id="plus"><a>+</a></div>
<div id="volume">?</div>
<div id="minus"><a>-</a></div>
</div>
<div id="fullscreen"><a>Fullscreen</a></div>
<div id="battery"><span>Battery</span>: <span id="level">100</span>%</div>
</div>
Expand Down Expand Up @@ -227,7 +232,6 @@
</div>
<span id="hide-tooltip"><a>Hide those tips</a></span>
</div>

</section>

<div class="popup" id="error-screenoff">
Expand All @@ -236,9 +240,9 @@ <h2>You must leave the screen of your smartphone on !</h2>
</div>

<div class="popup" id="error-noplugin">
<h2>You need to install VLC first !</h2>
<h2>You need to install or update VLC and the VLC mozilla plugin ! qsdqs qsdqs qsdqs</h2>
<h3>Get VLC: <a href="http://www.videolan.org/vlc/#download" target="_blank">Linux</a> <a href="http://www.videolan.org/vlc/download-windows.html" target="_blank">Windows</a> <a href="http://www.videolan.org/vlc/download-macosx.html" target="_blank">MacOSX</a></h3>
<div id="content"><h3>During the installation make sure to check the firefox plugin !</h3></div>
<div id="content"><h3>During the installation make sure to check the mozilla plugin !</h3></div>
<img src="images/install.jpg" width="316px" height="243px" alt="Install VLC and the mozilla plugin" />
<a href="#" id="close">Close</a>
</div>
Expand Down
8 changes: 4 additions & 4 deletions assets/www/js/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
21:"If the stream is choppy, try reducing the bitrate or increasing the cache size.",
22:"Try it instead of H.263 if video streaming is not working at all !",
23:"The H.264 compression algorithm is more efficient but may not work on your phone...",
24:"You need to install VLC first !",
24:"You need to install or update VLC and the VLC mozilla plugin !",
25:"During the installation make sure to check the firefox plugin !",
26:"Close",
27:"You must leave the screen of your smartphone on !",
Expand Down Expand Up @@ -72,7 +72,7 @@
21:"Si le stream est saccadé essaye de réduire le bitrate ou d'augmenter la taille du cache.",
22:"Essaye le à la place du H.263 si le streaming de la vidéo ne marche pas du tout !",
23:"Le H.264 est un algo plus efficace pour compresser la vidéo mais il a moins de chance de marcher sur ton smartphone...",
24:"Tu dois d'abord installer VLC !!",
24:"Tu dois d'abord installer ou mettre à jour VLC et le mozilla plugin !",
25:"Pendant l'installation laisse cochée l'option plugin mozilla !",
26:"Fermer",
27:"Tu dois laisser l'écran de ton smartphone allumé",
Expand Down Expand Up @@ -119,7 +119,7 @@
21:"Если поток прерывается, попробуйте уменьшить битрейт или увеличив размер кэша.",
22:"Если топоковое видео не работает совсем, попробуйте сжатие Н.263",
23:"Алгоритм сжатия H.264, является более эффективным, но может не работать на вашем телефоне ...",
24:"Вначале Вам необходимо установить VLC !",
24:"You need to install or update VLC and the VLC mozilla plugin !",
25:"При установке убедитесь в наличии плагина для firefox !",
26:"Закрыть",
27:"Вам надо отойти от вашего смартфона.",
Expand Down Expand Up @@ -164,7 +164,7 @@
21:"Wenn das Stream ruckartig ist, versuch mal die Bitrate zu reduzieren oder die Größe vom Cache zu steigern.",
22:"Probier es ansatt H.263, wenn das Videostream überhaupt nicht funktionert !",
23:"Der H.264 Kompressionalgorithmus ist effizienter aber er wird auf deinem Handy vielleicht nicht funktionieren...",
24:"Du musst zuerst VLC installieren !!",
24:"You need to install or update VLC and the VLC mozilla plugin !",
25:"Während der Installation, prüfe dass das Firefox plugin abgecheckt ist!",
26:"Zumachen",
27:"Du musst den Bildschirm deines Smartphones eingeschaltet lassen !",
Expand Down
52 changes: 41 additions & 11 deletions assets/www/js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
var audioPlugin;
var audioStream;
var error;
var volume;

function stream(object,type,done) {

Expand Down Expand Up @@ -92,16 +93,22 @@
$.ajax({type: 'POST', url: 'request.json', data: JSON.stringify(data), success:success, error:error});
}

function updateBatteryLevel(level) {
$('#battery>#level').text(level);
function updatePhoneStatus(data) {

if (data.volume !== undefined) {
volume = data.volume;
$('#sound>#volume').text(volume.current);
}
$('#battery>#level').text(data.battery);

setTimeout(function () {
sendRequest(
"battery",
[{"action":"battery"},{"action":"volume"}],
function (e) {
updateBatteryLevel(e.battery);
updatePhoneStatus(e);
},
function () {
updateBatteryLevel('??');
updatePhoneStatus({battery:'??'});
}
);
},100000);
Expand Down Expand Up @@ -159,6 +166,13 @@
}
}

function testVlcPlugin() {
if (videoPlugin[0].VersionInfo === undefined || videoPlugin[0].VersionInfo.indexOf('2.0') === -1) {
$('#error-noplugin').fadeIn();
$('#glass').fadeIn();
}
}

function generateUriParams(type) {
var audioEncoder, videoEncoder, cache, rotation, flash, camera, res;

Expand Down Expand Up @@ -384,6 +398,20 @@
$('#need-help').hide();
});

$('#sound #plus').click(function () {
volume.current += 1;
if (volume.current > volume.max) volume.current = volume.max;
else sendRequest([{'action':'volume','set':volume.current}]);
$('#sound>#volume').text(volume.current);
});

$('#sound #minus').click(function () {
volume.current -= 1;
if (volume.current < 0) volume.current = 0;
else sendRequest([{'action':'volume','set':volume.current}]);
$('#sound>#volume').text(volume.current);
});

window.onbeforeunload = function (e) {
videoStream.stop();
audioStream.stop();
Expand All @@ -399,19 +427,21 @@
audioPlugin = $('#vlca');
audioStream = stream(audioPlugin[0],'audio',updateStatus);

sendRequest([{'action':'sounds'},{'action':'screen'},{'action':'get'},{'action':'battery'}], function (data) {
testVlcPlugin();

sendRequest([{'action':'sounds'},{'action':'screen'},{'action':'get'},{'action':'battery'},{'action':'volume'}], function (data) {

// Verify that the screen is not turned off
// Verifies that the screen is not turned off
testScreenState(data.screen);

// Fetch the list of sounds available on the phone
// Fetches the list of sounds available on the phone
loadSoundsList(data.sounds);

// Retrieve the configuration of Spydroid on the phone
// Retrieves the configuration of Spydroid on the phone
loadSettings(data.get);

// Retrieve the battery level
updateBatteryLevel(data.battery);
// Retrieves volume and battery level
updatePhoneStatus(data);

});

Expand Down
17 changes: 16 additions & 1 deletion assets/www/less/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ a {
}
a:hover {
color: lighten(red,20%);
cursor: pointer;
}


Expand Down Expand Up @@ -331,7 +332,7 @@ section {

#error-noplugin {
width: 600px;
height: 420px;
height: 460px;
h3 {
margin-top: 15px;
}
Expand Down Expand Up @@ -455,6 +456,20 @@ footer {

}

#sound {
#plus,#minus {font-size: 24px;}
#volume {font-size: 14px;}
>div {
text-align: center;
width: 28px;
}
position: absolute;
z-index: -1;
bottom: 25px;
left: -28px;
background: rgba(7, 63, 131, 0.2);
}

#battery {

position: absolute;
Expand Down
8 changes: 5 additions & 3 deletions assets/www/less/styles.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions assets/www/less/vlc.less
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,5 @@
padding: 5px 20px 4px 20px;
background: rgba(7, 63, 131, 0.2);
}
#fullscreen:hover {
cursor: pointer;
color: lighten(red,20%);
}


}
14 changes: 14 additions & 0 deletions src/net/majorkernelpanic/spydroid/api/RequestHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ static public String handle(String request) {
* -> "state": returns a JSON containing information about the state of the application
* -> "battery": returns an approximation of the battery level on the phone
* -> "buzz": makes the phone buuz
* -> "volume": sets or gets the volume
* @throws JSONException
* @throws IllegalAccessException
* @throws IllegalArgumentException
Expand Down Expand Up @@ -230,6 +231,19 @@ else if (action.equals("buzz")) {
vibrator.vibrate(300);
response.append("[]");
}

// Sets or gets the system's volume
else if (action.equals("volume")) {
AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
if (object.has("set")) {
audio.setStreamVolume(AudioManager.STREAM_MUSIC, object.getInt("set"), AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
response.append("[]");
} else {
int max = audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
int current = audio.getStreamVolume(AudioManager.STREAM_MUSIC);
response.append("{\"max\":"+max+",\"current\":"+current+"}");
}
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected static String printBuffer(byte[] buffer, int start,int end) {

protected static class Statistics {

public final static int COUNT=50;
public final static int COUNT=500000;
private float m = 0, q = 0;

public void init(long value) {
Expand Down

0 comments on commit dcc9143

Please sign in to comment.