2017 © Pedro Peláez
 

symfony-bundle phantasos-client-bundle

MESD Phantasos Client Bundle

image

mesd/phantasos-client-bundle

MESD Phantasos Client Bundle

  • Wednesday, September 27, 2017
  • by appdev@mesd.k12.or.us
  • Repository
  • 11 Watchers
  • 0 Stars
  • 2,971 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Phantasos Client Bundle

The purpose of this Symfony bundle is to provide a set of tools to make connecting to our simple media server, Phantasos., (*1)

Getting Started

To install the bundle with your Symfony application, use composer to add the client to your application., (*2)

$ composer require mesd/phantasos-client-bundle "~0.1"

Then add the bundle to your app kernel., (*3)

$bundles = array(
  ...
  new Mesd\PhantasosClientBundle\MesdPhantasosClientBundle()
);

After that, the settings for the client need to be configured in your config.yml file., (*4)

mesd_phantasos_client:
  host: %phantasos_host%
  apikey: %phantasos_apikey%
  ready_callback_route: my_app_media_callback

The host is where the root of the Phantasos's rest api is, and apikey is the generated apikey for this application from Phantasos. The ready callback route is optional and takes the name of one of your application's named symfony routes to callback when the media done processing and is ready for playback. An example of what this action will look like is below. The method for the action needs to be POST, and the media id for the media that the call is being made about is in the body of the request under the name of 'media_id'., (*5)

/**
 * @Route('/myapp/media_is_ready', name="my_app_media_callback")
 * @Method({"POST"})
 */
public function myMediaIsDoneCallbackAction(Request $request)
{
  $mediaId = $request->request->get('media_id');

  // Application specific stuff here ...

  return new Response('Message Recieved', 200);
}

If everything went as expected, then your application is ready to use the client., (*6)

Usage

The client bundle will add a new service to the dependency injection container called 'mesd_phantasos_client' that will return the Phantasos Client preconstructed with the host and apikey information needed to make calls to the media server., (*7)

Uploading

Uploading to Phantasos is a two step process. First an upload ticket needs to be retrieved from Phantasos along with an upload route. Then the end user will directly upload the media to media server. To obtain an the upload ticket information from the client, do as follows., (*8)

$ticket = $this->get('mesd_phantasos_client')->requestUploadTicket();

// The upload ticket contains information such as the media id that will need to be saved in your application
$mediaLink = new MediaLink() // Or whatever you are using to persist the media information in the using application
$mediaLink->setMediaId($ticket->getMediaId());
// Persist the media link and do whatever other application specific things need to be done

After obtaining the ticket and persisting the information you want to save, provide the user with the a simple upload form in html that has the action pointing to the url provided by in the upload ticket. Note, that the media server will return a set of responses back when uploading, so you may want to use some javascript on the end user side to track these in case an error is thrown or to mark that the media was successfully uploaded on the using application side., (*9)

Playback

The easist way to have playback for the media is to embed the following twig directive in your template where you wish to display the media, where 'myMediaId', is the media id of the media you wish to display and width and height are the resolution in pixels you wish to display the media as., (*10)

{{ render(url('MesdPhantasosClient_embedMedia', { 'mediaId': myMediaId, 'width': 800, 'height': 600 })) }}

The bundle can support PDFs, video, audio, and images, all the types of media currently supported by Phantasos., (*11)

Given that the support for streaming directly from the end user form the server is not currently finished or in place, the client my change later in regards to playback., (*12)

The Versions

27/09 2017

dev-master

9999999-dev https://github.com/mesd

MESD Phantasos Client Bundle

  Sources   Download

MIT

The Requires

 

by Tyler Hand

27/09 2017

v0.1.2

0.1.2.0 https://github.com/mesd

MESD Phantasos Client Bundle

  Sources   Download

MIT

The Requires

 

by Tyler Hand

11/06 2015

v0.1.1

0.1.1.0 https://github.com/mesd

MESD Phantasos Client Bundle

  Sources   Download

MIT

The Requires

 

by Tyler Hand

04/06 2015

v0.1.0

0.1.0.0 https://github.com/mesd

MESD Phantasos Client Bundle

  Sources   Download

MIT

The Requires

 

by Tyler Hand