Visualizzazione dei risultati da 1 a 7 su 7

Discussione: Playing an FLV

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2004
    Messaggi
    45

    Playing an FLV

    ciao ragazzi, spero di non annoiarvi con le mie piccole (ma per me "enormi") domande.
    ho un video (dream.swf) che voglio caricare con AS in un contenitore_mc che viene creato ad hoc per visualizzare questo video.
    allora (dream.swf) è perfetto da solo, i controlli funzionano, l'audio è perfettamente in sync,ecc.. ma quando vado a caricarlo nel contenitore_mc i controlli anzichè agire sul filmato dream.swf, interagiscono con _root sulla quale è creato contenitore_mc. so che è un problema di percorsi, ma il codice che vi allego di seguito è troppo complicato per il mio piccolo cervellino e dopo alcuni tentativi non a buon fine ho deciso di postarlo a voi, così capisco i passi che devo fare ed imparare ancora....

    grazie da ora

    function playFLV()
    {
    return (g_flvVariable != undefined || g_flvURL != undefined);
    } // End of the function
    function initPlayer()
    {
    if (g_initilized == undefined)
    {
    g_flvLoaded = false;
    g_isPlaying = false;
    g_isEnd = false;
    g_soundObj = new Sound();
    g_soundVolume = g_soundObj.getVolume();
    g_soundMute = false;
    if (g_flvVariable != undefined)
    {
    g_flvURL = eval(g_flvVariable);
    } // end if
    if (!playFLV())
    {
    g_currentFrame = _currentframe;
    g_seekStep = int(_totalframes / 20);
    if (g_seekStep < g_fps * 5)
    {
    g_seekStep = g_fps * 5;
    } // end if
    _root.onEnterFrame = function ()
    {
    if (!control.vt.isDragging)
    {
    g_isPlaying = g_currentFrame != _currentframe;
    g_currentFrame = _currentframe;
    } // end if
    var _loc2 = g_isEnd;
    g_isEnd = _currentframe == _totalframes;
    if (g_isEnd)
    {
    if (g_endURL != undefined && !_loc2 && g_isEnd)
    {
    getURL(g_endURL, _root.g_endURLTarget == undefined ? ("") : (_root.g_endURLTarget));
    } // end if
    } // end if
    if (g_isEnd && !control.vt.isDragging)
    {
    if (g_isPlaying)
    {
    if (!(g_autoRewind || g_repeat))
    {
    g_isPlaying = false;
    stop ();
    }
    else
    {
    changeCurrentFrame(1);
    if (!g_repeat)
    {
    g_isPlaying = false;
    stop ();
    }
    else
    {
    play ();
    } // end if
    } // end if
    } // end else if
    } // end else if
    updateControls();
    };
    if (!g_autoPlay)
    {
    g_autoPlay = true;
    stop ();
    } // end if
    }
    else
    {
    if (g_flvURL != undefined)
    {
    control.vt.time.text = "Streaming...";
    g_currentTime = 0;
    g_netConnection = new NetConnection();
    g_netConnection.connect(null);
    g_netStream = new NetStream(g_netConnection);
    g_videoObj.attachVideo(g_netStream);
    g_netStream.setBufferTime(5);
    g_netStream.play(g_flvURL);
    g_netStream.onStatus = function (infoObj)
    {
    switch (infoObj.code)
    {
    case "NetStream.Play.Start":
    {
    g_flvLoaded = true;
    g_videoObj._width = g_videoWidth;
    g_videoObj._height = g_videoHeight;
    if (!g_autoPlay)
    {
    g_netStream.pause(true);
    g_netStream.seek(0);
    g_isPlaying = false;
    }
    else
    {
    g_isPlaying = true;
    } // end else if
    break;
    }
    case "NetStream.Buffer.Full":
    {
    break;
    }
    case "NetStream.Play.Stop":
    {
    break;
    }
    case "NetStream.Seek.InvalidTime":
    {
    g_netStream.seek(infoObj.details);
    break;
    }
    case "NetStream.Play.StreamNotFound":
    {
    control.vt.time.text = "Stream not found.";
    var _loc1 = new TextFormat();
    _loc1.color = 16711680;
    control.vt.time.setTextFormat(_loc1);
    break;
    }
    } // End of switch
    };
    g_netStream.onMetaData = function (infoObj)
    {
    g_totalTime = Math.floor(infoObj.duration);
    g_seekStep = g_totalTime / 20;
    if (g_seekStep < 5)
    {
    g_seekStep = 5;
    } // end if
    };
    }
    else
    {
    control.vt.time.text = "\"" + g_flvVariable + "\" not defined.";
    var fmt = new TextFormat();
    fmt.color = 16711680;
    control.vt.time.setTextFormat(fmt);
    } // end else if
    _root.onEnterFrame = function ()
    {
    if (g_totalTime != undefined)
    {
    var _loc2 = g_isEnd;
    g_isEnd = g_netStream.time >= g_totalTime;
    if (g_endURL != undefined && !_loc2 && g_isEnd)
    {
    getURL(g_endURL, _root.g_endURLTarget == undefined ? ("") : (_root.g_endURLTarget));
    } // end if
    } // end if
    if (g_isEnd && !control.vt.isDragging)
    {
    if (g_isPlaying)
    {
    if (!(g_autoRewind || g_repeat))
    {
    g_isPlaying = false;
    g_netStream.pause(true);
    }
    else
    {
    changeCurrentFrame(0);
    if (!g_repeat)
    {
    g_isPlaying = false;
    g_netStream.pause(true);
    }
    else
    {
    g_netStream.pause(false);
    } // end if
    } // end if
    } // end else if
    } // end else if
    updateControls();
    };
    } // end else if
    g_initilized = true;
    } // end if
    } // End of the function
    function changeCurrentFrame(pos)
    {
    if (!playFLV())
    {
    if (!(g_isPlaying && !control.vt.isDragging && pos < _totalframes))
    {
    g_currentFrame = pos;
    gotoAndStop(pos);
    }
    else
    {
    g_currentFrame = 0;
    gotoAndPlay(pos);
    } // end else if
    }
    else
    {
    g_netStream.seek(pos);
    } // end else if
    } // End of the function
    function updateControls()
    {
    control.b_play._visible = !g_isPlaying;
    control.b_pause._visible = g_isPlaying;
    control.vt.syncIndicatorWithVideo();
    } // End of the function
    var g_fps = 25;
    var g_autoPlay = true;
    var g_autoRewind = false;
    var g_repeat = false;
    var g_skinColor = 0;
    var g_skinColorSaturation = 100;
    var g_videoWidth = 400;
    var g_videoHeight = 275;
    var g_initilized;
    var g_flvLoaded;
    var g_netConnection;
    var g_netStream;
    var g_videoObj;
    var g_totalTime;
    var g_seekStep;
    var g_soundObj;
    var g_soundVolume;
    var g_soundMute;
    var g_currentFrame;
    var g_isPlaying;
    var g_isEnd;
    initPlayer();
    gotoAndStop(1);

  2. #2
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    il codice è decisamente lungo e stare lì a decifrarlo non è una passeggiata, se poi si pensa di dover rapportare i percorsi al filmato contenitore
    ci sarebbe una soluzione alternativa che non sempre funziona, dipende molto da come è strutturato il codice d'origine
    comunque la soluzione consiste nell'inserire nel tuo codice, come prima riga, this._lockroot = true;
    il che dovrebbe bloccare la _root del filmato figlio, come se venisse eseguito da solo, anche quando viene caricato dentro ad un altro filmato

    ps. se posti il link da cui l'hai scaricato, si fa prima

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2004
    Messaggi
    45
    grazie del consiglio, proverò così.
    per quanto riguarda il codice, esso è stato generato da Sothink SWF Decompiler. In pratica era un lavoro fatto in flash usando la timeline e senza codice AS. Volevo però fare in modo che il video non fosse in libreria ma caricato esternamente e quindi ho usato quel software per decompilarlo e rivavarne il codice. in effetti è un pò lunghetto!!
    comunque provo e faccio sapere.
    grazie

  4. #4
    Utente di HTML.it
    Registrato dal
    May 2004
    Messaggi
    45
    perfetto il codice ha funzionato alla grande!!!
    grazie mille del suggerimento

  5. #5
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    spero che fosse comunque tuo, altrimenti hai fatto una cosa illegale

  6. #6
    Utente di HTML.it
    Registrato dal
    May 2004
    Messaggi
    45
    tranquillo, il codice è stato creato con Sothink SWF Decompiler, ed il video è stato fatto da me. Il codice che utilizzo, se non sono io a compilarlo è comunque opensource, cioè tratto da esempi ed adattato alle mie esigenze. Spero un giorno di essere capace di compilarlo interamente da me!!!!!

  7. #7
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    io son tranquillo dicevo solo che se non hai il permesso di decompilare un filmato, stai commettendo un reato, ma pare che invece tu abbia chiesto il permesso, perciò apposto

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.