Sign up here and you can log into the forum!

Is there a API i can send a "play file XY" Commando ?

The place for n00b questions, anything goes...no n00b too n00bish.

Is there a API i can send a "play file XY" Commando ?   

Postby pellox » Thu Nov 12, 2015 5:59 am

Since the WD TV can attach NAS Storage and play Files from that local Network drives...

My Question is..

If i know the Network-Drive path, lets say "\\NetworkServer\Folder\Videofile.mkv", is there any way to send the WD TV a Command (maybe from a local Android Phone) to just play this file ?

Best case would be if the WD TV had a API /Method /Webservice that can take such calls


Any Idea ?
pellox
n00b
 
Posts: 7
Joined: Thu Nov 12, 2015 5:44 am

Re: Is there a API i can send a "play file XY" Commando ?   

Postby mad_ady » Mon Nov 16, 2015 12:37 am

You can do this easily via DLNA (with a gui on your phone) and have a DLNA server either on your NAS or your WDTV to index the files.

If you don't want DLNA, you can do it the hard way:
1. Mount your NAS on your WDTV at startup via xmounts
2. Use telnet/ssh and run the command:
Code: Select all
play /path/to/media/file.mp4
User avatar
mad_ady
Developer
 
Posts: 4561
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: Is there a API i can send a "play file XY" Commando ?   

Postby pellox » Sun Jan 17, 2016 7:44 am

@mad_ady
That actually works fine !

What i have done so far is:

I coded a Android App that functions a a bridge between a HTML-List of my Video Files and the WDTV

When i click a movie link, the App is called, opens up a telnet Session via Socket and send the "play /tmp/media/.../video.mp4" (over the same network)

BUT

I have a strange Problem because i cant figure out how i can send the commando with a Videos containing special characters, like "ä" or "ß"
(This problem only occurs on certain videos with special characters)
To set the outputstream to UTF8 didnt solve the Problem neither the US-ASCII.


Anybody has done that before ? (with Java / Sockets )

OR, what encoding is on the WDTV / telnet side ? (Because via Putty i can type special Characters)
pellox
n00b
 
Posts: 7
Joined: Thu Nov 12, 2015 5:44 am

Re: Is there a API i can send a "play file XY" Commando ?   

Postby kroetkroet » Sun Jan 17, 2016 9:49 am

Hello pellox, maybe a stupid idea (but that's why I'm here in the first place): what if you launch with wildcard where the special char popsup? Eg. "play St*rm_des_Lieben.avi" ?

Good luck, KK
WDLXTV-fan! - In case you need further assistance: read our WIKI, search our Forum and most of all: donate 'something' to b-rad for his great efforts!!!
User avatar
kroetkroet
Beta Tester
 
Posts: 1010
Joined: Mon Apr 05, 2010 11:53 pm

Re: Is there a API i can send a "play file XY" Commando ?   

Postby mad_ady » Mon Jan 18, 2016 5:05 am

If the play command can handle special chars, and your mount options don't destroy them (e.g. you can see them correctly using ls), you can either do as KK says (and replace them by a wildcard like * or ?), or try to escape them. Also, use single quotes when passing paths (in the command line).

Since you are building a telnet command to be executed, you can save it to a file, and copy paste the command on the wdtv to see if it executes correctly. Also, you can try to do a packet capture and see what your app actually executes through telnet.
User avatar
mad_ady
Developer
 
Posts: 4561
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: Is there a API i can send a "play file XY" Commando ?   

Postby pellox » Mon Jan 18, 2016 11:58 pm

the option with the wildcards isnt working for the play command so

Code: Select all
play "/path/to/video/drive/Ärger.mp4"
replacend by play
Code: Select all
"/path/to/video/drive/*rger.mp4"
wont work

I checkt with wireshark what bytes are actually send by putty, cause with putty i can send "special Characters".

it seems like it send UTF-8 bytes. so where normally one byte per char 2 bytes where send.

So an putty sends (example)
Code: Select all
a = 0x61 (hex) euals  0110 0001

and in the case of the special character
Code: Select all
ä = 0xc3 0xa4 quals (two bytes) 1100 0011 1010 0100


Java supports UTF-8 and its displayed corrent on the client side. On the telnet side the sepcial character seems to be send as (depends on encoding)
ä (with is the interpretation of two bytes seperatly) or other gliberish symbols.

So since ASCII is a 7 Bit characters, and UTF8 is the the multibyte representation of ASCII but i seems that the WDZV dont unterstand UTF8 when it comes from my java Client


Code explame of the java code
Code: Select all
Socket connection = new Socket( 192.168.0.30", 23); //  Server, Port
OutputStream stream = connection.getOutputStream();
OutputStreamWriter writer = new OutputStreamWriter( stream, "UTF-8" );

writer.write("play \"/path/The Video with ä.mp4\"");
writer.write("\r\n");
writer.flush();
writer.close();
pellox
n00b
 
Posts: 7
Joined: Thu Nov 12, 2015 5:44 am

Re: Is there a API i can send a "play file XY" Commando ?   

Postby mad_ady » Tue Jan 19, 2016 12:38 am

Do you use telnet when connecting with your program and when connecting with putty? There are some telnet options which are negociated between client/server before the actual telnet session begins. If you're using a raw socket those parameters are not negociated. You can check a wireshark capture (e.g. frame 17 from https://wiki.wireshark.org/SampleCaptures?action=AttachFile&do=get&target=telnet-cooked.pcap) and you can see that the terminal type is negociated. You can look for a java telnet client implementation to replace the raw socket.
User avatar
mad_ady
Developer
 
Posts: 4561
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: Is there a API i can send a "play file XY" Commando ?   

Postby pellox » Tue Jan 19, 2016 1:36 am

Yes you are right - its the Terminal negotiotion at the beginning, but seems rather complicated to implement this in Java.

So, maybe im Switching to SSH ...still trying
pellox
n00b
 
Posts: 7
Joined: Thu Nov 12, 2015 5:44 am

Re: Is there a API i can send a "play file XY" Commando ?   

Postby mad_ady » Tue Jan 19, 2016 2:35 am

Don't reinvent the wheel! Try somebody else's wheel for size: https://commons.apache.org/net/examples/telnet/TelnetClientExample.java
User avatar
mad_ady
Developer
 
Posts: 4561
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: Is there a API i can send a "play file XY" Commando ?   

Postby pellox » Wed Jan 20, 2016 12:04 am

Saw the Lib already, but it seems that i really dont have to reinvent the wheel.

Im on it now.

But followup question:

When i Boot up my WDTV the Network mount und /tmp/media/samba / are not mounted automatically (after bootup)
I have to choose "Movies" in the WDTV Menue and then they are mounted


Is there any script or command that i can just call to init the last known samba drives ? (the last step to get rid of the remote controll) =)
pellox
n00b
 
Posts: 7
Joined: Thu Nov 12, 2015 5:44 am

Next

Return to n00b central

Who is online

Users browsing this forum: No registered users and 5 guests