You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

Bug: setClip/setPlaylist not working? Created Nov 13, 2009

This thread is solved

Views: 3988     Replies: 7     Last reply Aug 8, 2011  
You must login first before you can use this feature

Ole Laursen
http://people.iola.dk/olau/

Posts: 4

Registered:
Nov 13, 2009

Bug: setClip/setPlaylist not working?

Posted: Nov 13, 2009

Hi!

I would like to initialize Flowplayer in one place and then afterwards play a clip. The thing is, in some cases I want the clip to auto play, in other cases I just want it to show up with the play button so the user can start it (this depends on where he comes from).

My first try was something like flowplayer("playerid").play({ url: foo, autoPlay: bar}). But play() seems to ignore the autoPlay setting and just play the clip no matter what?

Fair enough. Then I tried flowplayer("playerid").setClip({ url: foo, autoPlay: bar, autoBuffering: true }). But this doesn't seem to work at all. The clip is not loaded, and when I hit the play button with the mouse, the player just hangs with the spinner rotating. Adding a flowplayer("playerid").play(0) call afterwards doesn't help. Same thing happens with setPlaylist. I'm on the latest release, flowplayer-3.1.5.swf and flowplayer-3.1.4.min.js.

For now, I have resolved my problem by dropping the idea of initializing Flowplayer separately (autoplay doesn't seem to be ignored when you pass it in a clip as a config option to begin with).

The new styling stuff is very convenient, by the way! Thanks!

Ole Laursen
http://people.iola.dk/olau/

Posts: 4

Registered:
Nov 13, 2009

» Bug: setClip/setPlaylist not working?

Posted: Nov 13, 2009

Reply to: Bug: setClip/setPlaylist not working?, from olau
Oops, of course I should have reported this in the bug report forum. If someone could move it...

Christian Ebert
Flowplayer support

Posts: 2803

Registered:
May 27, 2008

» » Bug: setClip/setPlaylist not working?

Posted: Nov 14, 2009

Reply to: » Bug: setClip/setPlaylist not working?, from olau
Wait! This works:


window.onload = function () {
  var b = document.getElementsByTagName("button"),
  pl = [
    {url: "clip0.flv", autoPlay: false},
    {url: "clip1.flv", autoPlay: true}
  ],
  p = $f("player", "flowplayer.swf", {
    clip: {
      onUpdate: function (c) {
        if (c.autoPlay) {
          this.play();
        }
      }
    }
  });

  function condplay(c) {
    p.setClip(c).getClip(0).update();
  }

  b[0].onclick = function () {
    condplay(pl[0]);
  };

  b[1].onclick = function () {
    condplay(pl[1]);
  };
};

  • use clip.update() as trigger event
  • the 0 as argument is mandatory for getClip(0), in case the playlist is empty

Christian Ebert
Flowplayer support

Posts: 2803

Registered:
May 27, 2008

» Bug: setClip/setPlaylist not working?

Posted: Nov 14, 2009

Reply to: Bug: setClip/setPlaylist not working?, from olau
Ok, I've tried to clean up my first stab example and make it more general. It's sort of a clip.load function (which might be nice to have):


window.onload = function () {
  var i, b = document.getElementsByTagName("button"),
  pl = [
    {url: "clip0.flv", autoPlay: false},
    {url: "clip1.flv", autoPlay: true}
  ],
  p = $f("player", "flowplayer.swf");

  function condplay() {
    // retrieve playlist index
    var c = pl[parseInt(this.id.substring(1), 10)];
    if (p.getState() > 1) {
      p.stop();
    }
    p.getClip(0).update(c);
    if (c.autoPlay) {
      p.play();
    }
  }

  for (i = 0; i < b.length; i = i + 1) {
    // give button id corresponding to playlist item
    b[i].id = "b" + i;
    b[i].onclick = condplay;
  }
};


<div id="player"></div>

<p>1st clip <button type="button">autoPlay: false</button></p>

<p>2nd clip <button type="button">autoPlay: true</button></p>

Ole Laursen
http://people.iola.dk/olau/

Posts: 4

Registered:
Nov 13, 2009

» » Bug: setClip/setPlaylist not working?

Posted: Nov 16, 2009

Reply to: » Bug: setClip/setPlaylist not working?, from blacktrash
Interesting approach. Thanks for posting it, I'll keep that in mind. I still think there's a bug in there, but maybe I just don't understand how the API is supposed to be used.

Christian Ebert
Flowplayer support

Posts: 2803

Registered:
May 27, 2008

» » » Bug: setClip/setPlaylist not working?

Posted: Nov 16, 2009

Reply to: » » Bug: setClip/setPlaylist not working?, from olau
I agree that not all api methods work as expected. It's sort of absurd to query the autoPlay attribute manually (not "auto" at all ;-) ). I guess autoPlay only has its intended effect when it is set before loading the player.

The problem with the flexibility of the plugin architecture is that the developers cannot imagine what crazy ideas the users will have ;-) See also this bug I opened, which imho is quite serious, as one is not prone to test every possibility oneself.

Anyway, I was just trying to propose a pragmatic solution to your problem.

Ole Laursen
http://people.iola.dk/olau/

Posts: 4

Registered:
Nov 13, 2009

» » » » Bug: setClip/setPlaylist not working?

Posted: Nov 16, 2009

Reply to: » » » Bug: setClip/setPlaylist not working?, from blacktrash
Yep, and I really appreciate that. :) That snippet will come in handy. Thanks!