chessdragon136 677 Posted February 9, 2014 Share Posted February 9, 2014 Hi All, Recently I started some basic analysis of the Samsung API for creating a Smart TV App. However I have come across a problem in using the API.. I have been able to get a user authorised but I cannot get the playingitems api call to register with the server... Below are the specifics: Code: xmlHttp = new XMLHttpRequest(); url = "http://localhost:8096/mediabrowser/Users/4b4c128121aa642086bb225659a7d471/PlayingItems/f47f23a1c91263c853c928002ef2fdbd?CanSeek=false&QueueableMediaTypes=video"; alert (url); xmlHttp.open( "POST", url , false ); xmlHttp.setRequestHeader("Authorisation", "MediaBrowser"); xmlHttp.setRequestHeader("UserId", "4b4c128121aa642086bb225659a7d471"); xmlHttp.setRequestHeader("Client", "other"); xmlHttp.setRequestHeader("Device", "Samsung TV"); xmlHttp.setRequestHeader("DevideId", "0000000000001"); xmlHttp.setRequestHeader("Version", "1.0.0.0"); xmlHttp.setRequestHeader("Content-Type", 'application/json; charset=UTF-8'); xmlHttp.send(null); alert (xmlHttp.responseText); I get no responseText which I assume is ok (none seems defined in the API docs) but nothing shows up in the active connections either in the dashboard.. Have tried to look through the logs but I don't see anything - If i send the values through as a JSON in the body I get a nullreference error.. I assume I'm completely misunderstanding the API at this point - probably being dumb!! Thanks Link to comment Share on other sites More sharing options...
Luke 37116 Posted February 9, 2014 Share Posted February 9, 2014 the identification values are not separate values, they all go into authorization. use the chrome debugger in the web client to see an example. Link to comment Share on other sites More sharing options...
chessdragon136 677 Posted February 9, 2014 Author Share Posted February 9, 2014 Ok thanks - Have altered it to be: xmlHttp = new XMLHttpRequest(); url = "http://localhost:8096/mediabrowser/Users/4b4c128121aa642086bb225659a7d471/PlayingItems/f47f23a1c91263c853c928002ef2fdbd?CanSeek=false&QueueableMediaTypes=video"; alert (url); xmlHttp.open( "POST", url , false ); xmlHttp.setRequestHeader("Authorization", "MediaBrowser Client='Android', Device='Samsung Smart TV', DeviceId='00000000000000000000000000000000', Version='1.0.0.0', UserId='4b4c128121aa642086bb225659a7d471'"); xmlHttp.setRequestHeader("Content-Type", 'application/json; charset=UTF-8'); xmlHttp.send(null); alert (xmlHttp.responseText); What API requirements do I need to fulfil to get it showing in the Active Connections on the dashboard? And are there any server side tools that i can use to check the headers are sent correctly? Thanks, Link to comment Share on other sites More sharing options...
Luke 37116 Posted February 9, 2014 Share Posted February 9, 2014 you need to authenticate and that should be about it. the dashboard will show the session without an image, but that can be added later. Link to comment Share on other sites More sharing options...
chessdragon136 677 Posted February 9, 2014 Author Share Posted February 9, 2014 I was hoping you wouldn't say that.. I authenticate on the program launch and get the below in the log file "2014-02-09 17:05:49.5503 Info - App: Authentication request for Steve has succeeded." xmlHttp = new XMLHttpRequest(); url = this.ServerURL + "/Users/AuthenticateByName?format=xml"; xmlHttp.open( "POST", url , false ); xmlHttp.setRequestHeader("Content-Type", 'application/xml'); //The below needs to become dynamic at some point! var params = "<AuthenticateUserByName xmlns:i='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://schemas.datacontract.org/2004/07/MediaBrowser.Api'><Password>REMOVED for security</Password><Username>Steve</Username></AuthenticateUserByName>"; xmlHttp.send(params); alert (xmlHttp.responseText); Any thoughts? - Feel free to ask for logs if need Link to comment Share on other sites More sharing options...
Luke 37116 Posted February 9, 2014 Share Posted February 9, 2014 then something in the auth header is not matching up. compare it to chrome. 1 Link to comment Share on other sites More sharing options...
chessdragon136 677 Posted February 9, 2014 Author Share Posted February 9, 2014 (edited) Ok it now shows in the dashboard but doesnt show the playing video - its progress - Thanks for your help Edited February 9, 2014 by chessdragon136 Link to comment Share on other sites More sharing options...
Luke 37116 Posted February 9, 2014 Share Posted February 9, 2014 You might want to use our ready-build sdk: https://github.com/MediaBrowser/MediaBrowser.ApiClient.Javascript At that point all you need to do is review the web client source code for examples: https://github.com/MediaBrowser/MediaBrowser/tree/master/MediaBrowser.WebDashboard/dashboard-ui Link to comment Share on other sites More sharing options...
chessdragon136 677 Posted February 9, 2014 Author Share Posted February 9, 2014 Thanks - Will take a look, although will have to test jQuery on the TV to see if it can handle it Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now