Javascript control

Control the player with JS
Hi Plex developers!

I'm currently working on a plugin for a videosite, where I have control (as in code) over the player (or players, it is using both silverlight and flash depending on content).
All this siteconfig-working-with-pixel-locations and all is an innovative and impressive solution, but I'm thinking.. Both Flash and Silverlight allows communication with the host document, so if one have control over the player, I could let it call JS functions with status updates (seek position, playback status etc), and the other way around, let JS functions call the player (play/pause/seek).

What my question is, as you might guess, what would I need to do to utilize this in PMS? What changes would be required?
I haven't been able to find the source for the PMS (maybe I just need someone pointing me in the right direction, but I downloaded the Plex source from github and couldnt find it?) so I don't really have any clues about the inner workings of these parts. I'm not very familiar with webkit, but I guess it shouldn't be impossible to let the application using it interact with any javascripts on the rendered page?

If anyone got any input, I'd love to hear it!

Thanks for great software!

Welcome to the forums!




There is good support for Javascript "seekbars", this is an example of one:


	<seekbar type="javascript"><br />
			<percentComplete equals="$.currentTime()/$.duration() * 100.0" /><br />
			<bigStep minus="$.seek($.currentTime() - 30)" plus="$.seek($.currentTime() + 30)" /><br />
			<smallStep minus="$.seek($.currentTime() - 10)" plus="$.seek($.currentTime() + 10)" /><br />
			<end condition="$.currentTime() > 0 &amp;&amp; $.currentTime() > $.duration()" /><br />
	</seekbar>



You should be able to get this working with your player without much trouble. The $ is replaced with the player object.



The source for the Media Server is closed, at least for the moment. However, let me know if the above doesn't work for you, and I'd be happy to assist you more!

Cheers.

Oh, that is great!



I’ll try it out and report back! :slight_smile: Is there more javascript support? Or is there any docs regarding this yet?



Thanks!

Hello again!



This works like a charm! :slight_smile: How about other features? position/duration of movie; pause; etc etc



Thanks!



Glad to hear!

You can use Javascript in three areas:

1) The seekbar, as above

2) In conditions, like so:


<condition><br />
   <javascript script="isPlayingVar" matches="0" /><br />
</condition



3) In actions, like so:


<action><br />
	<run script="abcdm.abc.com.utils.lightfep.launch()" /><br />
</action>



Let me know if you have any more questions!

Cool, thanks :slight_smile: Works great, implemented pause/play & seek now. Haven’t seen much more features in the other siteconfigs though… There is a few features (some more, some less, “realistic”) that I’m thinking about:


  • Extracting duration/position (instead of just percentComplete)
  • When aborting a movie prematurely (Esc), store position and when restarting it, pass it somehow; just like normal local video items (“Play from 05:22”)
  • Extract information about available subtitles, and sending back info about chosen subtitle (in plex GUI)



    Also, is there any cookie sharing between the HTTP python class (HTTP.__cookieJar) that my plugin utilizes, and the WebVideo playback (webkit?)? Or will I have to pass any identification strings on the URL?



    Otherwise, this looks great! Both Silverlight and Flash implemented here… :slight_smile:



    I’ve also read about plans to control the buffersize of regular video items, so you don’t have to download the full videos (for ie smaller trailers etc), any idea when this will be available? Also, you probably already know about http://h264.code-shop.com/trac/wiki/WikiStart (based on http://h264.code-shop.com/trac/wiki/Mod-H264-Streaming)), but if not, that could be some interesting reading :slight_smile:



    Cheers!

bump… Any ideas if any of the above have any chances of being doable? :slight_smile: Too bad you haven’t decided to open-source it yet hehe hint hint:wink:

Sorry for the delay in reply…gotta run out now, but I’ll read and fully reply a bit later on today.



No plans to do this at the moment.



We'd like to definitely add this at some point. For some sites (e.g. Hulu) might not work great because bit skips force commercial breaks.



No plans to do this at the moment, I think I've only seen one or two sites that offer the subtitles, and synchronizing the Webkit video with subtitles doesn't seem very doable.



There is not any sharing at the moment.



The next version of Plex will allow plug-ins to set bitrate on individual video items.

Hi, thanks for your response!



Okay, just seemed like it would be pretty related to the percent function, this is probably on the top of my whishlist.. :)


Okay



Ah, the way I was thinking was when the Flash/Silverlight player plays the subtitle itself:

1. Player loads
2. PMS asks player for available subtitles (ie $.getSubs() which might return {1:English, 2:Swedish, 3:Danish})
3. The available subtitles are presented in the regular subtitle menu.
4. When a user selects a specific subtitle, PMS performs another call to the player, ie $.setSub(1) for English in the above example.

I realize that this probably won't be usable on that many sites though... So.. if you have no interest in implementing this, but feel that you could release (privately or publicly) the code, I'd be glad to take a look at it!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.