6 berichten aan het bekijken - 1 tot 6 (van in totaal 6)
  • Q:
    Bijdrager
    Guez

    AS3 Videoplayer verhouding problemen

    Hi,

    Ik heb een videoplayer gedownload van Flashmo.
    Het gaat om deze videoplayer: http://www.flashmo.com/preview/flashmo_215_video_player

    Hij is een prima videoplayer,..precies wat ik nodig heb. Het enige probleem is, dat niet al mijn videos in verhouding blijven.
    In de bron bestand (Flash) is een grootte aangegeven van 640 x 360.
    Dus elke video van 1280 x 720 of 1920 x 1080 blijft goed in verhouding in deze videoplayer.
    Maar een brede video van bijvoorbeeld 900 x 400 wordt niet in de juiste verhouding getoond. Normaal krijgt zo een brede video zwarte balkjes.
    Maar deze videoplayer rekt de video uit naar 640 x 360 waardoor het niet in verhouding is.

    Ik heb in de code proberen uit te vogelen of ik iets kon vinden met scaling van de videos, maar ik kom er niet echt uit.

    Weet iemand hoe ik dit kan oplossen?
    Alvast bedankt!

    Hier is de AS3 code:

    Bijdrager
    Guez

    Shit, ik zie nu pas dat de code niet duidelijk geplaatst wordt.
    Hopelijk is dit beter:

    /*

    Credits for FLASH VIDEO PLAYER

    Developed By
    http://www.flashmo.com

    References
    http://www.gotoandlearn.com
    http://www.thetechlabs.com/tutorials/xml/expanding-the-as3-videoplayer

    Tweener
    http://code.google.com/p/tweener

    */

    import caurina.transitions.Tweener;
    import caurina.transitions.properties.ColorShortcuts;
    ColorShortcuts.init();

    var css_file:String = “flashmo_215_style.css”;
    var buffer_time:uint = 3;
    var auto_play:Boolean = true;
    var video_smoothing:Boolean = true;
    var item_paused:Boolean = false;
    var mouse_visible:Boolean = true;
    var scrub_interval:uint;
    var fullscreen_interval:uint;
    var video_interval:uint = setInterval( video_status, 100 );
    var i:Number;
    var tn:Number = 0;
    var video_duration:Number;
    var total_items:Number;
    var amount_loaded:Number;
    var current_no:Number = 0;
    var flashmo_cpi:Number = 0;
    var flashmo_lpi:Number = -1;
    var last_mouse_x:Number = 0;
    var last_mouse_y:Number = 0;
    var control_bar_x:Number = fm_control_bar.x;
    var control_bar_y:Number = fm_control_bar.y;
    var flashmo_xml:XML;
    var total_min_sec:String;
    var flashmo_item_list = new Array();
    var item_group:MovieClip = new MovieClip();
    var css_loader:URLLoader = new URLLoader();
    var flashmo_style:StyleSheet = new StyleSheet();
    var custom_client:Object = new Object();
    var fm_st:SoundTransform = new SoundTransform();
    var fm_nc:NetConnection = new NetConnection();
    fm_nc.connect(null);
    var fm_ns:NetStream = new NetStream( fm_nc );

    this.addChild( item_group );
    item_group.mask = slider_mask;
    item_group.x = slider_mask.x;
    item_group.y = slider_mask.y;

    flashmo_sb.visible = false;
    flashmo_item_1.visible = false;
    fm_control_bar.visible = false;

    big_play_button.alpha = video_hit.alpha = 0;
    big_play_button.scaleX = big_play_button.scaleY = 1.4;
    video_hit.buttonMode = true;
    video_hit.addEventListener( MouseEvent.CLICK, on_video_click );

    fm_control_bar.status_bar.clickable_area.buttonMode = true;
    fm_control_bar.status_bar.status_bar_scroller.buttonMode = true;
    fm_control_bar.status_bar.status_bar_scroller.addEventListener( MouseEvent.MOUSE_DOWN, scroller_drag );
    fm_control_bar.status_bar.status_bar_scroller.addEventListener( MouseEvent.MOUSE_UP, scroller_drop );
    fm_control_bar.status_bar.clickable_area.addEventListener( MouseEvent.MOUSE_DOWN, scroller_seek );
    fm_control_bar.flashmo_fullscreen.addEventListener( MouseEvent.CLICK, switch_screen_mode );
    stage.addEventListener( FullScreenEvent.FULL_SCREEN, check_screen_mode );

    fm_ns.bufferTime = buffer_time;
    fm_ns.addEventListener( NetStatusEvent.NET_STATUS, fm_netstat );

    function load_xml( xml_file:String ):void
    {
    var xml_loader:URLLoader = new URLLoader();
    xml_loader.load( new URLRequest( xml_file ) );
    xml_loader.addEventListener( Event.COMPLETE, read_xml );
    }

    function read_xml( e:Event ):void
    {
    flashmo_xml = new XML( e.target.data );
    total_items = flashmo_xml.video.length();

    for( i = 0; i < total_items; i++ )
    {
    flashmo_item_list.push( {
    title: flashmo_xml.video.title.toString(),
    description: flashmo_xml.video.description.toString(),
    url: flashmo_xml.video.url.toString(),
    thumbnail: flashmo_xml.video.thumbnail.toString(),
    duration: flashmo_xml.video.duration.toString()
    } );
    }
    css_loader.load( new URLRequest(css_file) );
    css_loader.addEventListener(Event.COMPLETE, css_complete);
    }

    function css_complete( e:Event ):void
    {
    flashmo_style.parseCSS( css_loader.data );
    load_tn();
    }

    function load_tn():void
    {
    var pic_request:URLRequest = new URLRequest( flashmo_item_list[tn].thumbnail );
    var pic_loader:Loader = new Loader();

    pic_loader.load( pic_request );
    pic_loader.contentLoaderInfo.addEventListener( ProgressEvent.PROGRESS, tn_progress );
    pic_loader.contentLoaderInfo.addEventListener( Event.COMPLETE, tn_loaded );
    }

    function tn_progress( e:ProgressEvent ):void
    {
    loading_status.text = “loading item… ” + ( tn+1 ) + ” of ” + total_items;
    }

    function tn_loaded( e:Event ):void
    {
    var flashmo_tn_bm:Bitmap = new Bitmap();
    var item:MovieClip = new flashmo_item();

    flashmo_tn_bm = Bitmap( e.target.content );
    flashmo_tn_bm.smoothing = true;
    item.item_title.text = flashmo_item_list[tn].title;
    item.item_description.styleSheet = flashmo_style;
    item.item_description.htmlText = flashmo_item_list[tn].description;
    item.item_duration.text = flashmo_item_list[tn].duration;
    item.y = item_group.numChildren * 90;

    item.hit.buttonMode = true;
    item.hit.addEventListener( MouseEvent.MOUSE_OVER, item_over );
    item.hit.addEventListener( MouseEvent.MOUSE_OUT, item_out );
    item.hit.addEventListener( MouseEvent.CLICK, item_click );
    item.name = “flashmo_video_” + item_group.numChildren;
    item.tn.addChild( flashmo_tn_bm );
    item_group.addChild( item );
    tn++;

    if( tn < total_items )
    load_tn();
    else
    {
    loading_status.text = “”;
    flashmo_sb.visible = true;
    flashmo_sb.buttonMode = true;
    flashmo_sb.scrolling(“item_group”, “slider_mask”, 0.80);
    play_item( true );
    add_controls();
    }
    }

    function add_controls():void
    {
    fm_control_bar.flashmo_play.addEventListener(MouseEvent.CLICK, on_click_play);
    fm_control_bar.flashmo_pause.addEventListener(MouseEvent.CLICK, on_click_pause);
    fm_control_bar.flashmo_previous.addEventListener(MouseEvent.CLICK, on_click_prev);
    fm_control_bar.flashmo_next.addEventListener(MouseEvent.CLICK, on_click_next);
    fm_control_bar.visible = true;
    }

    function play_item( is_first_time:Boolean ):void
    {
    if( flashmo_lpi > -1 )
    change_color( MovieClip(item_group.getChildAt( flashmo_lpi ) ), 0, 0, 0);

    change_color( MovieClip(item_group.getChildAt( flashmo_cpi ) ) , 18, 18, 18);

    Tweener.addTween( big_play_button, { alpha: 0, time: 0.4, scaleX: 1.4, scaleY: 1.4, transition:”easeOutQuart” } );
    Tweener.addTween( video_hit, { alpha: 0, time: 0.4, transition:”easeOutQuart” } );

    clearInterval( video_interval );
    clearInterval( scrub_interval );

    fm_control_bar.status_bar.load_progress_bar.scaleX =
    fm_control_bar.status_bar.clickable_area.width =
    fm_control_bar.status_bar.fm_bar.width = fm_control_bar.status_bar.status_bar_scroller.x = 0;

    fm_st.volume = fm_control_bar.flashmo_volume.flashmo_scroller.x /
    ( fm_control_bar.flashmo_volume.flashmo_scrollable_area.width –
    fm_control_bar.flashmo_volume.flashmo_scroller.width );

    fm_video.attachNetStream( fm_ns );
    fm_video.smoothing = video_smoothing;
    custom_client.onMetaData = meta_data_handler;
    fm_ns.client = custom_client;

    if(( is_first_time && auto_play ) || !is_first_time )
    {
    fm_ns.play( flashmo_item_list[flashmo_cpi].url );
    flashmo_buffer.buffer_info.text = “BUFFERING VIDEO”;
    fm_control_bar.flashmo_pause.visible = true;
    fm_control_bar.flashmo_play.visible = false;
    item_paused = false;
    }
    else
    {
    flashmo_buffer.buffer_info.text = “”;
    fm_control_bar.flashmo_pause.visible = false;
    fm_control_bar.flashmo_play.visible = true;
    item_paused = true;
    }

    flashmo_lpi = flashmo_cpi;
    fm_ns.soundTransform = fm_st;
    video_interval = setInterval( video_status, 100 );
    }

    function scroller_seek( me:MouseEvent ):void
    {
    var drag_area:Rectangle = new Rectangle( 0, fm_control_bar.status_bar.status_bar_scroller.y,
    fm_control_bar.status_bar.clickable_area.width, 0 );
    fm_control_bar.status_bar.status_bar_scroller.startDrag( true, drag_area );
    clearInterval( video_interval );
    scrub_interval = setInterval( on_scroll, 10 );
    stage.addEventListener( MouseEvent.MOUSE_UP, up );
    }

    function video_status()
    {
    fm_control_bar.status_bar.load_progress_bar.width = fm_control_bar.status_bar.clickable_area.width = fm_ns.bytesLoaded * fm_control_bar.status_bar.load_progress_bar_bg.width / fm_ns.bytesTotal;

    fm_control_bar.status_bar.fm_bar.width = fm_control_bar.status_bar.status_bar_scroller.x = fm_ns.time * fm_control_bar.status_bar.load_progress_bar_bg.width / video_duration;

    fm_control_bar.status_bar.status_text.text = pad_zero( Math.floor( fm_ns.time / 60) ) +
    “:” + pad_zero( Math.floor( fm_ns.time % 60) ) + ” / ” + total_min_sec;
    }

    function on_scroll()
    {
    fm_control_bar.status_bar.fm_bar.width = fm_control_bar.status_bar.status_bar_scroller.x;

    var playback_ratio:Number = ( fm_control_bar.status_bar.fm_bar.width / fm_control_bar.status_bar.load_progress_bar_bg.width ) * video_duration;

    fm_control_bar.status_bar.status_text.text = pad_zero( Math.floor( playback_ratio / 60 ) ) +
    “:” + pad_zero( Math.floor( playback_ratio % 60 ) ) + ” / ” + total_min_sec;
    }

    function scroller_drag( me:MouseEvent ):void
    {
    var drag_area:Rectangle = new Rectangle( 0, fm_control_bar.status_bar.status_bar_scroller.y, fm_control_bar.status_bar.clickable_area.width, 0 );
    me.target.startDrag( false, drag_area );
    clearInterval( video_interval );
    scrub_interval = setInterval( on_scroll, 10 );
    stage.addEventListener( MouseEvent.MOUSE_UP, up );
    }

    function scroller_drop( me:MouseEvent ):void
    {
    me.target.stopDrag();
    }

    function up( me:MouseEvent ):void
    {
    fm_control_bar.status_bar.status_bar_scroller.stopDrag();
    fm_ns.seek( Math.round( fm_control_bar.status_bar.status_bar_scroller.x * video_duration / fm_control_bar.status_bar.load_progress_bar_bg.width ) );

    clearInterval( scrub_interval );
    video_interval = setInterval( video_status, 100 );
    stage.removeEventListener( MouseEvent.MOUSE_UP, up );
    }

    function on_video_click( me:MouseEvent )
    {
    if( item_paused )
    on_click_play( me );
    else
    on_click_pause( me );
    }

    function switch_screen_mode( me:MouseEvent )
    {
    if( stage.displayState == StageDisplayState.NORMAL )
    {
    var screen_rectangle:Rectangle = new Rectangle( this.x + fm_video.x, this.y + fm_video.y, fm_video.width, fm_video.height );
    stage.fullScreenSourceRect = screen_rectangle;
    stage.displayState = StageDisplayState.FULL_SCREEN;
    }
    else
    {
    stage.displayState = StageDisplayState.NORMAL;
    }
    }

    function check_screen_mode( fe:FullScreenEvent )
    {
    if ( fe.fullScreen )
    {
    Tweener.addTween( fm_control_bar, { alpha: 1, time: 0.5,
    y: ( control_bar_y – fm_control_bar.height ), transition: “easeInExpo” } );
    fullscreen_interval = setInterval( detect_mouse, 2000 );
    video_hit.addEventListener( MouseEvent.MOUSE_MOVE, on_mouse_move );
    fm_control_bar.addEventListener( MouseEvent.CLICK, on_click_control );
    }
    else
    {
    Mouse.show();
    mouse_visible = true;
    Tweener.addTween( fm_control_bar, { alpha: 1, time: 0.5,
    y: control_bar_y, transition: “easeInExpo” } );
    clearInterval( fullscreen_interval );
    video_hit.removeEventListener( MouseEvent.MOUSE_MOVE, on_mouse_move );
    fm_control_bar.removeEventListener( MouseEvent.CLICK, on_click_control );
    }
    }

    function on_click_control( me:MouseEvent )
    {
    last_mouse_x–;
    }

    function on_mouse_move( me:MouseEvent ):void
    {
    if( !mouse_visible )
    {
    Mouse.show();
    mouse_visible = true;
    Tweener.addTween( fm_control_bar, { alpha: 1, time: 0,
    y: ( control_bar_y – fm_control_bar.height ), transition: “easeInExpo” } );
    }
    }

    function detect_mouse():void
    {
    if( last_mouse_x == mouseX && last_mouse_y == mouseY && mouse_visible )
    {
    Mouse.hide();
    mouse_visible = false;
    Tweener.addTween( fm_control_bar, { alpha: 0, time: 1,
    y: control_bar_y + fm_control_bar.height, transition: “easeOutExpo” } );
    }
    last_mouse_x = mouseX;
    last_mouse_y = mouseY;
    }

    function fm_netstat( nse:NetStatusEvent )
    {
    switch( nse.info.code )
    {
    case “NetStream.Buffer.Full”:
    flashmo_buffer.visible = false;
    break;
    case “NetStream.Buffer.Empty”:
    flashmo_buffer.visible = true;
    break;
    case “NetStream.Play.Stop”:
    play_next_item();
    break;
    }
    }

    function meta_data_handler( info_object:Object ):void
    {
    video_duration = Math.round( info_object.duration );
    total_min_sec = pad_zero( Math.floor( video_duration / 60 ) ) +
    “:” + pad_zero( Math.floor( video_duration % 60 ) );
    }

    function item_over( me:MouseEvent ):void
    {
    var mc:MovieClip = MovieClip( me.target );
    current_no = parseInt( mc.name.slice(14,16 ));
    Tweener.addTween( mc, { alpha: 0.4, time: 0.4, transition:”easeOutQuart” } );
    }

    function item_out( me:MouseEvent ):void
    {
    var target_mc:MovieClip = MovieClip( me.target );
    var mc:MovieClip = MovieClip( me.target.parent );
    current_no = parseInt( mc.name.slice(14,16) );

    if( current_no != flashmo_cpi )
    change_color( mc, 0, 0, 0 );
    else
    change_color( MovieClip( item_group.getChildAt(flashmo_cpi) ), 18, 18, 18 );

    Tweener.addTween( target_mc, {alpha: 0, time: 0.4, transition: “easeOutQuart” } );
    }

    function item_click( me:MouseEvent ):void
    {
    var mc:MovieClip = MovieClip( me.target.parent );
    current_no = parseInt( mc.name.slice(14,16) );
    flashmo_cpi = current_no;
    play_item( false );
    }

    function on_click_pause( me:MouseEvent ):void
    {
    fm_control_bar.flashmo_play.visible = true;
    fm_control_bar.flashmo_pause.visible = false;
    Tweener.addTween( big_play_button, { alpha: 1, time: 0.4, scaleX: 1, scaleY: 1, transition: “easeOutQuart” } );
    Tweener.addTween( video_hit, { alpha: 1, time: 0.4, transition: “easeOutQuart” } );
    item_paused = true;
    fm_ns.togglePause();
    }

    function on_click_play( me:MouseEvent ):void
    {
    fm_control_bar.flashmo_pause.visible = true;
    fm_control_bar.flashmo_play.visible = false;

    if( fm_ns.time == 0 )
    {
    fm_ns.play( flashmo_item_list[flashmo_cpi].url );
    }
    else
    {
    fm_ns.togglePause();
    }
    item_paused = false;
    Tweener.addTween( big_play_button, { alpha: 0, time: 0.4, scaleX: 1.4, scaleY: 1.4, transition: “easeOutQuart” } );
    Tweener.addTween( video_hit, { alpha: 0, time: 0.4, transition: “easeOutQuart” } );
    }

    function on_click_next( me:MouseEvent ):void
    {
    play_next_item();
    }

    function on_click_prev( me:MouseEvent ):void
    {
    play_prev_item();
    }

    function play_next_item():void
    {
    if( flashmo_cpi < total_items – 1 )
    {
    flashmo_cpi++;
    }
    else
    {
    flashmo_cpi = 0;
    flashmo_buffer.buffer_info.text = “”;
    }
    play_item( false );
    }

    function play_prev_item():void
    {
    if( flashmo_cpi > 0 )
    flashmo_cpi–;
    else
    flashmo_cpi = total_items – 1;

    play_item( false );
    }

    function change_color( mc:MovieClip, r_offset:int, g_offset:int, b_offset:int ):void
    {
    Tweener.addTween( mc, {_color_redOffset: r_offset, _color_greenOffset: g_offset,
    _color_blueOffset: b_offset, time: 1, transition: “easeOutExpo” } );
    }

    function pad_zero( str_to_pad:Number ):String
    {
    if( str_to_pad < 10 )
    return “0” + str_to_pad;
    else
    return String( str_to_pad );
    }

    Bijdrager
    Hansi2124

    Je kan dan beter die lap tekst die verkeerd is overgekomen verwijderen. Iedereen zit nu voor niets te xrollen en te kijken…

    Bijdrager
    Guez

    dat is waar.. ik dacht dat ik het nog kon aanpassen maar dat kan dus niet. hoe kan ik nu die lap tekst verwijderen dan?

    Moderator
    Strifer

    Met je muis over je avatar heen, op het pijltje klikken en kiezen voor ‘Bewerk’ (onderste optie; zonder icon)

    Bijdrager
    Guez

    nu beter?

    nog iemand die weet hoe dit probleem opgelost kan worden?

6 berichten aan het bekijken - 1 tot 6 (van in totaal 6)

Je moet ingelogd zijn om een reactie op dit onderwerp te kunnen geven.