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

Your preferred username that is used when logging in.

Missing clip - Change URL Created Jul 21, 2010

This thread is solved

Views: 2778     Replies: 15     Last reply Sep 2, 2010  
You must login first before you can use this feature

sgentry

Posts: 6

Registered:
Jun 14, 2010

Missing clip - Change URL

Posted: Jul 21, 2010

Similar Solved Post

I saw the above post, but as it was marked solved didn't believe there would be much new traffic.

I am looking to change the URL of a clip when the stream is not found. I am properly configuring the onError event, as I can debug the specific line or add an alert, but what I am having trouble with is the following:


onError : function(errorCode, errorMessage) {
    this.getClip(0).update( { url : 'http://full-url.com/images/stream-not-found.png' } );
}

The problem is this image is never being loaded to the player upon the error -- I get a stream not found error message and then the player continues to look for this unfound stream. I'm able to hit the URL and see the image, but am unable to change over upon stream not found.

This is somewhat simplified as we are looking to use customized images for each error code.

sgentry

Posts: 6

Registered:
Jun 14, 2010

» Missing clip - Change URL

Posted: Aug 6, 2010

Reply to: Missing clip - Change URL, from sgentry
Anyone have any ideas on this?

newbizlady

Posts: 3

Registered:
Mar 27, 2010

» » Missing clip - Change URL

Posted: Aug 8, 2010

Reply to: » Missing clip - Change URL, from sgentry
Where you ever able to find a solution to this?

Christian Ebert
Flowplayer support

Posts: 2803

Registered:
May 27, 2008

» » Missing clip - Change URL

Posted: Aug 8, 2010

Reply to: » Missing clip - Change URL, from sgentry
I haven't been able to change the clip with getClip().update() after onError. But if you test with an ajax GET call whether the file exists, and then initialize the player accordingly, it should work.

Look at the source of this very simple example here:

http://www.blacktrash.org/test/ajax.html

Perhaps it gives you some ideas. The hard test is with empty browser cache, because then I still get a short glimpse at "Player initialization failed", unless, like in the sample, I put some html content in the player container.

sgentry

Posts: 6

Registered:
Jun 14, 2010

» » » Missing clip - Change URL

Posted: Aug 9, 2010

Reply to: » » Missing clip - Change URL, from blacktrash
Unfortunately we're not dealing with files, but rather live streams.

Sometimes these live streams haven't quite yet started yet, and unfortunately jQuery won't allow an ajax call to an rtmp url.

Will keep looking though.

Christian Ebert
Flowplayer support

Posts: 2803

Registered:
May 27, 2008

» » » » Missing clip - Change URL

Posted: Aug 9, 2010

Reply to: » » » Missing clip - Change URL, from sgentry
Then try to unload the player onError and reload it to play the next url.

Mdukizi

Posts: 5

Registered:
Aug 31, 2010

Change clip url via href dom manipulation

Posted: Aug 31, 2010

Reply to: » » » » Missing clip - Change URL, from blacktrash
Saw this thread was somewhat about changing clip URLs dynamically, so I thought I'd ask here too.

I've got one anchor tag I use as my flowplayer container, and I'm trying to dynamically change the video by manipulating the href via jQuery.

First, I attach an initial flowplayer instance to the first movie when the page loads:
$('#featured').each(function() {
    flowplayer(this, "videos/flowplayer-3.2.3.swf", {
        clip: {
            autoPlay: true,
            onFinish: function() {
                this.unload();
            }   
        }   
    }); 
});
On click of another image which represents another movie I unload the flowplayer instance, then swap the href values for the second movies:
$('#features img.person1').click(function () {
    $f().unload();
    ... // swapping a few other divs of text
    ...
    $('#featured').attr('href','nextvideo.flv');
});
This returns my #featured container to a placeholder image (a css background-image on the anchor), and I can see that the link target has changed, but clicking the video still loads the initial video.

I read somewhere Tero said that the href needs to be set before the flowplayer instance is created, but I can't seem to figure it out. Is it a matter of loading and unloading?

I guess I could use playlists and splash images, but I really dig the CSS background-image method as it is so clean and doesn't load the flash object until it's needed for playing.

Thanks

Christian Ebert
Flowplayer support

Posts: 2803

Registered:
May 27, 2008

» Change clip url via href dom manipulation

Posted: Aug 31, 2010

Reply to: Change clip url via href dom manipulation, from mdukizi
With a unique id="featured" you obviously do not need the each() method.

As for your actual question: Store the player in a variable, and then simply use the play() method.


// install player in element with id "featured"
var player = flowplayer("featured", "videos/flowplayer-3.2.3.swf", {
  // player configuration here
});

$("#features img.person1").click(function () {
  player.play("nextvideo.flv");
  // disable normal link behaviour
  return false;
});

More on player methods here:

http://flowplayer.org/documentation/api/player.html#methods

Here's a simple demo that does something similar, but without jQuery:

http://www.blacktrash.org/test/xplay.html

Mdukizi

Posts: 5

Registered:
Aug 31, 2010

changing clips with player unloading

Posted: Sep 1, 2010

Reply to: » Change clip url via href dom manipulation, from blacktrash
Thanks for the pointers. The way you've done it works, and I now have dynamic swapping of clips based on clicks to other areas of the page. My problem is that I want to both swap the flv path, and unload the player so that the html is shown.

I load the first video into the container anchor tag:
$('#featured').flowplayer("videos/flowplayer-3.2.4.swf", {
    clip: {
        autoPlay: false,
        onFinish: function() {
            this.unload()
        }
    }
});
On clicking somewhere else I can then bind a click event to .unload() the player, but then changing the flv path seems to not work.

The player API methods are very well documented and I will look over them to get a better idea of how to interact with the player.

By the way, I was having problems setting my flowplayer instance to a variable; the embedding works, but then accessing via player.play(), etc, was telling me there was no method associated with the variable. I was using this code:
var player = $('#featured').flowplayer("videos/flowplayer-3.2.4.swf");

Thanks. Back to the drawing board!

Christian Ebert
Flowplayer support

Posts: 2803

Registered:
May 27, 2008

» changing clips with player unloading

Posted: Sep 1, 2010

Reply to: changing clips with player unloading, from mdukizi
Why would you need to change the flv path?

Why don't you initialize the player like I proposed:


var player = flowplayer("featured", "videos/flowplayer-3.2.4.swf", {
  clip: {
    autoPlay: false,
    onFinish: function () {
      this.unload();
    }
  }
});

And then, as I said, call player.play("clipurl").

The above works with jquery too, only for ids the selector in the 1st argument to flowplayer is done without the hash #.

Please see:

http://flowplayer.org/documentation/api/index.html

on variations on how to install the player.

Mdukizi

Posts: 5

Registered:
Aug 31, 2010

player manipulation and unloading

Posted: Sep 1, 2010

Reply to: » changing clips with player unloading, from blacktrash
Gotcha, I now see that flowplayer() selects an ID without the hash. I had continually overlooked that. Setting a variable to a flowplayer instance is a really neat way to control the player, thanks. :)

Regarding changing the flv path: I have two videos, both with their own splash screen. I want to unload the player and show a splash screen before playing the flv. If I use player.play("new.flv") it is played immediately.

I really like using the CSS splash method because it degrades gracefully when Flash or Javascript are not available, not to mention using a CSS background-image with a "play" button overlaid is really cool.

I thought it would be enough to:
  1. Change the splash using jQuery
  2. unload() the player (user then sees the splash for video2
  3. Change the container A's href
  4. Then load() the player into the container again
This way, clicking the new splash would play video 2, but flowplayer always plays the flv which was originally specified in the href.

Thanks for the tips, by the way. It's been a great help.

Christian Ebert
Flowplayer support

Posts: 2803

Registered:
May 27, 2008

» player manipulation and unloading

Posted: Sep 1, 2010

Reply to: player manipulation and unloading, from mdukizi
I probably would update the html content either in the onFinish of the clip (possibly doing different things depending upon the clip's url) or in the onUnload event of the player.

I would not bother trying to update the href attribute of the container but try to update the clip:


player.getClip().update({url: "secondvideo.flv"});

See:

http://flowplayer.org/documentation/api/clip.html#update

Mdukizi

Posts: 5

Registered:
Aug 31, 2010

configuring an unloaded player

Posted: Sep 1, 2010

Reply to: » player manipulation and unloading, from blacktrash
I think I've made progress. Here's what works...

If I change the URL of the clip using player.getClip().update({url: clipURL});, then I can swap the CSS background-image on the container. If the player is configured with onUpdate: function() { this.unload() } then the user sees the desired splash image for the video he chose, and upon clicking the correct flv is loaded.

Code:

$("a.video").click(function() {
    var clipURL = $(this).attr("href");
    var anchorID = $(this).attr("id");

    if(player.isLoaded()) {
        player.getClip().update({url: clipURL});
    }

    // swap the splash image
    $("#player").css("background-image","url("+images[anchorID]+")");

    return false;
});

The downside is that this doesn't work if flowplayer is not loaded (ie, the user picks video2 before he clicks video1).

I've put up a sample here:http://thefro.org/test/swap/

Also, I noticed your example behaves oddly as well if you click "trailer 1" or "trailer 2" before you've loaded the main movie.

Christian Ebert
Flowplayer support

Posts: 2803

Registered:
May 27, 2008

» configuring an unloaded player

Posted: Sep 2, 2010

Reply to: configuring an unloaded player, from mdukizi
"oddly" in what way? It works for me[tm], but maybe I've overlooked something.

Christian Ebert
Flowplayer support

Posts: 2803

Registered:
May 27, 2008

» configuring an unloaded player

Posted: Sep 2, 2010

Reply to: configuring an unloaded player, from mdukizi
Oh, sorry, use 0 as playlist index argument to getClip:


player.getClip(0).update({url: "different.flv"});

then the player does not have to be loaded.

Mdukizi

Posts: 5

Registered:
Aug 31, 2010

Solved

Posted: Sep 2, 2010

Reply to: » configuring an unloaded player, from blacktrash
Ahhh... getClip(0) was the key. It's now working on my test setup here:http://thefro.org/test/swap/

The trick was testing if the player is loaded:

if(player.isLoaded()) {
  player.getClip().update({url: clipURL});
}   
else {
  player.getClip(0).update({url: clipURL});
}

Thanks for the pointers, I really appreciate it. Flowplayer's well documented but it's hard to navigate if you're new to the API.