Pages: [1]
  Print  
Author Topic: Help with Seek function  (Read 382 times)
mosk
Gaia Expert
****
Posts: 207


« on: August 19, 2011, 10:24:36 AM »

Just tried this in a regular Flash CS4 document to see if I was having an issue with Gaia or just plain flash:

imported an flv through Flash Interface, which resulted in an FLVPlayback being placed on the stage.
Named this myVidFHIntro

In actions panel:
Code:
myVidFHIntro.seek(350);
myVidFHIntro.play();

This worked fine - video started playing from 350 seconds into the flv.

I can't get the seek function to work inside of Gaia - video will only play from the very beginning.

I've tried the following code (where seekVal is a Number saying how far into flv to start):
Code:
INetStream(Gaia.api.getPage(videoAssetOfThisPage).assets[myVideoId]).seek(seekVal);
INetStream(Gaia.api.getPage(videoAssetOfThisPage).assets[myVideoId]).play();

and

Code:
ns = Gaia.api.getPage(videoAssetOfThisPage).assets[id] as INetStream;

if (ns)
{
ns.attach(myVideo);
Gaia.api.getDepthContainer(Gaia.MIDDLE).addChild(myVideo);
addVideoBtns();
}
ns.play();


Does seek only work if you have an FLVPlayback component or should I be able to use it purely through AS3?

Thanks for any help.

Logged
Ramiro
Moderator
Gaia Addict
*****
Posts: 861


interactive pragmatism


« Reply #1 on: August 20, 2011, 05:53:46 AM »

Is the video asset loaded when you call seek?
Logged
mosk
Gaia Expert
****
Posts: 207


« Reply #2 on: August 20, 2011, 08:34:39 PM »

Hiw can I check to see if my video is already loaded?

Nemo had once mentioned something about an isLoaded flag for videos- but he wasn't sure the exact name, I haven't been able to find it on forum search, and I don't know anything about it.

Thanks.
Logged
Ramiro
Moderator
Gaia Addict
*****
Posts: 861


interactive pragmatism


« Reply #3 on: August 21, 2011, 06:23:45 AM »

I meant the asset with preaload="false" or not. If it's loaded, I see nothing wrong in calling the seek method of the netstream object. Should work. Did you try with other video files? Sometimes they're poorly encoded, have very few keyframes, etc.
Logged
mosk
Gaia Expert
****
Posts: 207


« Reply #4 on: August 21, 2011, 05:55:03 PM »

Can't check my code right now, but I think I had preload set to false for all of my video assets.  If that's the case, I'll set preload to true in my xml and see if that fixes the problem.  

In some cases it will be fine to set preload to true.

For those cases where that wouldn't make sense (where I might have 10 videos and only want to load one if and when a user clicks on it), can you explain what I'd need to do within the Gaia framework.  Is there the equivalent of a loader.loadComplete that I'd need to check before performing the seek function?

EDIT - found Documentation on the AssetEvent.ASSET_COMPLETE - will read through that more carefully later and post back if I'm still having problems.



Thanks for your help as always.
« Last Edit: August 21, 2011, 06:00:09 PM by mosk » Logged
Ramiro
Moderator
Gaia Addict
*****
Posts: 861


interactive pragmatism


« Reply #5 on: August 21, 2011, 07:26:29 PM »

well, you can't seek to some point of a video that has not loaded yet, not in progressive video Smiley
Logged
mosk
Gaia Expert
****
Posts: 207


« Reply #6 on: August 26, 2011, 09:27:13 AM »

Hey Ramiro -
Had been out of town.  Just got back and checked my code, and it turns out I already had set preload to true in my site.xml for the flv I'm trying to seek to, so I guess that's not the issue.

Have tried adding the seek command wherever it seemed to make sense, and still can't get my video to start anywhere other than the first frame at time 0.

The video is roughly six minutes long and trace statements show it starting at frame 0
Code:
In onMyCuePoint - id = videoAssetFHTH1 and event.info.time = 0


First I'm setting up my netstream like this:
Code:
ns = Gaia.api.getPage(videoAssetOfThisPage).assets[id] as INetStream;

if (ns)
{
if (videoClickedName == "FHIntro")
{
trace("here Inside prepareVideo where FHIntro is the videoClickedName - - videoAssetOfThisPage = " + videoAssetOfThisPage + " and myVideoId = " + myVideoId);
trace("id = " + id + " and if that's videoAssetFHTH1 will then seek to seekVal of " + seekVal);
INetStream(Gaia.api.getPage(videoAssetOfThisPage).assets[myVideoId]).volume = 1;
INetStream(Gaia.api.getPage(videoAssetOfThisPage).assets[myVideoId]).pan = 0;
INetStream(Gaia.api.getPage(videoAssetOfThisPage).assets[myVideoId]).seek(seekVal); //doesn't help to use a number here in place of seekVal variable
INetStream(Gaia.api.getPage(videoAssetOfThisPage).assets[myVideoId]).play();
INetStream(Gaia.api.getPage(videoAssetOfThisPage).assets[myVideoId]).pause();
trace("B here in prepareVideo = after seeking to seekVal");
INetStream(Gaia.api.getPage(videoAssetOfThisPage).assets[myVideoId].addEventListener(NetStatusEvent.NET_STATUS, onNetStreamStatus, false, 0, true));
INetStream(Gaia.api.getPage(videoAssetOfThisPage).assets[myVideoId].addEventListener(NetStreamAssetEvent.CUEPOINT, onMyCuePoint, false, 0, true));
}

ns.attach(myVideo);
Gaia.api.getDepthContainer(Gaia.MIDDLE).addChild(myVideo);
addVideoBtns();

ns.play();


}

I'm going to try to use the greensock LoaderMax as you'd suggested earlier, but I'd still like to know how to implement a simple seek function within Gaia.  So if you see any issues with the code, please point them out.

Or if you (or anyone) know if seek only works with an FLVPlayback component, please let me know that as well.

Thanks






Logged
Ramiro
Moderator
Gaia Addict
*****
Posts: 861


interactive pragmatism


« Reply #7 on: August 26, 2011, 09:46:47 AM »

Seek works with any type of video loaded into a NetStream object. It works differently depending on progressive or streaming video. If it's progressive, it only works if you have enough video data to seek to that point in time, and if it's streaming I understand it actually ask the media server to jump to that point in time. I'm not sure why cant you make it work, it should be simple :S
Logged
mosk
Gaia Expert
****
Posts: 207


« Reply #8 on: August 30, 2011, 07:07:52 AM »

Hey Ramiro -

The code on my nav page was pretty convoluted, so I created a new Gaia project and started from scratch to try to isolate the problem of getting a video to seek properly without the FLVPlayback component.

I saw the reason documented earlier, but I don't recall why you have to do
Code:
ns.play("myFLV");
ns.pause();

Anyhow, following that with:
Code:
ns.seek(seekVal);
ns.resume();
works fine.  
I had tried using
Code:
INetStream(Gaia.api.getPage(videoAssetOfThisPage).assets[myVideoId]).resume();
earlier, but again, things were fairly convoluted in my real site's code, so I must have messed up somewhere else on that go around.  And for the most part, I was using
Code:
ns.play();
after seeking forward, and that didn't do as well.  I did get some strange behavior in my test, so it still wasn't clear to me if ns.play("myFlv") always starts from the beginning - but I do have things working for the most part now - just need to iron out some sloppy coding I put in place temporarily.

Thanks as always for your help.  It's made the difference on many occasions between my remaining completely stuck and figuring out the way to inch forward.    
« Last Edit: August 30, 2011, 08:24:09 AM by mosk » Logged
Pages: [1]
  Print  
 
Jump to:  

TinyPortal v1.0 beta 4 © Bloc