Skip to content
This repository was archived by the owner on May 3, 2019. It is now read-only.

Commit 9717a32

Browse files
shreyanshkColinDuquesnoy
authored andcommitted
Add Wynk Music plugin (#125)
* Add Wynk Music plugin * Wynk: lighten service icon * Wynk: remove icon border * Wynk: update requirement & platform
1 parent 0612d7f commit 9717a32

File tree

4 files changed

+107
-0
lines changed

4 files changed

+107
-0
lines changed

plugins/wynk/integration.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
function readTime(timeString) {
2+
var hours = 0;
3+
var minutes = 0;
4+
var seconds = 0;
5+
var m = timeString.match("\\d+:\\d+:\\d+");
6+
if (m !== null) {
7+
var data = timeString.split(':');
8+
hours = parseInt(data[0]);
9+
minutes = parseInt(data[1]);
10+
seconds = parseInt(data[2]);
11+
} else {
12+
var m = timeString.match("\\d+:\\d+");
13+
if (m !== null) {
14+
var data = timeString.split(':');
15+
minutes = parseInt(data[0]);
16+
seconds = parseInt(data[1]);
17+
}
18+
}
19+
return hours * 3600 + minutes * 60 + seconds;
20+
}
21+
22+
function getHashCode(s) {
23+
return s.split("").reduce(function(a, b) {
24+
a = ((a << 5) - a) + b.charCodeAt(0);
25+
return a & a
26+
}, 0);
27+
}
28+
29+
function update() {
30+
if (document.querySelector("#wynk-player > div > div > div.right-part.cssload-container > span").className === "sprite play") {
31+
playbackStatus = mellowplayer.PlaybackStatus.PAUSED;
32+
} else if (document.querySelector("#wynk-player > div > div > div.right-part.cssload-container > span").className === "sprite pause") {
33+
playbackStatus = mellowplayer.PlaybackStatus.PLAYING;
34+
} else {
35+
playbackStatus = mellowplayer.PlaybackStatus.BUFFERING;
36+
}
37+
duration = document.querySelector("#wynk-player > div > div > div.bottom-part > div.seek-bar > span.right.ng-binding").innerHTML;
38+
position = document.querySelector("#wynk-player > div > div > div.bottom-part > div.seek-bar > span.left.ng-binding").innerHTML;
39+
songTitle = document.querySelector("#wynk-player > div > div > div.left-part > div > p.head > a").innerHTML;
40+
albumTitle = document.querySelector("#wynk-player > div > div > div.left-part > div > p.sub > a").innerHTML;
41+
artUrl = document.querySelector("#wynk-player > div > div > div.left-part > span > img").src;
42+
return {
43+
"playbackStatus": playbackStatus,
44+
"canSeek": false,
45+
"canGoNext": true,
46+
"canGoPrevious": true,
47+
"canAddToFavorites": false,
48+
"volume": 1,
49+
"duration": readTime(duration),
50+
"position": readTime(position),
51+
"songId": getHashCode(songTitle),
52+
"songTitle": songTitle,
53+
"artistName": '',
54+
"albumTitle": albumTitle,
55+
"artUrl": artUrl,
56+
"isFavorite": false
57+
};
58+
}
59+
60+
function play() {
61+
document.querySelector("#wynk-player > div > div > div.right-part.cssload-container > span").click();
62+
}
63+
64+
function pause() {
65+
play();
66+
}
67+
68+
function goNext() {
69+
document.querySelector("#wynk-player > div > div > div.bottom-part > div.prev-next > span.next > a").click();
70+
}
71+
72+
function goPrevious() {
73+
document.querySelector("#wynk-player > div > div > div.bottom-part > div.prev-next > span.prev > a").click();
74+
}
75+
76+
function setVolume(volume) {
77+
//not implemented
78+
}
79+
80+
function addToFavorites() {
81+
//not implemented
82+
}
83+
84+
function removeFromFavorites() {
85+
//not implemented
86+
}
87+
88+
function seekToPosition(position) {
89+
//not implemented
90+
}

plugins/wynk/metadata.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
author=Shreyansh Khajanchi
2+
author_website=http://www.shreyanshja.in/
3+
icon=wynk-music-icon.png
4+
name=Wynk
5+
require_proprietary_codecs=true
6+
supported_platforms=All
7+
url=https://www.wynk.in/music
8+
version=1.0

plugins/wynk/theme.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"accent": "#ffffff",
3+
"background": "#ffffff",
4+
"foreground": "#505050",
5+
"primary": "#2b1d10",
6+
"primaryForeground": "#ffffff",
7+
"secondary": "#2b1d10",
8+
"secondaryForeground": "#ffffff"
9+
}

plugins/wynk/wynk-music-icon.png

6.66 KB
Loading

0 commit comments

Comments
 (0)