User Tag List

Results 1 to 5 of 5

Thread: Web View object Javascript example?

  1. #1
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleiOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)
    ratty's Avatar
    Join Date
    Apr 2012
    Posts
    1,165
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Web View object Javascript example?

    This is my first foray into Javascript, so please bear with me.

    I'm trying to insert a bit of Javascript code that will pause a Youtube video being played. The Youtube API shows that "player.playVideo():Void" and "player.pauseVideo():Void" should play and pause the video. I just don't understand how I input those bits of code into the Web View object. I see that I can go to Web View>Javascript>Execute Snippet and enter a bit of code, but how do those snippets work in the expression editor? Perhaps it's obvious to those who understand Javascript, while I do not, unfortunately.

    Any insight is greatly appreciated.

  2. #2
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    The WebView object won't do what you want, because it's based on Internet Explorer 7, which is poo - you can load a video, but not send commands for play/pause/stop/etc, and you'll also get a security warning about ActiveX pop up (someone *really* needs to make a Webkit / V8 based extension).
    Anyway, I see you have Developer, so you should be able to use WebX instead, shouldn't you?

    Don't use HTML snippets - load an html file instead.
    I only use MMF2 Standard, so can't help you with WebX, but the required code should not be complicated - something approximately like this:

    <div id='ytplayer'></div>
    <script src="https://www.youtube.com/player_api"></script>
    <script>
    var player;
    function onYouTubePlayerAPIReady() {
    player = new YT.Player('ytplayer', { height: '390', width: '640', videoId: 'M7lc1UVf-VE' });
    }

    function playVid() {
    player.playVideo();
    }
    </script>

    What that does is:
    Create an IFrame element with the id "ytplayer" in which to display the video.
    Load the YouTube player API (script), and then when it finishes loading...
    Create a YT.Player object called "player" - using a constructor function defined in the API, taking the IFrame's Id as one argument, and a list of parameters as another.
    Create a function to play the video - calling the function "playVid" from within MMF2 will make the video start playing (note that "playVideo" is a method belonging to the object "player").

  3. #3
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleiOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)
    ratty's Avatar
    Join Date
    Apr 2012
    Posts
    1,165
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Thanks, muddy. I seem to get a script error when I do that. Perhaps I'm not doing it right. I'll keep playing with it but if you or anyone has any more advice, I'm all ears. This is a realm I'm not experienced in.

    Additionally, what are the differences between WebView and WebX? I've never really known.

  4. #4
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    WebX is just a more feature-rich version, but for some reason it requires Developer.
    I believe it can use Internet Explorer 9 & 10, which would help you here. It also allows you to call MMF2 functions from within a script (like you can with the Lua extensions etc), which would be of more interest to me. Don't know about the other differences...

  5. #5
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleiOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)
    ratty's Avatar
    Join Date
    Apr 2012
    Posts
    1,165
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Wow, you aren't kidding. I haven't played with these web items much in the past besides the GET object. WebX/Web Control is loaded! I found the 'Set Focus by XY' action to take care of the issue rather well. Just focus where the video will be and the normal youtube commands work!

    So what happens if a user doesn't have the proper version of Internet Explorer installed? Does the object just not work?

Similar Threads

  1. List View Object Bug
    By ekr3peeK in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 15th December 2013, 12:58 AM
  2. Web View Object
    By strito in forum Android Export Module Version 2.0
    Replies: 3
    Last Post: 20th May 2013, 04:50 PM
  3. Javascript call with JS Object as parameter
    By netninja in forum SWF/Flash Export Module Version 2.0
    Replies: 2
    Last Post: 19th July 2010, 02:49 PM
  4. List View object bug
    By Wingamez in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 16th August 2006, 07:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •