sestdiena, 2014. gada 12. aprīlis

Packages that run Linux.

3.2. All Packages

Download or otherwise obtain the following packages:
Autoconf (2.69) - 1,186 KB:
MD5 sum: 50f97f4159805e374639a73e2636f22e
Automake (1.14.1) - 1,456 KB:
MD5 sum: 7fc29854c520f56b07aa232a0f880292
Bash (4.2) - 6,845 KB:
MD5 sum: 3fb927c7c33022f1c327f14a81c0d4b0
Bc (1.06.95) - 288 KB:
MD5 sum: 5126a721b73f97d715bb72c13c889035
Binutils (2.24) - 22,184 KB:
MD5 sum: e0f71a7b2ddab0f8612336ac81d9636b
Bison (3.0.2) - 1,882 KB:
MD5 sum: 146be9ff9fbd27497f0bf2286a5a2082
Bzip2 (1.0.6) - 764 KB:
MD5 sum: 00b516f4704d4a7cb50a1d97e6e8e15b
Check (0.9.12) - 714 KB:
MD5 sum: 46fe540d1a03714c7a1967dbc6d484e7
Coreutils (8.22) - 5,210 KB:
MD5 sum: 8fb0ae2267aa6e728958adc38f8163a2
DejaGNU (1.5.1) - 566 KB:
MD5 sum: 8386e04e362345f50ad169f052f4c4ab
Diffutils (3.3) - 1,170 KB:
MD5 sum: 99180208ec2a82ce71f55b0d7389f1b3
E2fsprogs (1.42.9) - 5,928 KB:
MD5 sum: 3f8e41e63b432ba114b33f58674563f7
Expect (5.45) - 614 KB:
MD5 sum: 44e1a4f4c877e9ddc5a542dfa7ecc92b
File (5.17) - 694 KB:
MD5 sum: e19c47e069ced7b01ccb4db402cc01d3
[Note] 

Note

File (5.17) may no longer be available at the listed location. The site administrators of the master download location occasionally remove older versions when new ones are released. An alternative download location that may have the correct version available can also be found at: http://www.linuxfromscratch.org/lfs/download.html#ftp.
Findutils (4.4.2) - 2,100 KB:
MD5 sum: 351cc4adb07d54877fa15f75fb77d39f
Flex (2.5.38) - 1,590 KB:
MD5 sum: b230c88e65996ff74994d08a2a2e0f27
Gawk (4.1.0) - 2,004 KB:
MD5 sum: b18992ff8faf3217dab55d2d0aa7d707
GCC (4.8.2) - 83,984 KB:
Home page: http://gcc.gnu.org/
MD5 sum: a3d7d63b9cb6b6ea049469a0c4a43c9d
GDBM (1.11) - 796 KB:
MD5 sum: 72c832680cf0999caedbe5b265c8c1bd
Gettext (0.18.3.2) - 15,810 KB:
MD5 sum: 241aba309d07aa428252c74b40a818ef
Glibc (2.19) - 11,801 KB:
MD5 sum: e26b8cc666b162f999404b03970f14e4
GMP (5.1.3) - 1,777 KB:
MD5 sum: e5fe367801ff067b923d1e6a126448aa
Grep (2.16) - 1,184 KB:
MD5 sum: 502350a6c8f7c2b12ee58829e760b44d
Groff (1.22.2) - 3,926 KB:
MD5 sum: 9f4cd592a5efc7e36481d8d8d8af6d16
GRUB (2.00) - 5,016 KB:
MD5 sum: a1043102fbc7bcedbf53e7ee3d17ab91
Gzip (1.6) - 712 KB:
MD5 sum: da981f86677d58a106496e68de6f8995
Iana-Etc (2.30) - 201 KB:
MD5 sum: 3ba3afb1d1b261383d247f46cb135ee8
Inetutils (1.9.2) - 2,188 KB:
MD5 sum: aa1a9a132259db83e66c1f3265065ba2
IPRoute2 (3.12.0) - 415 KB:
MD5 sum: f87386aaaecafab95607fd10e8152c68
Kbd (2.0.1) - 1,962 KB:
MD5 sum: cc0ee9f2537d8636cae85a8c6541ed2e
Kmod (16) - 1,408 KB:
MD5 sum: 3006a0287211212501cdfe1211b29f09
Less (458) - 308 KB:
MD5 sum: 935b38aa2e73c888c210dedf8fd94f49
LFS-Bootscripts (20130821) - 34 KB:
MD5 sum: e908023fc44e613ad0c81241781289e7
Libpipeline (1.2.6) - 761 KB:
MD5 sum: 6d1d51a5dc102af41e0d269d2a31e6f9
Libtool (2.4.2) - 2,571 KB:
MD5 sum: d2f3b7d4627e69e13514a40e72a24d50
Linux (3.13.3) - 75,393 KB:
MD5 sum: ad98a0c623a124a25dab86406ddc7119
[Note] 

Note

The Linux kernel is updated relatively often, many times due to discoveries of security vulnerabilities. The latest available 3.13.x kernel version should be used, unless the errata page says otherwise.
For users with limited speed or expensive bandwidth who wish to update the Linux kernel, a baseline version of the package and patches can be downloaded separately. This may save some time or cost for a subsequent patch level upgrade within a minor release.
M4 (1.4.17) - 1,122 KB:
MD5 sum: 12a3c829301a4fd6586a57d3fcf196dc
Make (4.0) - 1,311 KB:
MD5 sum: 571d470a7647b455e3af3f92d79f1c18
Man-DB (2.6.6) - 1,415 KB:
MD5 sum: 5d65d66191080c144437a6c854e17868
Man-pages (3.59) - 1,172 KB:
MD5 sum: d8e4d8287a76ee861351b905044c8e92
MPC (1.0.2) - 619 KB:
MD5 sum: 68fadff3358fb3e7976c7a398a0af4c3
MPFR (3.1.2) - 1,049 KB:
MD5 sum: e3d203d188b8fe60bb6578dd3152e05c
Ncurses (5.9) - 2,760 KB:
MD5 sum: 8cb9c412e5f2d96bc6f459aa8c6282a1
Patch (2.7.1) - 660 KB:
MD5 sum: e9ae5393426d3ad783a300a338c09b72
Perl (5.18.2) - 13,730 KB:
MD5 sum: d549b16ee4e9210988da39193a9389c1
Pkg-config (0.28) - 1,892 KB:
MD5 sum: aa3c86e67551adc3ac865160e34a2a0d
Procps (3.3.9) - 548 KB:
MD5 sum: 0980646fa25e0be58f7afb6b98f79d74
Psmisc (22.20) - 422 KB:
MD5 sum: a25fc99a6dc7fa7ae6e4549be80b401f
Readline (6.2) - 2,225 KB:
MD5 sum: 67948acb2ca081f23359d0256e9a271c
Sed (4.2.2) - 1,035 KB:
MD5 sum: 7ffe1c7cdc3233e1e0c4b502df253974
Shadow (4.1.5.1) - 3,428 KB:
MD5 sum: ae66de9953f840fb3a97f6148bc39a30
Sysklogd (1.5) - 85 KB:
MD5 sum: e053094e8103165f98ddafe828f6ae4b
Sysvinit (2.88dsf) - 108 KB:
MD5 sum: 6eda8a97b86e0a6f59dabbf25202aa6f
Tar (1.27.1) - 1,835 KB:
MD5 sum: e0382a4064e09a4943f3adeff1435978
Tcl (8.6.1) - 8,551 KB:
MD5 sum: aae4b701ee527c6e4e1a6f9c7399882e
Time Zone Data (2013i) - 214 KB:
MD5 sum: 8bc69eb75bea496ebe1d5a9ab576702d
Texinfo (5.2) - 3,724 KB:
MD5 sum: cb489df8a7ee9d10a236197aefdb32c5
Systemd (208) - 2,328 KB:
MD5 sum: df64550d92afbffb4f67a434193ee165
Udev-lfs Tarball (208) - 29 KB:
MD5 sum: c0231ff619e567a9b11f912d8a7a404a
Util-linux (2.24.1) - 3,461 KB:
MD5 sum: 88d46ae23ca599ac5af9cf96b531590f
Vim (7.4) - 9,632 KB:
Home page: http://www.vim.org
MD5 sum: 607e135c559be642f210094ad023dc65
Xz Utils (5.0.5) - 894 KB:
MD5 sum: aa17280f4521dbeebed0fbd11cd7fa30
Zlib (1.2.8) - 441 KB:
MD5 sum: 28f1205d8dd2001f26fec1e8c2cebe37
Total size of these packages: about 322 MB

LVM2 what allows using multiple partitions of hard drive.

LVM2-2.02.105

Introduction to LVM2

The LVM2 package is a package that manages logical partitions. It allows spanning of file systems across multiple physical disks and disk partitions and provides for dynamic growing or shrinking of logical partitions.
This package is known to build and work properly using an LFS-7.5 platform.

Package Information

  • Download MD5 sum: b5b3540661fc70bf329b526c1cfbcf3a
  • Download size: 1.4 MB
  • Estimated disk space required: 24 MB (additional 2 MB to run the test suite)
  • Estimated build time: 0.3 SBU (additional 3.6 SBU to run the test suite)

LVM2 Dependencies

Optional

mdadm-3.3 (for checks) and xfsprogs-3.1.11 (for checks)

Kernel Configuration

Enable the following option in the kernel configuration and recompile the kernel:
[Note] 

Note

There are several other Device Mapper options in the kernel beyond those listed below. In order to get reasonable results if running the regression tests, all must be enabled either internally or as a module.
Device Drivers --->
  Multiple devices driver support (RAID and LVM): Y
    Device mapper support: Y or M
    Crypt target support: (optional)
    Snapshot target: (optional)
    Mirror target: (optional) 

Installation of LVM2

Install LVM2 by running the following commands:
sed -i s/CPPFunction/rl_completion_func_t/ tools/lvm.c &&
./configure --prefix=/usr       \
            --exec-prefix=      \
            --with-confdir=/etc \
            --enable-applib     \
            --enable-cmdlib     \
            --enable-pkgconfig  \
            --enable-udev_sync &&
make
The check command must be run as the root user. Also the tests are known to hang if at least one partition on a hard drive is not set up as a Linux LVM partition (type 8e00). To test the results, issue: make check as the root user.
Now, as the root user:
make install

Command Explanations

sed -i s/CPPFunction/rl_completion_func_t/ tools/lvm.c: Corrects the use of a deprecated typedef.
--enable-applib: This switch enables building of the shared application library.
--enable-cmdlib: This switch enables building of the shared command library. It is required when building the event daemon.
--enable-pkgconfig: This switch enables installation of pkg-config support files.
--enable-udev_sync: This switch enables synchronisation with Udev processing.
--enable-dmeventd: This switch enables building of the Device Mapper event daemon.

Contents

Installed Programs:blkdeactivate, dmeventd (optional), dmsetup, fsadm, lvm, lvmconf, lvmdump, vgimportclone. There are also numerous symbolic links to lvm that implement specific functionality.
Installed Libraries:libdevmapper.so, liblvm2app.so and liblvm2cmd.so; optional: libdevmapper-event.so, libdevmapper-event-lvm2.so, libdevmapper-event-lvm2mirror.so, libdevmapper-event-lvm2snapshot.so, libdevmapper-event-lvm2raid.so, libdevmapper-event-lvm2thin.so and some under /lib/device-mapper
Installed Directories:/etc/lvm and /lib/device-mapper (optional)

Short Descriptions

blkdeactivate
utility to deactivate block device.
dmeventd
(optional) is the Device Mapper event daemon.
dmsetup
is a low level logical volume management tool.
fsadm
is an utility used to resize or check filesystem on a device.
lvm
provides the command-line tools for LVM2. Commands are implemented via sympolic links to this program to manage physical devices (pv*), volume groups (vg*) and logical volumes (lv*).
lvmconf
is a script that modifies the locking configuration in the LVM2 configuration file.
lvmdump
is a tool used to dump various information concerning LVM2.
vgimportclone
is used to import a duplicated VG (e.g. hardware snapshot).
libdevmapper.so
contains the Device Mapper API functions.
Last updated on 2014-03-07 15:12:35 +0000

FUSE something that creates file systems.

Fuse-2.9.3

Introduction to Fuse

FUSE (Filesystem in Userspace) is a simple interface for userspace programs to export a virtual filesystem to the Linux kernel. Fuse also aims to provide a secure method for non privileged users to create and mount their own filesystem implementations.
This package is known to build and work properly using an LFS-7.5 platform.

Package Information

Kernel Configuration

Enable the following options in the kernel configuration and recompile the kernel if necessary:
File systems  --->
  [*] FUSE (Filesystem in Userspace) support

Installation of Fuse

[Note] 

Note

After the configure script has finished you will see a warning shown below. You can safely disregard this warning.
configure: WARNING:
******************************************************************
* Please install util-linux version 2.18 or later which supports *
* --fake and --no-canonicalize options in mount and umount       *
******************************************************************
Install Fuse by running the following commands:
./configure --prefix=/usr --disable-static INIT_D_PATH=/tmp/init.d &&
make
If you have Doxygen-1.8.6 installed and wish to build the API documentation, issue doxygen doc/Doxyfile.
This package does not come with a test suite.
Now, as the root user:
make install &&

mv -v   /usr/lib/libfuse.so.* /lib &&
ln -sfv ../../lib/libfuse.so.2.9.3 /usr/lib/libfuse.so &&
rm -rf  /tmp/init.d &&

install -v -m755 -d /usr/share/doc/fuse-2.9.3 &&
install -v -m644    doc/{how-fuse-works,kernel.txt} \
                    /usr/share/doc/fuse-2.9.3
If you built the API documentation, install it as the root user by issuing the following commands:
install -v -m755 -d /usr/share/doc/fuse-2.9.3/api &&
install -v -m644    doc/html/* \
                    /usr/share/doc/fuse-2.9.3/api

Command Explanations

--disable-static: This switch prevents installation of static versions of the libraries.
INIT_D_PATH=/tmp/init.d: This parameter installs the bootscript into /tmp/init.d as a bootscript is not required.
mv -v /usr/lib/libfuse.so.* /lib: This moves the FUSE library to the root filesystem so that it is available early in the boot process in case /usr is mounted on a separate partition and ntfs-3g-2014.2.15 is built with a system-installed version of FUSE.
rm -rf /tmp/init.d: This removes the unneeded bootscript.

Configuring fuse

Config Files

Some options regarding mount policy can be set in the file /etc/fuse.conf. To install the file run the following command as the root user:
cat > /etc/fuse.conf << "EOF"
# Set the maximum number of FUSE mounts allowed to non-root users.
# The default is 1000.
#
#mount_max = 1000

# Allow non-root users to specify the 'allow_other' or 'allow_root'
# mount options.
#
#user_allow_other
EOF
Additional information about the meaning of the configuration options are found in the man page.

Contents

Installed Programs:fusermount, mount.fuse, and ulockmgr_server
Installed Libraries:libfuse.so and libulockmgr.so
Installed Directory:/usr/include/fuse

Short Descriptions

fusermount
is a set users ID root program to mount and unmount Fuse filesystems.
mount.fuse
is the command mount would call to mount a Fuse filesystem.
ulockmgr_server
is the Userspace Lock Manager Server for Fuse filesystems.
libfuse.so
contains the FUSE API functions.
libulockmgr.so
contains the Userspace Lock Manager API functions.
Last updated on 2014-02-17 23:16:31 +0000

INITRAMFS something that loads linux kernel.

About initramfs

The only purpose of an initramfs is to mount the root filesystem. The initramfs is a complete set of directories that you would find on a normal root filesystem. It is bundled into a single cpio archive and compressed with one of several compression algorithms.
At boot time, the boot loader loads the kernel and the initramfs image into memory and starts the kernel. The kernel checks for the presence of the initramfs and, if found, mounts it as / and runs /init. The init program is typically a shell script. Note that the boot process takes longer, possibly significantly longer, if an initramfs is used.
For most distributions, kernel modules are the biggest reason to have an initramfs. In a general distribution, there are many unknowns such as file system types and disk layouts. In a way, this is the opposite of LFS where the system capabilities and layout are known and a custom kernel is normally built. In this situation, an initramfs is rarely needed.
There are only four primary reasons to have an initramfs in the LFS environment: loading the rootfs from a network, loading it from an LVM logical volume, having an encrypted rootfs where a password is required, or for the convenience of specifying the rootfs as a LABEL or UUID. Anything else usually means that the kernel was not configured properly.

Building an initramfs

If you do decide to build an initramfs, the following scripts will provide a basis to do it. The scripts will allow specifying a rootfs via partition UUID or partition LABEL or a rootfs on an LVM logical volume. They do not support an encrypted root file system or mounting the rootfs over a network card. For a more complete capability see the LFS Hints or dracut.
To install these scripts, run the following commands as the root user:
cat > /sbin/mkinitramfs << "EOF"
#!/bin/bash
# This file based in part on the mkinitrafms script for the LFS LiveCD
# written by Alexander E. Patrakov and Jeremy Huntwork.

copy()
{
  local file

  if [ "$2" == "lib" ]; then
    file=$(PATH=/lib:/usr/lib type -p $1)
  else
    file=$(type -p $1)
  fi

  if [ -n $file ] ; then
    cp $file $WDIR/$2
  else
    echo "Missing required file: $1 for directory $2"
    rm -rf $WDIR
    exit 1
  fi
}

if [ -z $1 ] ; then
  INITRAMFS_FILE=initrd.img-no-kmods
else
  KERNEL_VERSION=$1
  INITRAMFS_FILE=initrd.img-$KERNEL_VERSION
fi

if [ -n "$KERNEL_VERSION" ] && [ ! -d "/lib/modules/$1" ] ; then
  echo "No modules directory named $1"
  exit 1
fi

printf "Creating $INITRAMFS_FILE... "

binfiles="sh cat cp dd killall ls mkdir mknod mount "
binfiles="$binfiles umount sed sleep ln rm uname"

sbinfiles="udevadm modprobe blkid switch_root"

#Optional files and locations
for f in mdadm udevd; do
  if [ -x /sbin/$f ] ; then sbinfiles="$sbinfiles $f"; fi
done

unsorted=$(mktemp /tmp/unsorted.XXXXXXXXXX)

DATADIR=/usr/share/mkinitramfs
INITIN=init.in

# Create a temporrary working directory
WDIR=$(mktemp -d /tmp/initrd-work.XXXXXXXXXX)

# Create base directory structure
mkdir -p $WDIR/{bin,dev,lib/firmware,run,sbin,sys,proc}
mkdir -p $WDIR/etc/{modprobe.d,udev/rules.d}
touch $WDIR/etc/modprobe.d/modprobe.conf
ln -s lib $WDIR/lib64

# Create necessary device nodes
mknod -m 640 $WDIR/dev/console c 5 1
mknod -m 664 $WDIR/dev/null    c 1 3

# Install the udev configuration files
if [ -f /etc/udev/udev.conf ]; then
  cp /etc/udev/udev.conf $WDIR/etc/udev/udev.conf
fi

for file in $(find /etc/udev/rules.d/ -type f) ; do
  cp $file $WDIR/etc/udev/rules.d
done

# Install any firmware present
cp -a /lib/firmware $WDIR/lib

# Copy the RAID configureation file if present
if [ -f /etc/mdadm.conf ] ; then
  cp /etc/mdadm.conf $WDIR/etc
fi

# Install the init file
install -m0755 $DATADIR/$INITIN $WDIR/init

if [  -n "$KERNEL_VERSION" ] ; then
  if [ -x /bin/kmod ] ; then
    binfiles="$binfiles kmod"
  else
    binfiles="$binfiles lsmod"
    sbinfiles="$sbinfiles insmod"
  fi
fi

# Install basic binaries
for f in $binfiles ; do
  ldd /bin/$f | sed "s/\t//" | cut -d " " -f1 >> $unsorted
  copy $f bin
done

# Add lvm if present
if [ -x /sbin/lvm ] ; then sbinfiles="$sbinfiles lvm dmsetup"; fi

for f in $sbinfiles ; do
  ldd /sbin/$f | sed "s/\t//" | cut -d " " -f1 >> $unsorted
  copy $f sbin
done

# Add udevd libraries if not in /sbin
if [ -x /lib/udev/udevd ] ; then
  ldd /lib/udev/udevd | sed "s/\t//" | cut -d " " -f1 >> $unsorted
fi

# Add module symlinks if appropriate
if [ -n "$KERNEL_VERSION" ] && [ -x /bin/kmod ] ; then
  ln -s kmod $WDIR/bin/lsmod
  ln -s kmod $WDIR/bin/insmod
fi

# Add lvm symlinks if appropriate
# Also copy the lvm.conf file
if  [ -x /sbin/lvm ] ; then
  ln -s lvm $WDIR/sbin/lvchange
  ln -s lvm $WDIR/sbin/lvrename
  ln -s lvm $WDIR/sbin/lvextend
  ln -s lvm $WDIR/sbin/lvcreate
  ln -s lvm $WDIR/sbin/lvdisplay
  ln -s lvm $WDIR/sbin/lvscan

  ln -s lvm $WDIR/sbin/pvchange
  ln -s lvm $WDIR/sbin/pvck
  ln -s lvm $WDIR/sbin/pvcreate
  ln -s lvm $WDIR/sbin/pvdisplay
  ln -s lvm $WDIR/sbin/pvscan

  ln -s lvm $WDIR/sbin/vgchange
  ln -s lvm $WDIR/sbin/vgcreate
  ln -s lvm $WDIR/sbin/vgscan
  ln -s lvm $WDIR/sbin/vgrename
  ln -s lvm $WDIR/sbin/vgck
  # Conf file(s)
  cp -a /etc/lvm $WDIR/etc
fi

# Install libraries
sort $unsorted | uniq | while read library ; do
  if [ "$library" == "linux-vdso.so.1" ] ||
     [ "$library" == "linux-gate.so.1" ]; then
    continue
  fi

  copy $library lib
done

cp -a /lib/udev $WDIR/lib

# Install the kernel modules if requested
if [ -n "$KERNEL_VERSION" ]; then
  find                                                                        \
     /lib/modules/$KERNEL_VERSION/kernel/{crypto,fs,lib}                      \
     /lib/modules/$KERNEL_VERSION/kernel/drivers/{block,ata,md,firewire}      \
     /lib/modules/$KERNEL_VERSION/kernel/drivers/{scsi,message,pcmcia,virtio} \
     /lib/modules/$KERNEL_VERSION/kernel/drivers/usb/{host,storage}           \
     -type f 2> /dev/null | cpio --make-directories -p --quiet $WDIR

  cp /lib/modules/$KERNEL_VERSION/modules.{builtin,order}                     \
            $WDIR/lib/modules/$KERNEL_VERSION

  depmod -b $WDIR $KERNEL_VERSION
fi

( cd $WDIR ; find . | cpio -o -H newc --quiet | gzip -9 ) > $INITRAMFS_FILE

# Remove the temporary directory and file
rm -rf $WDIR $unsorted
printf "done.\n"

EOF

chmod 0755 /sbin/mkinitramfs
mkdir -p /usr/share/mkinitramfs &&
cat > /usr/share/mkinitramfs/init.in << "EOF"
#!/bin/sh

PATH=/bin:/usr/bin:/sbin:/usr/sbin
export PATH

problem()
{
   printf "Encountered a problem!\n\nDropping you to a shell.\n\n"
   sh
}

no_device()
{
   printf "The device %s, which is supposed to contain the\n" $1
   printf "root file system, does not exist.\n"
   printf "Please fix this problem and exit this shell.\n\n"
}

no_mount()
{
   printf "Could not mount device %s\n" $1
   printf "Sleeping forever. Please reboot and fix the kernel command line.\n\n"
   printf "Maybe the device is formatted with an unsupported file system?\n\n"
   printf "Or maybe filesystem type autodetection went wrong, in which case\n"
   printf "you should add the rootfstype=... parameter to the kernel command line.\n\n"
   printf "Available partitions:\n"
}

do_mount_root()
{
   mkdir /.root
   [ -n "$rootflags" ] && rootflags="$rootflags,"
   rootflags="$rootflags$ro"

   case "$root" in
      /dev/* ) device=$root ;;
      UUID=* ) eval $root; device="/dev/disk/by-uuid/$UUID"  ;;
      LABEL=*) eval $root; device="/dev/disk/by-label/$LABEL" ;;
      ""     ) echo "No root device specified." ; problem    ;;
   esac

   while [ ! -b "$device" ] ; do
       no_device $device
       problem
   done

   if ! mount -n -t "$rootfstype" -o "$rootflags" "$device" /.root ; then
       no_mount $device
       cat /proc/partitions
       while true ; do sleep 10000 ; done
   else
       echo "Successfully mounted device $root"
   fi
}

init=/sbin/init
root=
rootdelay=
rootfstype=auto
ro="ro"
rootflags=
device=

mount -n -t devtmpfs devtmpfs /dev
mount -n -t proc     proc     /proc
mount -n -t sysfs    sysfs    /sys
mount -n -t tmpfs    tmpfs    /run

read -r cmdline < /proc/cmdline

for param in $cmdline ; do
  case $param in
    init=*      ) init=${param#init=}             ;;
    root=*      ) root=${param#root=}             ;;
    rootdelay=* ) rootdelay=${param#rootdelay=}   ;;
    rootfstype=*) rootfstype=${param#rootfstype=} ;;
    rootflags=* ) rootflags=${param#rootflags=}   ;;
    ro          ) ro="ro"                         ;;
    rw          ) ro="rw"                         ;;
  esac
done

# udevd location depends on version
if [ -x /sbin/udevd ]; then
  UDEV_PATH=/sbin
else
  UDEV_PATH=/lib/udev
fi

${UDEV_PATH}/udevd --daemon --resolve-names=never
udevadm trigger
udevadm settle

if [ -f /etc/mdadm.conf ] ; then mdadm -As                       ; fi
if [ -x /sbin/vgchange  ] ; then /sbin/vgchange -a y > /dev/null ; fi
if [ -n "$rootdelay"    ] ; then sleep "$rootdelay"              ; fi

do_mount_root

killall -w ${UDEV_PATH}/udevd

exec switch_root /.root "$init" "$@"

EOF

Using an initramfs

Required Runtime Dependency

To build an initramfs, run the following as the root user:
mkinitramfs [KERNEL VERSION]
The optional argument is the directory where the appropriate kernel modules are located. This must be a subdirectory of /lib/modules. If no modules are specified, then the initramfs is named initrd.img-no-kmods. If a kernel version is specified, the initrd is named initrd.img-$KERNEL_VERSION and is only appropriate for the specific kernel specified. The output file will be placed in the current directory.
After generating the initrd, copy it to the /boot directory.
Now edit /boot/grub/grub.cfg and add a new menuentry. Below are several examples.
# Generic initramfs and root fs identified by UUID
menuentry "LFS Dev (LFS-7.0-Feb14) initrd, Linux 3.0.4"
{
  linux  /vmlinuz-3.0.4-lfs-20120214 root=UUID=54b934a9-302d-415e-ac11-4988408eb0a8 ro
  initrd /initrd.img-no-kmods
}
# Generic initramfs and root fs on LVM partition
menuentry "LFS Dev (LFS-7.0-Feb18) initrd lvm, Linux 3.0.4"
{
  linux  /vmlinuz-3.0.4-lfs-20120218 root=/dev/mapper/myroot ro
  initrd /initrd.img-no-kmods
}
# Specific initramfs and root fs identified by LABEL
menuentry "LFS Dev (LFS-7.1-Feb20) initrd label, Linux 3.2.6"
{
  linux  /vmlinuz-3.2.6-lfs71-120220 root=LABEL=lfs71 ro
  initrd /initrd.img-3.2.6-lfs71-120220
}
Finally, reboot the system and select the desired system.

YOUTUBE IFRAMES?

YouTube Player API Reference for iframe Embeds

Contents

  1. Overview
  2. Requirements
  3. Getting started
  4. Loading a video player
  5. Operations
    1. Functions
      1. Queueing functions
      2. Playback controls and player settings
      3. Playback status
      4. Playback quality
      5. Retrieving video information
      6. Retrieving playlist information
      7. Adding an event listener
    2. Events
  6. Mobile Considerations
  7. Examples
  8. Revision history

Overview

Video introduction
The IFrame player API lets you embed a YouTube video player on your website and control the player using JavaScript. Unlike the Flash and JavaScript player APIs, which both involve embedding a Flash object on your web page, the IFrame API posts content to an <iframe> tag on your page. This approach provides more flexibility than the previously available APIs since it allows YouTube to serve an HTML5 player rather than a Flash player for mobile devices that do not support Flash.
Using the API's JavaScript functions, you can queue videos for playback; play, pause, or stop those videos; adjust the player volume; or retrieve information about the video being played. You can also add event listeners that will execute in response to certain player events, such as a player state change or a video playback quality change.
This guide explains how to use the IFrame API. It identifies the different types of events that the API can send and explains how to write event listeners to respond to those events. It also details the different JavaScript functions that you can call to control the video player as well as the player parameters you can use to further customize the player.

Requirements

The end user must be using a browser that supports the HTML5 postMessage feature. Most modern browsers support postMessage, though Internet Explorer 7 does not support it.
Embedded players must have a viewport that is at least 200px by 200px. If the player displays controls, it must be large enough to fully display the controls without shrinking the viewport below the minimum size. We recommend 16:9 players be at least 480 pixels wide and 270 pixels tall.
Any web page that uses the IFrame API must also implement the following JavaScript function:
  • onYouTubeIframeAPIReady – The API will call this function when the page has finished downloading the JavaScript for the player API, which enables you to then use the API on your page. Thus, this function might create the player objects that you want to display when the page loads.

Getting started

The sample HTML page below creates an embedded player that will load a video, play it for six seconds, and then stop the playback. The numbered comments in the HTML are explained in the list below the example.
<!DOCTYPE html>
<html>
  <body>
    <!-- 1. The <iframe> (and video player) will replace this <div> tag. -->
    <div id="player"></div>

    <script>
      // 2. This code loads the IFrame Player API code asynchronously.
      var tag = document.createElement('script');

      tag.src = "https://www.youtube.com/iframe_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

      // 3. This function creates an <iframe> (and YouTube player)
      //    after the API code downloads.
      var player;
      function onYouTubeIframeAPIReady() {
        player = new YT.Player('player', {
          height: '390',
          width: '640',
          videoId: 'M7lc1UVf-VE',
          events: {
            'onReady': onPlayerReady,
            'onStateChange': onPlayerStateChange
          }
        });
      }

      // 4. The API will call this function when the video player is ready.
      function onPlayerReady(event) {
        event.target.playVideo();
      }

      // 5. The API calls this function when the player's state changes.
      //    The function indicates that when playing a video (state=1),
      //    the player should play for six seconds and then stop.
      var done = false;
      function onPlayerStateChange(event) {
        if (event.data == YT.PlayerState.PLAYING && !done) {
          setTimeout(stopVideo, 6000);
          done = true;
        }
      }
      function stopVideo() {
        player.stopVideo();
      }
    </script>
  </body>
</html>
The following list provides more details about the sample above:
  1. The <div> tag in this section identifies the location on the page where the IFrame API will place the video player. The constructor for the player object, which is described in the Loading a video player section, identifies the <div> tag by its id to ensure that the API places the <iframe> in the proper location. Specifically, the IFrame API will replace the <div> tag with the <iframe> tag.
    As an alternative, you could also put the <iframe> element directly on the page. The Loading a video player section explains how to do so.
  2. The code in this section loads the IFrame Player API JavaScript code. The example uses DOM modification to download the API code to ensure that the code is retrieved asynchronously. (The <script> tag's async attribute, which also enables asynchronous downloads, is not yet supported in all modern browsers as discussed in this Stack Overflow answer.
  3. The onYouTubeIframeAPIReady function will execute as soon as the player API code downloads. This portion of the code defines a global variable,player, which refers to the video player you are embedding, and the function then constructs the video player object.
  4. The onPlayerReady function will execute when the onReady event fires. In this example, the function indicates that when the video player is ready, it should begin to play.
  5. The API will call the onPlayerStateChange function when the player's state changes, which may indicate that the player is playing, paused, finished, and so forth. The function indicates that when the player state is 1 (playing), the player should play for six seconds and then call the stopVideofunction to stop the video.

Loading a video player

After the API's JavaScript code loads, the API will call the onYouTubeIframeAPIReady function, at which point you can construct a YT.Player object to insert a video player on your page. The HTML excerpt below shows the onYouTubeIframeAPIReady function from the example above:
var player;
function onYouTubeIframeAPIReady() {
  player = new YT.Player('player', {
    height: '390',
    width: '640',
    videoId: 'M7lc1UVf-VE',
    events: {
      'onReady': onPlayerReady,
      'onStateChange': onPlayerStateChange
    }
  });
}
The constructor for the video player specifies the following parameters:
  1. The first parameter specifies either the DOM element or the id of the HTML element where the API will insert the <iframe> tag containing the player.
    The IFrame API will replace the specified element with the <iframe> element containing the player. This could affect the layout of your page if the element being replaced has a different display style than the inserted <iframe> element. By default, an <iframe> displays as an inline-blockelement.
  2. The second parameter is an object that specifies player options. The object contains the following properties:
    • width (number) – The width of the video player. The default value is 640.
    • height (number) – The height of the video player. The default value is 390.
    • videoId (string) – The YouTube video ID that identifies the video that the player will load.
    • playerVars (object) – The object's properties identify player parameters that can be used to customize the player.
    • events (object) – The object's properties identify the events that the API fires and the functions (event listeners) that the API will call when those events occur. In the example, the constructor indicates that the onPlayerReady function will execute when the onReady event fires and that theonPlayerStateChange function will execute when the onStateChange event fires.
As mentioned in the Getting started section, instead of writing an empty <div> element on your page, which the player API's JavaScript code will then replace with an <iframe> element, you could create the <iframe> tag yourself.
<iframe id="player" type="text/html" width="640" height="390"
  src="http://www.youtube.com/embed/M7lc1UVf-VE?enablejsapi=1&origin=http://example.com"
  frameborder="0"></iframe>
If you do write the <iframe> tag, then when you construct the YT.Player object, you do not need to specify values for the width and height, which are specified as attributes of the <iframe> tag, or the videoId and player parameters, which are are specified in the src URL. As an extra security measure, you should also include the origin parameter to the URL, specifying the URL scheme (http:// or https://) and full domain of your host page as the parameter value. While origin is optional, including it protects against malicious third-party JavaScript being injected into your page and hijacking control of your YouTube player.
The Examples section shows a few more examples for constructing video player objects.

Operations

To call the player API methods, you must first get a reference to the player object you wish to control. You obtain the reference by creating a YT.Player object as discussed in the Getting started and Loading a video player sections of this document.

Functions

The following subsections list the functions that the player API supports.

Queueing functions

Queueing functions allow you to load and play a video, a playlist, or another list of videos. If you are using the object syntax, described below, to call these functions, you can also queue or load a list of search results or a user's list of uploaded videos.
The API supports two different syntaxes for calling the queueing functions.
  • The argument syntax requires function arguments to be listed in a prescribed order.
  • The object syntax lets you pass an object as a single parameter and to define object properties for the function arguments that you wish to set. In addition, the API may support additional functionality that the argument syntax does not support.
For example, the loadVideoById function can be called in either of the following ways. Note that the object syntax supports the endSeconds property, which the argument syntax does not support.
  • Argument syntax
    loadVideoById("bHQqvYy5KYo", 5, "large")
  • Object syntax
    loadVideoById({'videoId': 'bHQqvYy5KYo', 'startSeconds': 5, 'endSeconds': 60, 'suggestedQuality': 'large'});
The different queueing functions for videos and playlists are described below.

Queueing functions for videos

cueVideoById
  • Argument syntax
    player.cueVideoById(videoId:String, startSeconds:Number, suggestedQuality:String):Void
  • Object syntax
    player.cueVideoById({videoId:String, startSeconds:Number, endSeconds:Number, suggestedQuality:String}):Void
This function loads the specified video's thumbnail and prepares the player to play the video. The player does not request the FLV until playVideo()or seekTo() is called.
  • The required videoId parameter specifies the YouTube Video ID of the video to be played. In YouTube Data API video feeds, the<yt:videoid> tag specifies the ID.
  • The optional startSeconds parameter accepts a float/integer and specifies the time from which the video should start playing whenplayVideo() is called. If you specify a startSeconds value and then call seekTo(), then the player plays from the time specified in theseekTo() call. When the video is cued and ready to play, the player will broadcast a video cued event (5).
  • The optional endSeconds parameter, which is only supported in object syntax, accepts a float/integer and specifies the time when the video should stop playing when playVideo() is called. If you specify an endSeconds value and then call seekTo(), the endSeconds value will no longer be in effect.
  • The optional suggestedQuality parameter specifies the suggested playback quality for the video. Please see the definition of thesetPlaybackQuality function for more information about playback quality.
loadVideoById
  • Argument syntax
    player.loadVideoById(videoId:String, startSeconds:Number, suggestedQuality:String):Void
  • Object syntax
    player.loadVideoById({videoId:String, startSeconds:Number, endSeconds:Number, suggestedQuality:String}):Void
This function loads and plays the specified video.
  • The required videoId parameter specifies the YouTube Video ID of the video to be played. In YouTube Data API video feeds, the<yt:videoid> tag specifies the ID.
  • The optional startSeconds parameter accepts a float/integer. If it is specified, then the video will start from the closest keyframe to the specified time.
  • The optional endSeconds parameter accepts a float/integer. If it is specified, then the video will stop playing at the specified time.
  • The optional suggestedQuality parameter specifies the suggested playback quality for the video. Please see the definition of thesetPlaybackQuality function for more information about playback quality.
cueVideoByUrl
  • Argument syntax
    player.cueVideoByUrl(mediaContentUrl:String, startSeconds:Number, suggestedQuality:String):Void
  • Object syntax
    player.cueVideoByUrl({mediaContentUrl:String, startSeconds:Number, endSeconds:Number, suggestedQuality:String}):Void
This function loads the specified video's thumbnail and prepares the player to play the video. The player does not request the FLV until playVideo()or seekTo() is called.
  • The required mediaContentUrl parameter specifies a fully qualified YouTube player URL in the formathttp://www.youtube.com/v/VIDEO_ID?version=3. In YouTube Data API video feeds, the <media:content> tag's url attribute contains a fully qualified player URL when the tag's format attribute has a value of 5.
  • The optional startSeconds parameter accepts a float/integer and specifies the time from which the video should start playing whenplayVideo() is called. If you specify startSeconds and then call seekTo(), then the player plays from the time specified in theseekTo() call. When the video is cued and ready to play, the player will broadcast a video cued event (5).
  • The optional endSeconds parameter, which is only supported in object syntax, accepts a float/integer and specifies the time when the video should stop playing when playVideo() is called. If you specify an endSeconds value and then call seekTo(), the endSeconds value will no longer be in effect.
  • The optional suggestedQuality parameter specifies the suggested playback quality for the video. Please see the definition of thesetPlaybackQuality function for more information about playback quality.
loadVideoByUrl
  • Argument syntax
    player.loadVideoByUrl(mediaContentUrl:String, startSeconds:Number, suggestedQuality:String):Void
  • Object syntax
    player.loadVideoByUrl({mediaContentUrl:String, startSeconds:Number, endSeconds:Number, suggestedQuality:String}):Void
This function loads and plays the specified video.
  • The required mediaContentUrl parameter specifies a fully qualified YouTube player URL in the formathttp://www.youtube.com/v/VIDEO_ID?version=3. In YouTube Data API video feeds, the url attribute of the <media:content> tag contains a fully qualified player URL when the tag's format attribute has a value of 5.
  • The optional startSeconds parameter accepts a float/integer and specifies the time from which the video should start playing. IfstartSeconds (number can be a float) is specified, the video will start from the closest keyframe to the specified time.
  • The optional endSeconds parameter, which is only supported in object syntax, accepts a float/integer and specifies the time when the video should stop playing.
  • The optional suggestedQuality parameter specifies the suggested playback quality for the video. Please see the definition of thesetPlaybackQuality function for more information about playback quality.

Queueing functions for lists

The cuePlaylist and loadPlaylist functions allow you to load and play a playlist or list of videos. If you are using the object syntax to call these functions, you can also queue (or load) a list of search results or a user's list of uploaded videos.
Since the functions work differently depending on whether they are called using the argument syntax or the object syntax, both calling methods are documented below.
  • Argument syntax
    player.cuePlaylist(playlist:String|Array, index:Number, startSeconds:Number, suggestedQuality:String):Void
    Queues the specified playlist. When the playlist is cued and ready to play, the player will broadcast a video cued event (5).
    • The required playlist parameter specifies an array of YouTube video IDs. In YouTube Data API feeds, the <yt:videoid> tag specifies a video ID.
    • The optional index parameter specifies the index of the first video in the playlist that will play. The parameter uses a zero-based index, and the default parameter value is 0, so the default behavior is to load and play the first video in the playlist.
    • The optional startSeconds parameter accepts a float/integer and specifies the time from which the first video in the playlist should start playing when the playVideo() function is called. If you specify a startSeconds value and then call seekTo(), then the player plays from the time specified in the seekTo() call. If you cue a playlist and then call the playVideoAt() function, the player will start playing at the beginning of the specified video.
    • The optional suggestedQuality parameter specifies the suggested playback quality for the video. Please see the definition of thesetPlaybackQuality function for more information about playback quality.
    player.loadPlaylist(playlist:String|Array, index:Number, startSeconds:Number, suggestedQuality:String):Void
    This function loads the specified playlist and plays it.
    • The required playlist parameter specifies an array of YouTube video IDs. In YouTube Data API feeds, the <yt:videoid> tag specifies a video ID.
    • The optional index parameter specifies the index of the first video in the playlist that will play. The parameter uses a zero-based index, and the default parameter value is 0, so the default behavior is to load and play the first video in the playlist.
    • The optional startSeconds parameter accepts a float/integer and specifies the time from which the first video in the playlist should start playing.
    • The optional suggestedQuality parameter specifies the suggested playback quality for the video. Please see the definition of thesetPlaybackQuality function for more information about playback quality.
  • Object syntax
    player.cuePlaylist({listType:String,
                        list:String,
                        index:Number,
                        startSeconds:Number,
                        suggestedQuality:String}):Void
    Queues the specified list of videos. The list can be a playlist, a search results feed, or a user's uploaded videos feed. When the list is cued and ready to play, the player will broadcast a video cued event (5).
    • The optional listType property specifies the type of results feed that you are retrieving. Valid values are playlistsearch, anduser_uploads. The default value is playlist.
    • The required list property contains a key that identifies the particular list of videos that YouTube should return.
      • If the listType property value is playlist, then the list property specifies the playlist ID or an array of video IDs. In YouTube Data API feeds, the <yt:playlistid> tag specifies a playlist ID, and the <yt:videoid> tag specifies a video ID.
      • If the listType property value is search, then the list property specifies the search query.
      • If the listType property value is user_uploads, then the list property identifies the user whose uploaded videos will be returned.
    • The optional index property specifies the index of the first video in the list that will play. The parameter uses a zero-based index, and the default parameter value is 0, so the default behavior is to load and play the first video in the list.
    • The optional startSeconds property accepts a float/integer and specifies the time from which the first video in the list should start playing when the playVideo() function is called. If you specify a startSeconds value and then call seekTo(), then the player plays from the time specified in the seekTo() call. If you cue a list and then call the playVideoAt() function, the player will start playing at the beginning of the specified video.
    • The optional suggestedQuality property specifies the suggested playback quality for the list's videos. Please see the definition of thesetPlaybackQuality function for more information about playback quality.
    player.loadPlaylist({list:String,
                         listType:String,
                         index:Number,
                         startSeconds:Number,
                         suggestedQuality:String}):Void
    This function loads the specified list and plays it. The list can be a playlist, a search results feed, or a user's uploaded videos feed.
    • The optional listType property specifies the type of results feed that you are retrieving. Valid values are playlistsearch, anduser_uploads. The default value is playlist.
    • The required list property contains a key that identifies the particular list of videos that YouTube should return.
      • If the listType property value is playlist, then the list property specifies a playlist ID or an array of video IDs. In YouTube Data API feeds, the <yt:playlistid> tag specifies a playlist ID, and the <yt:videoid> tag specifies a video ID.
      • If the listType property value is search, then the list property specifies the search query.
      • If the listType property value is user_uploads, then the list property identifies the user whose uploaded videos will be returned.
    • The optional index property specifies the index of the first video in the list that will play. The parameter uses a zero-based index, and the default parameter value is 0, so the default behavior is to load and play the first video in the list.
    • The optional startSeconds property accepts a float/integer and specifies the time from which the first video in the list should start playing.
    • The optional suggestedQuality property specifies the suggested playback quality for the list's videos. Please see the definition of the setPlaybackQuality function for more information about playback quality.

Playback controls and player settings

Playing a video

player.playVideo():Void
Plays the currently cued/loaded video. The final player state after this function executes will be playing (1).

Note: A playback only counts toward a video's official view count if it is initiated via a native play button in the player.
player.pauseVideo():Void
Pauses the currently playing video. The final player state after this function executes will be paused (2) unless the player is in the ended (0) state when the function is called, in which case the player state will not change.
player.stopVideo():Void
Stops and cancels loading of the current video. This function should be reserved for rare situations when you know that the user will not be watching additional video in the player. If your intent is to pause the video, you should just call the pauseVideo function. If you want to change the video that the player is playing, you can call one of the queueing functions without calling stopVideo first.

Important: Unlike the pauseVideo function, which leaves the player in the paused (2) state, the stopVideo function could put the player into any not-playing state, including ended (0), paused (2), video cued (5) or unstarted (-1).
player.seekTo(seconds:Number, allowSeekAhead:Boolean):Void
Seeks to a specified time in the video. If the player is paused when the function is called, it will remain paused. If the function is called from another state (playingvideo cued, etc.), the player will play the video.
  • The seconds parameter identifies the time to which the player should advance.
    The player will advance to the closest keyframe before that time unless the player has already downloaded the portion of the video to which the user is seeking. In that case, the player will advance to the closest keyframe before or after the specified time as dictated by the seek()method of the Flash player's NetStream object. (See Adobe's documentation for more information.)
  • The allowSeekAhead parameter determines whether the player will make a new request to the server if the seconds parameter specifies a time outside of the currently buffered video data.
    We recommend that you set this parameter to false while the user drags the mouse along a video progress bar and then set it to true when the user releases the mouse. This approach lets a user scroll to different points of a video without requesting new video streams by scrolling past unbuffered points in the video. When the user releases the mouse button, the player advances to the desired point in the video and requests a new video stream if necessary.
player.clearVideo():Void
Clears the video display. This function is useful if you want to clear the video remnant after calling stopVideo(). Note that this function has been deprecated in the ActionScript 3.0 Player API.

Playing a video in a playlist

player.nextVideo():Void
This function loads and plays the next video in the playlist.
  • If player.nextVideo() is called while the last video in the playlist is being watched, and the playlist is set to play continuously (loop), then the player will load and play the first video in the list.
  • If player.nextVideo() is called while the last video in the playlist is being watched, and the playlist is not set to play continuously, then playback will end.
player.previousVideo():Void
This function loads and plays the previous video in the playlist.
  • If player.previousVideo() is called while the first video in the playlist is being watched, and the playlist is set to play continuously (loop), then the player will load and play the last video in the list.
  • If player.previousVideo() is called while the first video in the playlist is being watched, and the playlist is not set to play continuously, then the player will restart the first playlist video from the beginning.
player.playVideoAt(index:Number):Void
This function loads and plays the specified video in the playlist.
  • The required index parameter specifies the index of the video that you want to play in the playlist. The parameter uses a zero-based index, so a value of 0 identifies the first video in the list. If you have shuffled the playlist, this function will play the video at the specified position in the shuffled playlist.

Changing the player volume

player.mute():Void
Mutes the player.
player.unMute():Void
Unmutes the player.
player.isMuted():Boolean
Returns true if the player is muted, false if not.
player.setVolume(volume:Number):Void
Sets the volume. Accepts an integer between 0 and 100.
player.getVolume():Number
Returns the player's current volume, an integer between 0 and 100. Note that getVolume() will return the volume even if the player is muted.

Setting the player size

player.setSize(width:Number, height:Number):Object
Sets the size in pixels of the <iframe> that contains the player.

Setting the playback rate

player.getPlaybackRate():Number
This function retrieves the playback rate of the currently playing video. The default playback rate is 1, which indicates that the video is playing at normal speed. Playback rates may include values like 0.250.511.5, and 2.
player.setPlaybackRate(suggestedRate:Number):Void
This function sets the suggested playback rate for the current video. If the playback rate changes, it will only change for the video that is already cued or being played. If you set the playback rate for a cued video, that rate will still be in effect when the playVideo function is called or the user initiates playback directly through the player controls. In addition, calling functions to cue or load videos or playlists (cueVideoByIdloadVideoById, etc.) will reset the playback rate to 1.

Calling this function does not guarantee that the playback rate will actually change. However, if the playback rate does change, theonPlaybackRateChange event will fire, and your code should respond to the event rather than the fact that it called the setPlaybackRate function.

The getAvailablePlaybackRates method will return the possible playback rates for the currently playing video. However, if you set thesuggestedRate parameter to a non-supported integer or float value, the player will round that value down to the nearest supported value in the direction of 1.
Note: Even though the AS3 player supports playback rate controls, variable speeds are currently only supported in the HTML5 player.
player.getAvailablePlaybackRates():Array
This function returns the set of playback rates in which the current video is available. The default value is 1, which indicates that the video is playing in normal speed.
The function returns an array of numbers ordered from slowest to fastest playback speed. Even if the player does not support variable playback speeds, the array should always contain at least one value (1).

Setting playback behavior for playlists

player.setLoop(loopPlaylists:Boolean):Void
This function indicates whether the video player should continuously play a playlist or if it should stop playing after the last video in the playlist ends. The default behavior is that playlists do not loop.
This setting will persist even if you load or cue a different playlist, which means that if you load a playlist, call the setLoop function with a value oftrue, and then load a second playlist, the second playlist will also loop.
  • The required loopPlaylists parameter identifies the looping behavior.
    • If the parameter value is true, then the video player will continuously play playlists. After playing the last video in a playlist, the video player will go back to the beginning of the playlist and play it again.
    • If the parameter value is false, then playbacks will end after the video player plays the last video in a playlist.
player.setShuffle(shufflePlaylist:Boolean):Void
This function indicates whether a playlist's videos should be shuffled so that they play back in an order different from the one that the playlist creator designated. If you shuffle a playlist after it has already started playing, the list will be reordered while the video that is playing continues to play. The next video that plays will then be selected based on the reordered list.
This setting will not persist if you load or cue a different playlist, which means that if you load a playlist, call the setShuffle function, and then load a second playlist, the second playlist will not be shuffled.
  • The required shufflePlaylist parameter indicates whether YouTube should shuffle the playlist.
    • If the parameter value is true, then YouTube will shuffle the playlist order. If you instruct the function to shuffle a playlist that has already been shuffled, YouTube will shuffle the order again.
    • If the parameter value is false, then YouTube will change the playlist order back to its original order.

Playback status

player.getVideoLoadedFraction():Float
Returns a number between 0 and 1 that specifies the percentage of the video that the player shows as buffered. This method returns a more reliable number than the now-deprecated getVideoBytesLoaded and getVideoBytesTotal methods.
player.getPlayerState():Number
Returns the state of the player. Possible values are unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5).
player.getCurrentTime():Number
Returns the elapsed time in seconds since the video started playing.
player.getVideoStartBytes():Number
Deprecated as of October 31, 2012. Returns the number of bytes the video file started loading from. (This method now always returns a value of 0.) Example scenario: the user seeks ahead to a point that hasn't loaded yet, and the player makes a new request to play a segment of the video that hasn't loaded yet.
player.getVideoBytesLoaded():Number
Deprecated as of July 18, 2012. Instead, use the getVideoLoadedFraction method to determine the percentage of the video that has buffered.

This method returns a value between 0 and 1000 that approximates the amount of the video that has been loaded. You could calculate the fraction of the video that has been loaded by dividing the getVideoBytesLoaded value by the getVideoBytesTotal value.
player.getVideoBytesTotal():Number
Deprecated as of July 18, 2012. Instead, use the getVideoLoadedFraction method to determine the percentage of the video that has buffered.

Returns the size in bytes of the currently loaded/playing video or an approximation of the video's size.

This method always returns a value of 1000. You could calculate the fraction of the video that has been loaded by dividing the getVideoBytesLoadedvalue by the getVideoBytesTotal value.

Playback quality

player.getPlaybackQuality():String
This function retrieves the actual video quality of the current video. It returns undefined if there is no current video. Possible return values are highres,hd1080hd720largemedium and small.
player.setPlaybackQuality(suggestedQuality:String):Void
This function sets the suggested video quality for the current video. The function causes the video to reload at its current position in the new quality. If the playback quality does change, it will only change for the video being played. Calling this function does not guarantee that the playback quality will actually change. However, if the playback quality does change, the onPlaybackQualityChange event will fire, and your code should respond to the event rather than the fact that it called the setPlaybackQuality function.

The suggestedQuality parameter value can be smallmediumlargehd720hd1080highres or default. We recommend that you set the parameter value to default, which instructs YouTube to select the most appropriate playback quality, which will vary for different users, videos, systems and other playback conditions.

When you suggest a playback quality for a video, the suggested quality will only be in effect for that video. You should select a playback quality that corresponds to the size of your video player. For example, if your page displays a 1280px by 720px video player, a hd720 quality video will actually look better than an hd1080 quality video. We recommend calling the getAvailableQualityLevels() function to determine which quality levels are available for a video.

The list below shows the playback quality levels that correspond to different standard player sizes. We recommend that you set the height of your video player to one of the values listed below and that you size your player to use 16:9 aspect ratio. As stated above, even if you choose a standard player size, we also recommend that you set the suggestedQuality parameter value to default to enable YouTube to select the most appropriate playback quality.

  • Quality level small: Player height is 240px, and player dimensions are at least 320px by 240px for 4:3 aspect ratio.
  • Quality level medium: Player height is 360px, and player dimensions are 640px by 360px (for 16:9 aspect ratio) or 480px by 360px (for 4:3 aspect ratio).
  • Quality level large: Player height is 480px, and player dimensions are 853px by 480px (for 16:9 aspect ratio) or 640px by 480px (for 4:3 aspect ratio).
  • Quality level hd720: Player height is 720px, and player dimensions are 1280px by 720px (for 16:9 aspect ratio) or 960px by 720px (for 4:3 aspect ratio).
  • Quality level hd1080: Player height is 1080px, and player dimensions are 1920px by 1080px (for 16:9 aspect ratio) or 1440px by 1080px (for 4:3 aspect ratio).
  • Quality level highres: Player height is greater than 1080px, which means that the player's aspect ratio is greater than 1920px by 1080px.
  • Quality level default: YouTube selects the appropriate playback quality. This setting effectively reverts the quality level to the default state and nullifies any previous efforts to set playback quality using the cueVideoByIdloadVideoById or setPlaybackQuality functions.

If you call the setPlaybackQuality function with a suggestedQuality level that is not available for the video, then the quality will be set to the next lowest level that is available. For example, if you request a quality level of large, and that is unavailable, then the playback quality will be set to medium(as long as that quality level is available).

In addition, setting suggestedQuality to a value that is not a recognized quality level is equivalent to setting suggestedQuality to default.
player.getAvailableQualityLevels():Array
This function returns the set of quality formats in which the current video is available. You could use this function to determine whether the video is available in a higher quality than the user is viewing, and your player could display a button or other element to let the user adjust the quality.

The function returns an array of strings ordered from highest to lowest quality. Possible array element values are highreshd1080hd720large,medium and small. This function returns an empty array if there is no current video.

Your client should not automatically switch to use the highest (or lowest) quality video or to any unknown format name. YouTube could expand the list of quality levels to include formats that may not be appropriate in your player context. Similarly, YouTube could remove quality options that would be detrimental to the user experience. By ensuring that your client only switches to known, available formats, you can ensure that your client's performance will not be affected by either the introduction of new quality levels or the removal of quality levels that are not appropriate for your player context.

Retrieving video information

player.getDuration():Number
Returns the duration in seconds of the currently playing video. Note that getDuration() will return 0 until the video's metadata is loaded, which normally happens just after the video starts playing.

If the currently playing video is a live event, the getDuration() function will return the elapsed time since the live video stream began. Specifically, this is the amount of time that the video has streamed without being reset or interrupted. In addition, this duration is commonly longer than the actual event time since streaming may begin before the event's start time.
player.getVideoUrl():String
Returns the YouTube.com URL for the currently loaded/playing video.
player.getVideoEmbedCode():String
Returns the embed code for the currently loaded/playing video.

Retrieving playlist information

player.getPlaylist():Array
This function returns an array of the video IDs in the playlist as they are currently ordered. By default, this function will return video IDs in the order designated by the playlist owner. However, if you have called the setShuffle function to shuffle the playlist order, then the getPlaylist() function's return value will reflect the shuffled order.
player.getPlaylistIndex():Number
This function returns the index of the playlist video that is currently playing.
  • If you have not shuffled the playlist, the return value will identify the position where the playlist creator placed the video. The return value uses a zero-based index, so a value of 0 identifies the first video in the playlist.
  • If you have shuffled the playlist, the return value will identify the video's order within the shuffled playlist.

Adding an event listener

player.addEventListener(event:String, listener:String):Void
Adds a listener function for the specified event. The Events section below identifies the different events that the player might fire. The listener is a string that specifies the function that will execute when the specified event fires.

Accessing and modifying DOM nodes

player.getIframe():Object
This method returns the DOM node for the embedded <iframe>.
player.destroy():Void
Removes the <iframe> containing the player.

Events

The API fires events to notify your application of changes to the embedded player. As noted in the previous section, you can subscribe to events by adding an event listener when constructing the YT.Player object, and you can also use the addEventListener function.
The API will pass an event object as the sole argument to each of those functions. The event object has the following properties:
  • The event's target identifies the video player that corresponds to the event.
  • The event's data specifies a value relevant to the event. Note that the onReady event does not specify a data property.
The following list defines the events that the API fires:
onReady
This event fires whenever a player has finished loading and is ready to begin receiving API calls. Your application should implement this function if you want to automatically execute certain operations, such as playing the video or displaying information about the video, as soon as the player is ready.

The example below shows a sample function for handling this event. The event object that the API passes to the function has a target property, which identifies the player The function retrieves the embed code for the currently loaded video, starts to play the video, and displays the embed code in the page element that has an id value of embed-code.
function onPlayerReady(event) {
  var embedCode = event.target.getVideoEmbedCode();
  event.target.playVideo();
  if (document.getElementById('embed-code')) {
    document.getElementById('embed-code').innerHTML = embedCode;
  }
}
onStateChange
This event fires whenever the player's state changes. The data property of the event object that the API passes to your event listener function will specify an integer that corresponds to the new player state. Possible values are:
  • -1 (unstarted)
  • 0 (ended)
  • 1 (playing)
  • 2 (paused)
  • 3 (buffering)
  • 5 (video cued).
When the player first loads a video, it will broadcast an unstarted (-1) event. When a video is cued and ready to play, the player will broadcast a video cued (5) event. In your code, you can specify the integer values or you can use one of the following namespaced variables:
  • YT.PlayerState.ENDED
  • YT.PlayerState.PLAYING
  • YT.PlayerState.PAUSED
  • YT.PlayerState.BUFFERING
  • YT.PlayerState.CUED
onPlaybackQualityChange
This event fires whenever the video playback quality changes. For example, if you call the setPlaybackQuality(suggestedQuality) function, this event will fire if the playback quality actually changes. Your application should respond to the event and should not assume that the quality will automatically change when the setPlaybackQuality(suggestedQuality) function is called. Similarly, your code should not assume that playback quality will only change as a result of an explicit call to setPlaybackQuality or any other function that allows you to set a suggested playback quality.

The data property value of the event object that the API passes to the event listener function will be a string that identifies the new playback quality. Possible values are:
  • small
  • medium
  • large
  • hd720
  • hd1080
  • highres
onPlaybackRateChange
This event fires whenever the video playback rate changes. For example, if you call the setPlaybackRate(suggestedRate) function, this event will fire if the playback rate actually changes. Your application should respond to the event and should not assume that the playback rate will automatically change when the setPlaybackRate(suggestedRate) function is called. Similarly, your code should not assume that the video playback rate will only change as a result of an explicit call to setPlaybackRate.

The data property value of the event object that the API passes to the event listener function will be a number that identifies the new playback rate. ThegetAvailablePlaybackRates method returns a list of the valid playback rates for the currently cued or playing video.

Note: Even though the AS3 player supports this event, variable speeds are currently only supported in the HTML5 player.
onError
This event fires if an error occurs in the player. The API will pass an event object to the event listener function. That object's data property will specify an integer that identifies the type of error that occurred. Possible values are:
  • 2 – The request contains an invalid parameter value. For example, this error occurs if you specify a video ID that does not have 11 characters, or if the video ID contains invalid characters, such as exclamation points or asterisks.
  • 5 – The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.
  • 100 – The video requested was not found. This error occurs when a video has been removed (for any reason) or has been marked as private.
  • 101 – The owner of the requested video does not allow it to be played in embedded players.
  • 150 – This error is the same as 101. It's just a 101 error in disguise!
onApiChange
This event is fired to indicate that the player has loaded (or unloaded) a module with exposed API methods. Your application can listen for this event and then poll the player to determine which options are exposed for the recently loaded module. Your application can then retrieve or update the existing settings for those options.

The following command retrieves an array of module names for which you can set player options:
player.getOptions();
Currently, the only module that you can set options for is the cc module, which handles closed captioning in the player. Upon receiving an onApiChangeevent, your application can use the following command to determine which options can be set for the cc module:
player.getOptions('cc');
By polling the player with this command, you can confirm that the options you want to access are, indeed, accessible. The following commands retrieve and update module options:
Retrieving an option:
player.getOption(module, option);

Setting an option
player.setOption(module, option, value);
The table below lists the options that the API supports:

ModuleOptionDescription
ccfontSizeThis option adjusts the font size of the captions displayed in the player.

Valid values are -1012, and 3. The default size is 0, and the smallest size is -1. Setting this option to an integer below -1will cause the smallest caption size to display, while setting this option to an integer above 3 will cause the largest caption size to display.
ccreloadThis option reloads the closed caption data for the video that is playing. The value will be null if you retrieve the option's value. Set the value to true to reload the closed caption data.

Mobile Considerations

Autoplay and Scripted Playback

The HTML5 <video> element, in certain mobile browsers (such as Chrome and Safari), only allows playback to take place if it's initiated by a user interaction (such as tapping on the player). Here's an excerpt from Apple's documentation:
"Warning: To prevent unsolicited downloads over cellular networks at the user’s expense, embedded media cannot be played automatically in Safari on iOS — the user always initiates playback."
Due to this restriction, functions and parameters such as autoplayplayVideo()loadVideoById() won't work in all mobile environments.

Examples

Creating YT.Player objects

  • Example 1: Loud playback
    This example creates a 1280px by 720px video player. The event listener for the onReady event then calls the setVolume function to adjust the volume to the highest setting.
    function onYouTubeIframeAPIReady() {
      var player;
      player = new YT.Player('player', {
        width: 1280,
        height: 720,
        videoId: 'M7lc1UVf-VE',
        events: {
          'onReady': onPlayerReady,
          'onPlaybackQualityChange': onPlayerPlaybackQualityChange,
          'onStateChange': onPlayerStateChange,
          'onError': onPlayerError
        }
      });
    }
    
    function onPlayerReady(event) {
      event.target.setVolume(100);
      event.target.playVideo();
    }
    
  • Example 2: This example sets player parameters to automatically play the video when it loads and to hide the video player's controls. It also adds event listeners for all of the events that the API broadcasts.
    function onYouTubeIframeAPIReady() {
      var player;
      player = new YT.Player('player', {
        videoId: 'M7lc1UVf-VE',
        playerVars: { 'autoplay': 1, 'controls': 0 },
        events: {
          'onReady': onPlayerReady,
          'onPlaybackQualityChange': onPlayerPlaybackQualityChange,
          'onStateChange': onPlayerStateChange,
          'onError': onPlayerError
        }
      });
    }

Revision history

This section lists YouTube IFrame Player API changes and documentation updates. Subscribe to this changelogSubscribe

March 25, 2014

This update contains the following changes:
  • The Requirements section has been updated to note that embedded players must have a viewport that is at least 200px by 200px. If a player displays controls, it must be large enough to fully display the controls without shrinking the viewport below the minimum size. We recommend 16:9 players be at least 480 pixels wide and 270 pixels tall.

July 23, 2013

This update contains the following changes:
  • The Overview now includes a video of a 2011 Google I/O presentation that discusses the iframe player.

October 31, 2012

This update contains the following changes:
  • The Queueing functions section has been updated to explain that you can use either argument syntax or object syntax to call all of those functions. Note that the API may support additional functionality in object syntax that the argument syntax does not support.
    In addition, the descriptions and examples for each of the video queueing functions have been updated to reflect the newly added support for object syntax. (The API's playlist queueing functions already supported object syntax.)
  • When called using object syntax, each of the video queueing functions supports an endSeconds property, which accepts a float/integer and specifies the time when the video should stop playing when playVideo() is called.
  • The getVideoStartBytes method has been deprecated. The method now always returns a value of 0.

August 22, 2012

This update contains the following changes:
  • The example in the Loading a video player section that demonstrates how to manually create the <iframe> tag has been updated to include a closing</iframe> tag since the onYouTubeIframeAPIReady function is only called if the closing </iframe> element is present.

August 6, 2012

This update contains the following changes:
  • The Operations section has been expanded to list all of the supported API functions rather than linking to the JavaScript Player API Reference for that list.
  • The API supports several new functions and one new event that can be used to control the video playback speed:
    • Functions
      • getAvailablePlaybackRates – Retrieve the supported playback rates for the cued or playing video. Note that variable playback rates are currently only supported in the HTML5 player.
      • getPlaybackRate – Retrieve the playback rate for the cued or playing video.
      • setPlaybackRate – Set the playback rate for the cued or playing video.
    • Events

July 19, 2012

This update contains the following changes:
  • The new getVideoLoadedFraction method replaces the now-deprecated getVideoBytesLoaded and getVideoBytesTotal methods. The new method returns the percentage of the video that the player shows as buffered.
  • The onError event may now return an error code of 5, which indicates that the requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.
  • The Requirements section has been updated to indicate that any web page using the IFrame API must also implement theonYouTubeIframeAPIReady function. Previously, the section indicated that the required function was named onYouTubePlayerAPIReady. Code samples throughout the document have also been updated to use the new name.
    Note: To ensure that this change does not break existing implementations, both names will work. If, for some reason, your page has anonYouTubeIframeAPIReady function and an onYouTubePlayerAPIReady function, both functions will be called, and theonYouTubeIframeAPIReady function will be called first.
  • The code sample in the Getting started section has been updated to reflect that the URL for the IFrame Player API code has changed tohttp://www.youtube.com/iframe_api. To ensure that this change does not affect existing implementations, the old URL (http://www.youtube.com/player_api) will continue to work.

July 16, 2012

This update contains the following changes:
  • The Operations section now explains that the API supports the setSize() and destroy() methods. The setSize() method sets the size in pixels of the <iframe> that contains the player and the destroy() method removes the <iframe>.

June 6, 2012

This update contains the following changes:
  • We have removed the experimental status from the IFrame Player API.
  • The Loading a video player section has been updated to point out that when inserting the <iframe> element that will contain the YouTube player, the IFrame API replaces the element specified in the constructor for the YouTube player. This documentation change does not reflect a change in the API and is intended solely to clarify existing behavior.
    In addition, that section now notes that the insertion of the <iframe> element could affect the layout of your page if the element being replaced has a different display style than the inserted <iframe> element. By default, an <iframe> displays as an inline-block element.

March 30, 2012

This update contains the following changes:
  • The Operations section has been updated to explain that the IFrame API supports a new method, getIframe(), which returns the DOM node for the IFrame embed.

March 26, 2012

This update contains the following changes:
  • The Requirements section has been updated to note the minimum player size.