Skip to content

Commit

Permalink
sketch out MakeTrack
Browse files Browse the repository at this point in the history
may change this to be done on the playlist level
  • Loading branch information
cbaggers committed Jul 26, 2017
1 parent d7d6e6d commit 9381886
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Examples/Basics/Artist.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var refreshClicked = function() {

var trackClicked = function(item) {
console.log("play all of: " + JSON.stringify(item.data.name));
router.goto("play", { "artistID" : item.data.name});
router.goto("play", { "artistID" : item.data.name });
};

module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions Examples/Basics/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ var tracks = Observable();
var paramObs = this.Parameter.onValueChanged(module, function(param) {
MediaQuery.tracks({ "artist": param["artistID"] }).then(function(tracksArray) {
var tmp = tracksArray.map(function(track, index) {
return {
return StreamingPlayer.makeTrack({
"id": index,
"name": track["title"],
"artist": track["artist"],
"url": track["path"],
"artworkUrl":"https://everyweeks.com/pZ2j56doGB6c0ykra8lXMj7nuNTDsT79-logo.png",
"duration": track["duration"]
};
});
});
tracks.addAll(tmp);
StreamingPlayer.setPlaylist(tmp);
Expand Down
11 changes: 11 additions & 0 deletions src/JS.uno
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace StreamingPlayer
Marshal.AddConverter(new TrackConverter());

Resource.SetGlobalKey(_instance, "FuseJS/StreamingPlayer");
AddMember(new NativeFunction("makeTrack", (NativeCallback)MakeTrack));
AddMember(new NativeFunction("next", (NativeCallback)Next));
AddMember(new NativeFunction("previous", (NativeCallback)Previous));
AddMember(new NativeFunction("backward", (NativeCallback)Backward));
Expand All @@ -39,6 +40,7 @@ namespace StreamingPlayer
AddMember(new NativeFunction("pause", (NativeCallback)Pause));
AddMember(new NativeFunction("stop", (NativeCallback)Stop));
AddMember(new NativeFunction("seek", (NativeCallback)Seek));
AddMember(new NativeFunction("setNextPrevBehavior", (NativeCallback)SetNextPrevBehavior));

AddMember(new NativeProperty<PlayerStatus,string>("status", GetStatus, null, PlayerStatusConverter.Convert));

Expand Down Expand Up @@ -82,6 +84,15 @@ namespace StreamingPlayer
Emit("statusChanged", status.Stringify());
}

public object MakeTrack(Context c, object[] args)
{
if (!_playerInitialized) return null;
var jsObject = (Fuse.Scripting.Object)args[0];
if (!jsObject.ContainsKey("uid"))
jsObject["uid"] = Track.NewUID();
return jsObject;
}

public object Next(Context c, object[] args)
{
if (!_playerInitialized) return null;
Expand Down
3 changes: 1 addition & 2 deletions src/Track.uno
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ namespace StreamingPlayer
{
if (CanConvert(t))
{
debug_log("MUST FIX TRYCONVERT");
var jsObject = (Fuse.Scripting.Object)o;
var uid = Track.NewUID(); //Marshal.ToInt(jsObject["uid"]);
var uid = Marshal.ToInt(jsObject["uid"]);
var name = jsObject["name"].ToString();
var artist = jsObject["artist"].ToString();
var url = jsObject["url"].ToString();
Expand Down

0 comments on commit 9381886

Please sign in to comment.